npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bhapi.js

v1.1.0

Published

A JavaScript library to interact with Brawlhalla API

Downloads

6

Readme

Contributors Forks Stargazers Issues MIT License

About The Project

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.

Built With

  • Node
  • TypeScript

Getting Started

You need to follow some steps to get this running.

Prerequisites

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.

Installation

Install the package using your package manager of choice.

npm install bhapi.js --save

Usage

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()

Methods

new BrawlhallaAPI(config) ===> BrawlhallaAPI object

Constructor to create a new BrawlhallaAPI object. You need to provide a config object

  1. Constructor Arguments

    • config: {BrawlhallaAPIConfig}. Config object that contains the API key
  2. Example Use

const config = {
  apiKey: 'YOUR-API-KEY',
}

const bhapi = new BrawlhallaAPI(config)

searchBySteamID(steamId) ===> Promise<Player>

Find a player by Steam ID

  1. Method Arguments

    • steamId: {SteamId64} (string). A player’s Steam ID in format steamID64 (ex 76561198025185087).
  2. Example Use

const config = {
  apiKey: 'YOUR-API-KEY',
}

const bhapi = new BrawlhallaAPI(config)

const player = await bhapi.searchBySteamID('76561198025185087')

// {
//     "brawlhalla_id": 2,
//     "name": ""
// }

getRankings(options) ===> Promise<ReadonlyArray<Ranking>>

Get rankings ordered and paginated 50 at a time

  1. Method Arguments

    • options: {RankingsOptions}. Search options. Default values = { bracket: '1v1', region: 'all', page: 1, }
  2. 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
//     },
//     ...
// ]

getPlayerStats(brawlhallaId) ===> Promise<PlayerStats>

Get all stats about a player

  1. Method Arguments

    • brawlhallaId: {number}. The Brawlhalla ID of a player.
  2. 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)
// }

getPlayerRankedData(brawlhallaId) ===> Promise<PlayerRankedData>

Get ranked data about a player

  1. Method Arguments

    • brawlhallaId: {number}. The Brawlhalla ID of a player.
  2. 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)
// }

getClan(clanId) ===> Promise<Clan>

Get information about a specific clan and its members

  1. Method Arguments

    • clanId: {number}. The clan ID of a clan.
  2. 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
//         }
//     ]
// }

getLegends() ===> Promise<ReadonlyArray<LegendData>>

Get summarized data for all legends. Use getLegend(legendId) for more details about a legend.

  1. 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"
//     },  ...
// ]

getLegend(legendId) ===> Promise<Legend>

Get detailed data about a specific legend.

  1. Method Arguments

    • legendId: {number}. The legend ID of a legend.
  2. 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"
// }

getWeapons() ===> Promise<ReadonlyArray<Weapon>>

Get all weapons from legends.

  1. 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' }
// ]

Contributing

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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE.txt for more information.

Contact

Tomas Melone - @tomzdotjs

Project Link: https://github.com/tomimelo/bhapi.js