![Steam logo](/tomimelo/bhapi.js/raw/main/images/logo.webp)
A TypeScript/JavaScript library to interact with Brawlhalla API. It also has extended functionalities not included in original API
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
Table of Contents
TypeScript/JavaScript wrapper around Brawlhalla API. Consume the API easily through different methods and access extended functionalities not included originally in the API. This is not an official Brawlhalla Application and it has no connection with Brawlhalla nor its developers.
You need to follow some steps to get this running.
You need to acquire an API key from Brawlhalla. If you do not have an API key, please read this to know how to get one.
Install the package using your package manager of choice.
npm install bhapi.js --save
You may then import BrawlhallaAPI
into your project.
// ES Modules
import BrawlhallaAPI from 'bhapi.js'
// CommonJS
const BrawlhallaAPI = require('bhapi.js')
After that, you need to instantiate the class providing the Brawlhalla API key in the config and you're ready to use it!
const bhapi = new BrawlhallaAPI({ apiKey: 'YOUR-API-KEY' })
const legends = await bhapi.getLegends()
Constructor to create a new BrawlhallaAPI
object. You need to provide a config
object
-
Constructor Arguments
- config: {BrawlhallaAPIConfig}. Config object that contains the API key
-
Example Use
const config = {
apiKey: 'YOUR-API-KEY',
}
const bhapi = new BrawlhallaAPI(config)
Find a player by Steam ID
-
Method Arguments
- steamId: {SteamId64} (string). A player’s Steam ID in format steamID64 (ex 76561198025185087).
-
Example Use
const config = {
apiKey: 'YOUR-API-KEY',
}
const bhapi = new BrawlhallaAPI(config)
const player = await bhapi.searchBySteamID('76561198025185087')
// {
// "brawlhalla_id": 2,
// "name": ""
// }
Get rankings ordered and paginated 50 at a time
-
Method Arguments
- options: {RankingsOptions}. Search options. Default values = { bracket: '1v1', region: 'all', page: 1, }
-
Example Use
const config = {
apiKey: 'YOUR-API-KEY',
}
const bhapi = new BrawlhallaAPI(config)
const options = {
bracket: '1v1',
region: 'brz',
page: 1,
name: 'John Doe',
}
const rankings = await bhapi.getRankings(options)
// [
// {
// "rank": "1",
// "name": "John Doe",
// "brawlhalla_id": 20877,
// "best_legend": 25,
// "best_legend_games": 719,
// "best_legend_wins": 642,
// "rating": 2872,
// "tier": "Diamond",
// "games": 719,
// "wins": 642,
// "region": "BRZ",
// "peak_rating": 2872
// },
// ...
// ]
Get all stats about a player
-
Method Arguments
- brawlhallaId: {number}. The Brawlhalla ID of a player.
-
Example Use
const config = {
apiKey: 'YOUR-API-KEY',
}
const bhapi = new BrawlhallaAPI(config)
const playerStats = await bhapi.getPlayerStats(2)
// {
// "brawlhalla_id": 2,
// "name": "bmg | dan",
// "xp": 191718,
// "level": 47,
// "xp_percentage": 0.6252398209337,
// "games": 8,
// "wins": 2,
// "damagebomb": "29",
// "damagemine": "0",
// "damagespikeball": "0",
// "damagesidekick": "14",
// "hitsnowball": 0,
// "kobomb": 0,
// "komine": 0,
// "kospikeball": 0,
// "kosidekick": 0,
// ...(more data)
// }
Get ranked data about a player
-
Method Arguments
- brawlhallaId: {number}. The Brawlhalla ID of a player.
-
Example Use
const config = {
apiKey: 'YOUR-API-KEY',
}
const bhapi = new BrawlhallaAPI(config)
const playerRankedData = await bhapi.getPlayerRankedData(2)
// {
// "name": "bmg | dan",
// "brawlhalla_id": 2,
// "rating": 1745,
// "peak_rating": 1792,
// "tier": "Platinum 2",
// "wins": 207,
// "games": 391,
// "region": "US-E",
// "global_rank": 5698,
// "region_rank": 1644,
// "legends": [
// {
// "legend_id": 4,
// "legend_name_key": "cassidy",
// "rating": 1736,
// "peak_rating": 1792,
// "tier": "Platinum 1",
// "wins": 161,
// "games": 300
// },
// ... (more data)
// }
Get information about a specific clan and its members
-
Method Arguments
- clanId: {number}. The clan ID of a clan.
-
Example Use
const config = {
apiKey: 'YOUR-API-KEY',
}
const bhapi = new BrawlhallaAPI(config)
const clan = await bhapi.getClan(1)
// {
// "clan_id": 1,
// "clan_name": "Blue Mammoth Games",
// "clan_create_date": 1464206400,
// "clan_xp": "86962",
// "clan": [
// {
// "brawlhalla_id": 3,
// "name": "[BMG] Chill Penguin X",
// "rank": "Leader",
// "join_date": 1464206400,
// "xp": 6664
// },
// {
// "brawlhalla_id": 2,
// "name": "bmg | dan",
// "rank": "Officer",
// "join_date": 1464221047,
// "xp": 4492
// }
// ]
// }
Get summarized data for all legends. Use getLegend(legendId)
for more details about a legend.
- Example Use
const config = {
apiKey: 'YOUR-API-KEY',
}
const bhapi = new BrawlhallaAPI(config)
const legends = await bhapi.getLegends()
// [
// {
// "legend_id": 3,
// "legend_name_key": "bodvar",
// "bio_name": "B\u00f6dvar",
// "bio_aka": "The Unconquered Viking, The Great Bear",
// "weapon_one": "Hammer",
// "weapon_two": "Sword",
// "strength": "6",
// "dexterity": "6",
// "defense": "5",
// "speed": "5"
// },
// {
// "legend_id": 4,
// "legend_name_key": "cassidy",
// "bio_name": "Cassidy",
// "bio_aka": "The Marshal of the Old West",
// "weapon_one": "Pistol",
// "weapon_two": "Hammer",
// "strength": "6",
// "dexterity": "8",
// "defense": "4",
// "speed": "4"
// }, ...
// ]
Get detailed data about a specific legend.
-
Method Arguments
- legendId: {number}. The legend ID of a legend.
-
Example Use
const config = {
apiKey: 'YOUR-API-KEY',
}
const bhapi = new BrawlhallaAPI(config)
const legend = await bhapi.getLegend(3)
// {
// "legend_id": 3,
// "legend_name_key": "bodvar",
// "bio_name": "B\u00f6dvar",
// "bio_aka": "The Unconquered Viking, The Great Bear",
// "bio_quote": "\"I speak, you noble vikings, of a warrior who surpassed you all. I tell of a great bear-man who overcame giants and armies, and of how he came to leave our world and challenge the Gods.\"",
// "bio_quote_about_attrib": "\" -The Saga of B\u00f6dvar Bearson, first stanza\"",
// "bio_quote_from": "\"Listen you nine-mothered bridge troll, I'm coming in, and the first beer I'm drinking is the one in your fist.\"",
// "bio_quote_from_attrib": "\" -B\u00f6dvar to Heimdall, guardian of the gates of Asgard\"",
// "bio_text": "Born of a viking mother and bear father, ...",
// "bot_name": "B\u00f6tvar",
// "weapon_one": "Hammer",
// "weapon_two": "Sword",
// "strength": "6",
// "dexterity": "6",
// "defense": "5",
// "speed": "5"
// }
Get all weapons from legends.
- Example Use
const config = {
apiKey: 'YOUR-API-KEY',
}
const bhapi = new BrawlhallaAPI(config)
const weapons = await bhapi.getWeapons()
// [
// { name: 'Hammer' },
// { name: 'Sword' },
// { name: 'Pistol' },
// { name: 'RocketLance' },
// { name: 'Spear' },
// { name: 'Katar' },
// { name: 'Axe' },
// { name: 'Bow' },
// { name: 'Fists' },
// { name: 'Scythe' },
// { name: 'Cannon' },
// { name: 'Orb' },
// { name: 'Greatsword' }
// ]
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE.txt
for more information.
Tomas Melone - @tomzdotjs
Project Link: https://github.com/tomimelo/bhapi.js