Giter Site home page Giter Site logo

brawlstars.js's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.