coc-game-api
v1.1.2
Published
Clash of Clans API
Downloads
13
Readme
Clash of Clans API
Full types support
Installation
npm i coc-game-api --save
Usage
Clans
Find clans by filters
import { cocAPI, WarFrequency } from 'coc-game-api'
const { clans } = cocAPI(TOKEN)
clans.findAll({
name: 'Deutschland',
warFrequency: WarFrequency.always,
minMembers: 10,
limit: 5
// ...
}).then(clans => {
clans.forEach(clan => console.log(clan))
})
Get info about clan
import { cocAPI } from 'coc-game-api'
const { clans } = cocAPI(TOKEN)
const clan = clans.getByTag(CLAN_TAG)
clan.getInfo().then(allInfo => {/*...*/})
clan.getMembers().then(members => {/*...*/})
clan.getCurrentWar().then(warInfo => {/*...*/})
clan.getWarLog().then(warLogs => {/*...*/})
clan.getWarLeagueGroup().then(warLeagueInfo => {/*...*/})
clan.getCapitalRaidSeasons().then(raidSeasons => {/*...*/})
Clan war leagues
import { cocAPI } from 'coc-game-api'
const { clanwarleagues } = cocAPI(TOKEN)
clanwarleagues.getWarLeagueWar('war-tag').then(info => {/*...*/})
Players
Get info about player
import { cocAPI } from 'coc-game-api'
const { players } = cocAPI(TOKEN)
players.getByTag(PLAYER_TAG).then(playerInfo => {/*...*/})
Get info about player clan
import { cocAPI } from 'coc-game-api'
const { players } = cocAPI(TOKEN)
players.getByTag(PLAYER_TAG).then(async playerInfo => {
const clanInfo = await playerInfo.clan.getInfo()
console.log(clanInfo)
})
Leagues
import { cocAPI, LeagueID, CapitalLeagueID, WarLeagueID } from 'coc-game-api'
const { leagues } = cocAPI(TOKEN)
leagues.getLeagues().then(leagues => {/*...*/})
leagues.getLeague(LeagueID.Legend).then(info => {/*...*/})
leagues.getLeagueSeasons(LeagueID.Legend).then(seasons => {/*...*/})
leagues.getLeagueSeasonRankings(LeagueID.Legend, 'season-id').then(rankings => {/*...*/})
leagues.getCapitalLeagues().then(capitalLeagues => {/*...*/})
leagues.getCapitalLeague(CapitalLeague.Titan1).then(info => {/*...*/})
leagues.getWarLeagues().then(warLeagues => {/*...*/})
leagues.getWarLeague(WarLeague.Gold1).then(info => {/*...*/})
Locations
import { cocAPI, LocationID } from 'coc-game-api'
const { locations } = cocAPI(TOKEN)
locations.getList().then(list => {/*...*/})
const location = locations.getByID(LocationID.Europe)
location.getInfo().then(info => {/*...*/})
location.getClanRankings().then(rankings => {/*...*/})
location.getPlayerRankings().then(rankings => {/*...*/})
location.getClanVersusRankings().then(rankings => {/*...*/})
location.getPlayerVersusRankings().then(rankings => {/*...*/})
location.getCapitalRankings().then(rankings => {/*...*/})
Goldpass
import { cocAPI } from 'coc-game-api'
const { goldpass } = cocAPI(TOKEN)
goldpass.getCurrentSeason().then(info => {/*...*/})
Labels
import { cocAPI } from 'coc-game-api'
const { labels } = cocAPI(TOKEN)
labels.getClanLabels().then(labels => {/*...*/})
labels.getPlayerLabels().then(labels => {/*...*/})