lib to call Clash-of-Clans API compatible with typescript
npm install @devgoe/coc.js
ts
import { Api } from "@devgoe/coc.js";
const client = new Api({
baseApiParams: {
headers: {
Authorization: Bearer ${process.env.COC_TOKEN},
},
},
});
`
Use the process.env.COC_TOKEN to store your token in your .env File
After the initial creation of the API you can use all features listed on the coc API description.
This package also supports TypeScript
For example you can search for Clans using the .clans syntax
`ts
client.clans
.searchClans({
name: "example",
limit: 10,
})
.then((res) =>
res.data.items.forEach((clan) => {
console.log(clan.name);
})
);
`
`ts
const clans = await client.clans.searchClans({
name: "example",
limit: 10,
});
``