https://github.com/verzsut/coc-game-api
Clash of Clans API
https://github.com/verzsut/coc-game-api
api clash-of-clans clashofclans
Last synced: about 2 months ago
JSON representation
Clash of Clans API
- Host: GitHub
- URL: https://github.com/verzsut/coc-game-api
- Owner: VerZsuT
- License: mit
- Created: 2023-05-02T13:40:45.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-01T08:25:30.000Z (over 1 year ago)
- Last Synced: 2024-10-15T04:33:05.895Z (7 months ago)
- Topics: api, clash-of-clans, clashofclans
- Language: TypeScript
- Homepage:
- Size: 56.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Clash of Clans API
**_Full types support_**
## Installation
```cmd
npm i coc-game-api --save
```## Usage
### Clans
**Find clans by filters**
```js
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**
```js
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
```js
import { cocAPI } from 'coc-game-api'
const { clanwarleagues } = cocAPI(TOKEN)clanwarleagues.getWarLeagueWar('war-tag').then(info => {/*...*/})
```### Players
**Get info about player**
```js
import { cocAPI } from 'coc-game-api'
const { players } = cocAPI(TOKEN)players.getByTag(PLAYER_TAG).then(playerInfo => {/*...*/})
```**Get info about player clan**
```js
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
```js
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
```js
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
```js
import { cocAPI } from 'coc-game-api'
const { goldpass } = cocAPI(TOKEN)goldpass.getCurrentSeason().then(info => {/*...*/})
```### Labels
```js
import { cocAPI } from 'coc-game-api'
const { labels } = cocAPI(TOKEN)labels.getClanLabels().then(labels => {/*...*/})
labels.getPlayerLabels().then(labels => {/*...*/})
```