Skip to content

API wrapper for the official Brawl Stars API

Notifications You must be signed in to change notification settings

willshiao/brawlstars.js

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Brawl Stars

Discord

Unofficial API wrapper for the Official Brawl Stars API.

This package implements all the API and is written in TypeScript for safety and full typings support.

Note: This library got a major rewrite to v2 and is not backward compatible anymore, the previous version was for Starlist API which is now discontinued and so the v2 is made with TypeScript and uses the official API.

Install

$ npm install brawlstars

TypeScript typings included in the installation.

Usage

Simply import the Client class and instantiate it with your API token:

// TypeScript, ESM
import { Client } from "brawlstars";

// CommonJS, Node.js
const { Client } = require("brawlstars");

// Create instance
const client = new Client("TOKEN", { 
  cache: true, // default is true
  cacheOptions: undefined /* options for node-cache, default is undefined. */
});

// Call into functions
client.getPlayer("TAG")
  .then((player) => console.log(player.name))
  .catch((err) => console.error(err));

All functions return a Promise. Tags are cleaned before use (Removes # and replaces letter O with zero 0)

All results are cached when supercell sends cache-control in the response, in that case the objects are in cache until the max-age expires. Caching can be disabled and options can be passed to the underlying node-cache library.

TypeScript

Types for responses are exposed for easy TypeScript usage and safety.

import { Client, Player } from "brawlstars";

const client = new Client(...);

client.getPlayer("TAG")
  .then((player: Player) => {
    // Access player fields.
  });

Getting Support

Best way to contact me is through my Discord Server. You can also open issues for bug reports or suggestions.

License

BrawlStars Wrapper is released under the MIT License

This is an unofficial wrapper and I do not own the name Brawl Stars in any way.

About

API wrapper for the official Brawl Stars API

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 100.0%