clashperk / clashofclans.js

JavaScript library for interacting with the Clash of Clans API
https://clashofclans.js.org/
MIT License
54 stars 23 forks source link
clash-of-clans clash-of-clans-api clashapi clashofclans hacktoberfest
[![Logo](https://i.imgur.com/RHkfYVm.png.png)](https://clashofclans.js.org/) ### JavaScript library for interacting with the Clash of Clans API [![ESLint](https://github.com/clashperk/clashofclans.js/actions/workflows/eslint.yml/badge.svg)](https://github.com/clashperk/clashofclans.js/actions/workflows/node.js.yml) [![Logo](https://img.shields.io/npm/v/clashofclans.js.svg?maxAge=3600)](https://www.npmjs.com/package/clashofclans.js)

Installation

Links

Examples

const { Client } = require('clashofclans.js');

Login with Email Password

const client = new Client();

(async function () {
  // This method should be called once when application starts.
  await client.login({ email: 'developer@email.com', password: '***' });

  const clan = await client.getClan('#2PP');
  console.log(`${clan.name} (${clan.tag})`);
})();

Login with API Keys

const client = new Client({ keys: ['api_key_goes_here'] });

(async function () {
  const clan = await client.getClan('#2PP');
  console.log(`${clan.name} (${clan.tag})`);
})();

Events

The API lacks socket-based real-time events. It is recommended to implement your own custom polling system. Pull data at specified intervals, compare with previous values, and emit events on change. Consider using Node.js clusters and threads for efficient parallel processing.

Disclaimer

This content is not affiliated with, endorsed, sponsored, or specifically approved by Supercell and Supercell is not responsible for it. For more information see Supercell's Fan Content Policy.