1.1.2 • Published 4 months ago

coc-game-api v1.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

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 => {/*...*/})
1.1.2

4 months ago

1.1.1

11 months ago

1.1.0

11 months ago

1.0.4

12 months ago

1.0.3

12 months ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago