Class: Client
Represents Clash of Clans API Client.
const { Client } = require('clashofclans.js');
const client = new Client({ keys: ['***'] });
Hierarchy
EventEmitter
↳
Client
Constructors
constructor
• new Client(options?
)
Parameters
Name | Type |
---|---|
options? | ClientOptions |
Defined in
Properties
emit
• emit: <K>(event
: K
, ...args
: IClientEvents
[K
]) => boolean
& <S>(event
: Exclude
<S
, keyof IClientEvents
>, ...args
: any
[]) => boolean
Defined in
off
• off: <K>(event
: K
, listener
: (...args
: IClientEvents
[K
]) => void
) => Client
& <S>(event
: Exclude
<S
, keyof IClientEvents
>, listener
: (...args
: any
[]) => void
) => Client
Defined in
on
• on: <K>(event
: K
, listener
: (...args
: IClientEvents
[K
]) => void
) => Client
& <S>(event
: Exclude
<S
, keyof IClientEvents
>, listener
: (...args
: any
[]) => void
) => Client
Defined in
once
• once: <K>(event
: K
, listener
: (...args
: IClientEvents
[K
]) => void
) => Client
& <S>(event
: Exclude
<S
, keyof IClientEvents
>, listener
: (...args
: any
[]) => void
) => Client
Defined in
removeAllListeners
• removeAllListeners: <K>(event?
: K
) => Client
& <S>(event?
: Exclude
<S
, keyof IClientEvents
>) => Client
Defined in
rest
• rest: RESTManager
REST Handler of the client.
Defined in
Accessors
util
• get
util(): typeof Util
Contains various general-purpose utility methods.
Returns
typeof Util
Defined in
Methods
login
▸ login(options
): Promise
<string
[]>
Initialize the client to create keys.
Parameters
Name | Type |
---|---|
options | LoginOptions |
Returns
Promise
<string
[]>
Example
const client = new Client();
client.login({ email: 'developer@email.com', password: '***' });
Defined in
setKeys
▸ setKeys(keys
): Client
Set Clash of Clans API keys.
Parameters
Name | Type |
---|---|
keys | string [] |
Returns
Defined in
getClans
▸ getClans(query
, options?
): Promise
<Clan
[]>
Search clans by name and/or filtering parameters or get clans by their tags (fetches in parallel).
Parameters
Name | Type |
---|---|
query | string [] | ClanSearchOptions |
options? | OverrideOptions |
Returns
Promise
<Clan
[]>
Defined in
getClan
▸ getClan(clanTag
, options?
): Promise
<Clan
>
Get info about a clan.
Parameters
Name | Type |
---|---|
clanTag | string |
options? | OverrideOptions |
Returns
Promise
<Clan
>
Defined in
getClanMembers
▸ getClanMembers(clanTag
, options?
): Promise
<ClanMember
[]>
Get list of clan members.
Parameters
Name | Type |
---|---|
clanTag | string |
options? | SearchOptions |
Returns
Promise
<ClanMember
[]>
Defined in
getCapitalRaidSeasons
▸ getCapitalRaidSeasons(tag
, options?
): Promise
<CapitalRaidSeason
[]>
Get capital raid seasons.
Parameters
Name | Type |
---|---|
tag | string |
options? | SearchOptions |
Returns
Promise
<CapitalRaidSeason
[]>
Defined in
getClanWarLog
▸ getClanWarLog(clanTag
, options?
): Promise
<ClanWarLog
[]>
Get clan war log.
Parameters
Name | Type |
---|---|
clanTag | string |
options? | SearchOptions |
Returns
Promise
<ClanWarLog
[]>
Defined in
getClanWar
▸ getClanWar(clanTag
, options?
): Promise
<ClanWar
>
Get info about currently running war (normal or friendly) in the clan.
Parameters
Name | Type |
---|---|
clanTag | string |
options? | OverrideOptions |
Returns
Promise
<ClanWar
>
Defined in
getCurrentWar
▸ getCurrentWar(clanTag
, options?
): Promise
<null
| ClanWar
>
Get info about currently running war in the clan.
Parameters
Name | Type |
---|---|
clanTag | string | { clanTag : string ; round? : "PreviousRound" | "CurrentRound" | "NextRound" } |
options? | OverrideOptions |
Returns
Promise
<null
| ClanWar
>
Example
await client.getCurrentWar('#8QU8J9LP');
Example
await client.getCurrentWar({ clanTag: '#8QU8J9LP', round: 'PREVIOUS_ROUND' });
Defined in
getLeagueWar
▸ getLeagueWar(clanTag
, options?
): Promise
<null
| ClanWar
>
Get info about currently running CWL round.
Parameters
Name | Type |
---|---|
clanTag | string | { clanTag : string ; round? : "PreviousRound" | "CurrentRound" | "NextRound" } |
options? | OverrideOptions |
Returns
Promise
<null
| ClanWar
>
Example
await client.getLeagueWar('#8QU8J9LP');
Example
await client.getLeagueWar({ clanTag: '#8QU8J9LP', round: 'PREVIOUS_ROUND' });
Defined in
getLeagueWars
▸ getLeagueWars(clanTag
, options?
): Promise
<ClanWar
[]>
Returns active wars (last 2) of the CWL group.
Parameters
Name | Type |
---|---|
clanTag | string |
options? | OverrideOptions |
Returns
Promise
<ClanWar
[]>
Defined in
getWars
▸ getWars(clanTag
, options?
): Promise
<ClanWar
[]>
Returns active wars (last 2 for CWL) of the clan.
Parameters
Name | Type |
---|---|
clanTag | string |
options? | OverrideOptions |
Returns
Promise
<ClanWar
[]>
Defined in
getClanWarLeagueGroup
▸ getClanWarLeagueGroup(clanTag
, options?
): Promise
<ClanWarLeagueGroup
>
Get info about clan war league.
Parameters
Name | Type |
---|---|
clanTag | string |
options? | OverrideOptions |
Returns
Promise
<ClanWarLeagueGroup
>
Defined in
getClanWarLeagueRound
▸ getClanWarLeagueRound(warTag
, options?
): Promise
<ClanWar
>
Get info about a CWL round by WarTag.
Parameters
Name | Type |
---|---|
warTag | string | { warTag : string ; clanTag? : string } |
options? | OverrideOptions |
Returns
Promise
<ClanWar
>
Defined in
getPlayer
▸ getPlayer(playerTag
, options?
): Promise
<Player
>
Get info about a player by tag.
Parameters
Name | Type |
---|---|
playerTag | string |
options? | OverrideOptions |
Returns
Promise
<Player
>
Defined in
getPlayers
▸ getPlayers(playerTags
, options?
): Promise
<Player
[]>
Get info about some players by their tags (fetches in parallel).
Parameters
Name | Type |
---|---|
playerTags | string [] |
options? | OverrideOptions |
Returns
Promise
<Player
[]>
Defined in
verifyPlayerToken
▸ verifyPlayerToken(playerTag
, token
, options?
): Promise
<boolean
>
Verify Player API token that can be found from the Game settings.
Parameters
Name | Type |
---|---|
playerTag | string |
token | string |
options? | OverrideOptions |
Returns
Promise
<boolean
>
Defined in
getLeagues
▸ getLeagues(options?
): Promise
<APILeague
[]>
Get a list of Leagues.
Parameters
Name | Type |
---|---|
options? | SearchOptions |
Returns
Promise
<APILeague
[]>
Defined in
getBuilderBaseLeagues
▸ getBuilderBaseLeagues(options?
): Promise
<APIBuilderBaseLeague
[]>
Get a list of Leagues.
Parameters
Name | Type |
---|---|
options? | SearchOptions |
Returns
Promise
<APIBuilderBaseLeague
[]>
Defined in
getCapitalLeagues
▸ getCapitalLeagues(options?
): Promise
<APICapitalLeague
[]>
Get a list of Capital Leagues.
Parameters
Name | Type |
---|---|
options? | SearchOptions |
Returns
Promise
<APICapitalLeague
[]>
Defined in
getLeagueSeasons
▸ getLeagueSeasons(options?
): Promise
<string
[]>
Get Legend League season Ids.
Parameters
Name | Type |
---|---|
options? | SearchOptions |
Returns
Promise
<string
[]>
Defined in
getSeasonRankings
▸ getSeasonRankings(seasonId
, options?
): Promise
<SeasonRankedPlayer
[]>
Get Legend League season rankings by season Id.
Parameters
Name | Type |
---|---|
seasonId | string |
options? | SearchOptions |
Returns
Promise
<SeasonRankedPlayer
[]>
Defined in
getWarLeagues
▸ getWarLeagues(options?
): Promise
<APIWarLeague
[]>
Get list of Clan War Leagues.
Parameters
Name | Type |
---|---|
options? | SearchOptions |
Returns
Promise
<APIWarLeague
[]>
Defined in
getLocations
▸ getLocations(options?
): Promise
<Location
[]>
Get list of Locations.
Parameters
Name | Type |
---|---|
options? | SearchOptions |
Returns
Promise
<Location
[]>
Defined in
getClanRanks
▸ getClanRanks(locationId
, options?
): Promise
<RankedClan
[]>
Get clan rankings for a specific location.
For global ranking, use global
as locationId
.
Parameters
Name | Type |
---|---|
locationId | number | "global" |
options? | SearchOptions |
Returns
Promise
<RankedClan
[]>
Defined in
getPlayerRanks
▸ getPlayerRanks(locationId
, options?
): Promise
<RankedPlayer
[]>
Get player rankings for a specific location.
For global ranking, use global
as locationId
.
Parameters
Name | Type |
---|---|
locationId | number | "global" |
options? | SearchOptions |
Returns
Promise
<RankedPlayer
[]>
Defined in
getBuilderBaseClanRanks
▸ getBuilderBaseClanRanks(locationId
, options?
): Promise
<RankedClan
[]>
Get clan builder base rankings for a specific location.
For global ranking, use global
as locationId
.
Parameters
Name | Type |
---|---|
locationId | number | "global" |
options? | SearchOptions |
Returns
Promise
<RankedClan
[]>
Defined in
getBuilderBasePlayerRanks
▸ getBuilderBasePlayerRanks(locationId
, options?
): Promise
<RankedPlayer
[]>
Get player builder base rankings for a specific location.
For global ranking, use global
as locationId
.
Parameters
Name | Type |
---|---|
locationId | number | "global" |
options? | SearchOptions |
Returns
Promise
<RankedPlayer
[]>
Defined in
getClanCapitalRanks
▸ getClanCapitalRanks(locationId
, options?
): Promise
<APIClanCapitalRanking
[]>
Get clan capital rankings for a specific location.
For global ranking, use global
as locationId
.
Parameters
Name | Type |
---|---|
locationId | number | "global" |
options? | SearchOptions |
Returns
Promise
<APIClanCapitalRanking
[]>
Defined in
getClanLabels
▸ getClanLabels(options?
): Promise
<APILabel
[]>
Get list of clan labels.
Parameters
Name | Type |
---|---|
options? | SearchOptions |
Returns
Promise
<APILabel
[]>
Defined in
getPlayerLabels
▸ getPlayerLabels(options?
): Promise
<APILabel
[]>
Get list of player labels.
Parameters
Name | Type |
---|---|
options? | SearchOptions |
Returns
Promise
<APILabel
[]>
Defined in
getGoldPassSeason
▸ getGoldPassSeason(options?
): Promise
<GoldPassSeason
>
Get info about gold pass season.
Parameters
Name | Type |
---|---|
options? | OverrideOptions |
Returns
Promise
<GoldPassSeason
>
Defined in
Events
debug
• debug: string
Emitted for general debugging information.
Defined in
error
• error: string
Emitted when the client encounters an error.