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

battle

v0.0.8

Published

node-battle is a client for Blizzard's World of Warcraft Community Web API

Downloads

26

Readme

node-battle buildstatus

node-battle is a client for Blizzard's World of Warcraft Community Web API.

Install

npm install battle

Usage

First you need an API key so head to the developer portal and register an application.

var battle = require('battle');

// create a new client with a default region
var client = battle.createClient({
    apiKey: '...',
    region: 'eu'
});

// load an item
client.item({ id: 72095 }, function (err, item) {
    console.log(item);
});

// load a character from a US realm
client.character({
    region: 'us',
    realm: 'nesingwary',
    name: 'havøk',
    fields: 'stats'
}, function (err, char) {
    console.log(char);
});

// also nice errors
client.item({ id: 99999999 }, function (err, item) {
    console.log(err instanceof battle.APIError) // true
    console.log(err.statusCode) // 404
    console.log(err.message)    // "unable to get item information."
    console.log(err.body)       // json body
});

API

battle.createClient(options)

Options:

  • options.apiKey - required
  • [options.region] - optional, defaults to us. Supports: us, eu, kr, tw, ch

Returns: an instance of battle.Client

client.endpoint(params, callback)

The client supports all endpoints found on Blizzard's API docs.

Sending a request to the character endpoint:

client.character({
    region: 'us',            // optional param
    realm: 'nesingwary',     // required param
    name: 'havøk',           // required param
    fields: 'stats'          // optional param
}, function (err, data) {
    // do your thing
})

Note: Passing in params.region will override the client's default region.
Note: all request parameters that are not required to build the url (such as fields in the example above) will be sent to the API as query string parameters.

Available endpoints and their required parameters:

achievement      : '/api/wow/achievement/:id',
auction          : '/api/wow/auction/data/:realm',
battlePetAbility : '/api/wow/battlePet/ability/:id',
battlePetSpecies : '/api/wow/battlePet/species/:id',
battlePetStats   : '/api/wow/battlePet/stats/:id',
challengeRealm   : '/api/wow/challenge/:realm',
challengeRegion  : '/api/wow/challenge/region',
character        : '/api/wow/character/:realm/:name',
item             : '/api/wow/item/:id',
itemSet          : '/api/wow/item/set/:id',
guild            : '/api/wow/guild/:realm/:name',
arenaTeam        : '/api/wow/arena/:realm/:size/:name', // size=2v2, 3v3, 5v5
arenaLadder      : '/api/wow/pvp/arena/:battlegroup/:size',
ratedBg          : '/api/wow/pvp/ratedbg/ladder',
quest            : '/api/wow/quest/:id',
realm            : '/api/wow/realm/status',
recipe           : '/api/wow/recipe/:id',
spell            : '/api/wow/spell/:id',
battlegroups     : '/api/wow/data/battlegroups/',
races            : '/api/wow/data/character/races',
classes          : '/api/wow/data/character/classes',
achievements     : '/api/wow/data/character/achievements',
guildRewards     : '/api/wow/data/guild/rewards',
guildPerks       : '/api/wow/data/guild/perks',
guildAchievements: '/api/wow/data/guild/achievements',
itemClasses      : '/api/wow/data/item/classes',
talents          : '/api/wow/data/talents',
petTypes         : '/api/wow/data/pet/types'

battle.Client(options)

battle.APIError(statusCode, body)

The error class used for API errors. err.statusCode, err.message and err.body are populated from the response.