BRAWL API WRAPPER
Brawl API Wrapper is a powerful module to interact with the brawl stars API
INSTALATION
npm i brawl-api-wrapper
FIRST STEPS
First of all you have to get a brawl stars API key
const { Client } = require('brawl-api-wrapper')
const client = new Client('YOUR API KEY GOES HERE')
Or if you're using ES6 import:
import { Client } from 'brawl-api-wrapper'
const client = new Client('YOUR API KEY GOES HERE')
GET PLAYER
This method return a player object, we only have to provide the player's tag
const player = await client.getPlayer('PLAYER TAG GOES HERE', true) //the second param is to select if you want the battlelog to show or not. The default is false
console.log(player.name) // return the player username
//NOTE: Requesting the battlelog might get a 500 error by the Brawl Stars Api.
GET PLAYER'S BATTLELOG
This method returns a player battlelog, we have to provide the player's tag
const battlelog = await client.getBattleLog('PLAYER TAG GOES HERE')
Or you can access to a Player property called battlelog
const player = await client.getPlayer('PLAYER TAG GOES HERE')
console.log(player.battlelog) // return the player battlelog
GET CLUB
This method return a club, we have only to provide the club's tag
const club = await client.getClub('CLUB TAG GOES HERE')
console.log(club.memberCount) // return the number of members of the club
GET BRAWLER
To get a brawler you have to pass the brawlerId that this module provides to you in form of an enum
const { Brawlers } = require('brawl-api-wrapper')
const brawler = await client.getBrawler(Brawlers.Amber)
console.log(brawler.gadgets) // return the gadgets in form of an array
GET ALL BRAWLERS
This method return all the brawlers in form of an array
const brawlers = await client.getBrawlers()
console.log(brawlers) // return an array of all the brawlers
GET RANKINGS
GET RANKING OF PLAYERS TROPHIES
This method returns the 200 players with more trophies of a country.
const topPlayers = await client.getRankingOfPlayers('es') // return the top 200 players with more trophies of Spain, by default return the global top.
console.log(topPlayers)
GET RANKING OF CLUBS
This method return the 200 clubs with more trophies of a country
const topClubs = await client.getRankingOfClubs('es') // return the top 200 clubs with more trophies of Spain, by default return the global top.
console.log(topClubs)
GET RANKING OF BRAWLERS
This method return the 200 players with more trophies of a country.You have to pass the brawlerId in the method so we import the Brawlers enum
const { Brawlers } = require('brawl-api-wrapper')
const topBrawlers = await client.getRankingOfBrawlers(Brawlers.Amber, 'es') // return the top 200 players with more trophies with Amber of Spain, by default is the global top
GET EVENT ROTATION
This method return the event rotation of the game
const events = await client.getEvents()
console.log(event) // return an array of events
BUGS
If you find a bug create an issue in the official repository