UNPKG

sprcl

Version:

Simple API client for Clash of Clans, Clash Royale, and Brawl Stars

66 lines (44 loc) 1.5 kB
# sprcl A simple Node.js library to fetch player and clan data from Clash of Clans, Clash Royale, and Brawl Stars. ## Installation ```bash npm install sprcl ``` ## Quick Start ```js const { Client } = require('sprcl'); const client = new Client('YOUR_API_KEY', 'clashofclans'); (async () => { const player = await client.getPlayer('#PLAYER_TAG'); console.log(player); const clan = await client.getClan('#CLAN_TAG'); console.log(clan); })(); ``` ## Supported Games - `clashofclans` - `clashroyale` - `brawlstars` ## Where to Get API Keys - **Clash of Clans**: [https://developer.clashofclans.com](https://developer.clashofclans.com) - **Clash Royale**: [https://developer.clashroyale.com](https://developer.clashroyale.com) - **Brawl Stars**: [https://developer.brawlstars.com](https://developer.brawlstars.com) You must sign in with your Supercell ID and create a key for each game. Ensure you whitelist your server's IP address. ## API ### `new Client(apiKey, game)` Creates a new client instance for the selected game. ### `client.getPlayer(tag)` Fetches player data by tag. ### `client.getClan(tag)` Fetches clan data by tag. ## Environment Variables (recomended) You can use environment variables with the `dotenv` package: ```js require('dotenv').config(); const client = new Client(process.env.COC_API_KEY, 'clashofclans'); ``` ## Notes - Each game uses a different API key. - Player and clan objects will be formatted according to the selected game. ## License MIT