A promise-based Node.js library for the Blizzard Community Platform API.
Return an initialized Blizzard.js instance with default options.
Your Battle.net API key is required for all API calls so it must be passed to Blizzard.js with .initialize()
or with each request.
A user access token is only required for account level requests. A default access token can be passed to .initialize()
(for a browser environment working with a single user account), or to each request (for a server environment working with multiple user accounts).
Other parameters include origin
and locale
. When passed to initialize()
they are no longer required with each request unless you want to override the default (e.g. when setting US as the default region but you want to request from the EU region instead).
Blizzard.js uses axios internally and requests return fetch promises from axios. The instance
argument is an axios-compatible default configuration object.
Parameters
args
Objectargs.apikey
String - Your private Blizzard API keyargs.access_token
[String] - A default user access tokenargs.origin
[String] - The default API regionargs.locale
[String] - The default API locale
instance
[Object] - An axios instance configuration object
Example
const blizzard = require('blizzard.js').initialize({ apikey: BATTLENET_API_KEY });
Fetch an authenticated user's account id
and battletag
.
Parameters
args
Objectargs.access_token
String - The user access tokenargs.origin
[String] - The region keyargs.locale
[String] - A locale code for this region
instance
[Object] - An axios instance configuration object
Example
blizzard.account.user({ access_token: USER_ACCESS_TOKEN, origin: 'us' })
.then(response => {
console.log(response.data);
});
Fetch an authenticated user's World of Warcraft character list.
Parameters
args
Objectargs.access_token
String - The user access tokenargs.origin
[String] - The region keyargs.locale
[String] - A locale code for this region
instance
[Object] - An axios instance configuration object
Example
blizzard.account.wow({ access_token: USER_ACCESS_TOKEN, origin: 'us' })
.then(response => {
console.log(response.data);
});
Fetch an authenticated user's Starcraft 2 profile.
Parameters
args
Objectargs.access_token
String - The user access tokenargs.origin
[String] - The region keyargs.locale
[String] - A locale code for this region
instance
[Object] - An axios instance configuration object
Example
blizzard.account.sc2({ access_token: USER_ACCESS_TOKEN, origin: 'us' })
.then(response => {
console.log(response.data);
});
The Blizzard World of Warcraft Game Data APIs provide access to the following resources:
- Connected Realm API
- Realm API
- Region API
- Mythic Keystone Leaderboard API
- WoW Token API
These APIs require a valid application access token which is obtained through the .credentials()
method, while an issued access token can be checked through the .validate()
method.
Fetch an application access token.
Parameters
args
Objectargs.id
String - Your application client IDargs.secret
String - Your application client secretargs.origin
String - The region key
Example
blizzard.data.credentials({id: process.env.BLIZZARD_API_ID, secret: process.env.BLIZZARD_API_SECRET, origin: 'us' })
.then(response => {
console.log(response.data);
});
Check the details of an application access token.
Parameters
args
Objectargs.origin
String - The region keyargs.token
String - The access token to be checked
Example
blizzard.data.validate({ origin: 'us', token: APPLICATION_ACCESS_TOKEN })
.then(response => {
console.log(response.data);
});
Fetch the index of connected realms or a single connected realm by ID.
Parameters
args
Objectargs.access_token
String - The application access tokenargs.namespace
String - The game data namespaceargs.realm
[Number] - The connected realm ID for a single realmargs.origin
[String] - The region keyargs.locale
[String] - A locale code for this region
instance
[Object] - An axios instance configuration object
Example
blizzard.data.connectedRealm({ access_token: APPLICATION_ACCESS_TOKEN, namespace: 'dynamic-us', origin: 'us' })
.then(response => {
console.log(response.data);
});
blizzard.data.connectedRealm({ access_token: APPLICATION_ACCESS_TOKEN, namespace: 'dynamic-us', realm: 11, origin: 'us' })
.then(response => {
console.log(response.data);
});
Get an index of Mythic Keystone Leaderboards for a connected realm or weekly Mythic Keystone Leaderboard by period.
Parameters
args
Objectargs.access_token
String - The application access tokenargs.namespace
String - The game data namespaceargs.realm
[Number] - The realm IDargs.dungeon
[Number] - The dungeon IDargs.period
[Number] - The mythic leaderboard periodargs.origin
[String] - The region keyargs.locale
[String] - A locale code for this region
instance
[Object] - An axios instance configuration object
Example
blizzard.data.mythicLeaderboard({ access_token: APPLICATION_ACCESS_TOKEN, namespace: 'dynamic-us', origin: 'us' })
.then(response => {
console.log(response.data);
});
blizzard.data.mythicLeaderboard({ access_token: APPLICATION_ACCESS_TOKEN, namespace: 'dynamic-us', relam: 11, dungeon: 197, period: 602 origin: 'us' })
.then(response => {
console.log(response.data);
});
Get current period information about the Mythic Challenge Mode relevant to Mythic Keystone Leaderboards.
Parameters
args
Objectargs.access_token
String - The application access tokenargs.namespace
String - The game data namespaceargs.origin
[String] - The region keyargs.locale
[String] - A locale code for this region
instance
[Object] - An axios instance configuration object
Example
blizzard.data.mythicChallengeMode({ access_token: APPLICATION_ACCESS_TOKEN, namespace: 'dynamic-us', origin: 'us' })
.then(response => {
console.log(response.data);
});
Get an index of realms or a single realm by slug or ID.
Parameters
args
Objectargs.access_token
String - The application access tokenargs.namespace
String - The game data namespaceargs.realm
[String|Number] - The connected realm slug or IDargs.origin
[String] - The region keyargs.locale
[String] - A locale code for this region
instance
[Object] - An axios instance configuration object
Example
blizzard.data.realm({ access_token: APPLICATION_ACCESS_TOKEN, namespace: 'dynamic-us', origin: 'us' })
.then(response => {
console.log(response.data);
});
blizzard.data.realm({ access_token: APPLICATION_ACCESS_TOKEN, namespace: 'dynamic-us', realm: 11, origin: 'us' })
.then(response => {
console.log(response.data);
});
Get an index of regions or a single region by ID.
Parameters
args
Objectargs.access_token
String - The application access tokenargs.namespace
String - The game data namespaceargs.region
[Number] - The region IDargs.origin
[String] - The region keyargs.locale
[String] - A locale code for this region
instance
[Object] - An axios instance configuration object
Example
blizzard.data.region({ access_token: APPLICATION_ACCESS_TOKEN, namespace: 'dynamic-us', origin: 'us' })
.then(response => {
console.log(response.data);
});
blizzard.data.region({ access_token: APPLICATION_ACCESS_TOKEN, namespace: 'dynamic-us', region: 1, origin: 'us' })
.then(response => {
console.log(response.data);
});
Get the World of Warcraft token index.
Parameters
args
Objectargs.access_token
String - The application access tokenargs.namespace
String - The game data namespaceargs.origin
[String] - The region keyargs.locale
[String] - A locale code for this region
instance
[Object] - An axios instance configuration object
Example
blizzard.data.token({ access_token: APPLICATION_ACCESS_TOKEN, namespace: 'dynamic-us', origin: 'us' })
.then(response => {
console.log(response.data);
});
Fetch a Diablo 3 data resource.
Parameters
key
String - The data resource key:follower
,artisan
,item
args
Objectargs.id
String - The data resource IDargs.origin
[String] - The region keyargs.locale
[String] - A locale code for this region
instance
[Object] - An axios instance configuration object
Example
blizzard.d3.data('follower', { id: 'templar', origin: 'us' })
.then(response => {
console.log(response.data);
});
blizzard.d3.data('artisan', { id: 'mystic', origin: 'us' })
.then(response => {
console.log(response.data);
});
Fetch a Diablo 3 era.
Parameters
args
Objectargs.id
[Number] - The era IDargs.access_token
[String] - A user access tokenargs.leaderboard
[String] - The era leaderboard keyargs.origin
[String] - The region keyargs.locale
[String] - A locale code for this region
instance
[Object] - An axios instance configuration object
Example
blizzard.d3.era({ origin: 'us' })
.then(response => {
console.log(response.data);
});
blizzard.d3.era({ id: 5, origin: 'us' })
.then(response => {
console.log(response.data);
});
blizzard.d3.era({ id: 5, leaderboard: 'rift-barbarian', origin: 'us' })
.then(response => {
console.log(response.data);
});
Fetch a Diablo 3 profile.
Parameters
args
Objectargs.tag
String - The user battletagargs.hero
[Number] - The hero IDargs.itemTypes
[String] - The hero items to fetch:items
,follower-items
args.origin
[String] - The region keyargs.locale
[String] - A locale code for this region
instance
[Object] - An axios instance configuration object
Example
blizzard.d3.profile({ tag: 'skt#1884', origin: 'us' })
.then(response => {
console.log(response.data);
});
blizzard.d3.profile({ tag: 'skt#1884', hero: 287801, origin: 'us' })
.then(response => {
console.log(response.data);
});
Fetch a Diablo 3 season.
Parameters
args
Objectargs.id
[String] - The season IDargs.leaderboard
[String] - The season leaderboard keyargs.access_token
[String] - A user access tokenargs.origin
[String] - The region keyargs.locale
[String] - A locale code for this region
instance
[Object] - An axios instance configuration object
Example
blizzard.d3.season({ origin: 'us' })
.then(response => {
console.log(response.data);
});
blizzard.d3.season({ id: 5, origin: 'us' })
.then(response => {
console.log(response.data);
});
blizzard.d3.season({ id: 5, leaderboard: 'rift-barbarian', origin: 'us' })
.then(response => {
console.log(response.data);
});
Fetch a Starcraft 2 data resource.
Parameters
key
String - The data resource key:achievements
,rewards
args
Objectargs.origin
[String] - The region keyargs.locale
[String] - A locale code for this region
instance
[Object] - An axios instance configuration object
Example
blizzard.sc2.data('achievements', { origin: 'us' })
.then(response => {
console.log(response.data);
});
blizzard.sc2.data('rewards', { origin: 'us' })
.then(response => {
console.log(response.data);
});
Fetch a Starcraft 2 ladder.
Parameters
args
Objectargs.id
Number - The ladder IDargs.origin
[String] - The region keyargs.locale
[String] - A locale code for this region
instance
[Object] - An axios instance configuration object
Example
blizzard.sc2.ladder({ id: 194163, origin: 'us' })
.then(response => {
console.log(response.data);
});
Fetch a Starcraft 2 player profile.
Parameters
key
String - The profile resource key:profile
,ladders
,matches
args
Objectargs.id
Number - The profile IDargs.name
String - The profile nameargs.region
[String] - The profile region (optional, default1
)args.origin
[String] - The region keyargs.locale
[String] - A locale code for this region
instance
[Object] - An axios instance configuration object
Example
blizzard.sc2.profile('profile', { id: 2137104, name: 'skt', origin: 'us' })
.then(response => {
console.log(response.data);
});
blizzard.sc2.profile('ladders', { id: 2137104, name: 'skt', origin: 'us' })
.then(response => {
console.log(response.data);
});
blizzard.sc2.profile('matches', { id: 2137104, name: 'skt', origin: 'us' })
.then(response => {
console.log(response.data);
});
Fetch an achievement.
Parameters
args
Objectargs.id
Number - The achievement IDargs.origin
[String] - The region keyargs.locale
[String] - A locale code for this region
instance
[Object] - An axios instance configuration object
Example
blizzard.wow.achievement({ id: 2144, origin: 'us' })
.then(response => {
console.log(response.data);
});
Fetch auction data.
Parameters
args
Objectargs.realm
String - The slugified realm nameargs.origin
[String] - The region keyargs.locale
[String] - A locale code for this region
instance
[Object] - An axios instance configuration object
Example
blizzard.wow.auction({ realm: 'proudmoore', origin: 'us' })
.then(response => {
console.log(response.data);
});
Fetch boss data.
Parameters
args
Objectargs.id
[Number] - The boss IDargs.origin
[String] - The region keyargs.locale
[String] - A locale code for this region
instance
[Object] - An axios instance configuration object
Example
blizzard.wow.boss({ origin: 'us' })
.then(response => {
console.log(response.data);
});
blizzard.wow.boss({ id: 24664, origin: 'us' })
.then(response => {
console.log(response.data);
});
Fetch challenge data.
Parameters
args
Objectargs.realm
[String] - The slugified realm nameargs.origin
[String] - The region keyargs.locale
[String] - A locale code for this region
instance
[Object] - An axios instance configuration object
Example
blizzard.wow.challenge({ origin: 'us' })
.then(response => {
console.log(response.data);
});
blizzard.wow.challenge({ realm: 'medivh', origin: 'us' })
.then(response => {
console.log(response.data);
});
Fetch character data.
Parameters
keys
String|Array - One or more character resource keys:profile
,achievements
,appearance
,feed
,guild
,hunterPets
,items
,mounts
,professions
,progression
,pvp
,quests
,reputation
,statistics
,stats
,talents
,titles
,audit
args
Objectargs.name
String - The character nameargs.realm
String - The slugified realm nameargs.origin
[String] - The region keyargs.locale
[String] - A locale code for this region
instance
[Object] - An axios instance configuration object
Example
blizzard.wow.character(['profile', 'achievements'], { realm: 'proudmoore', name: 'kailee', origin: 'us' })
.then(response => {
console.log(response.data);
});
blizzard.wow.character(['pets', 'petSlots'], { realm: 'amanthul', name: 'charni', origin: 'us' })
.then(response => {
console.log(response.data);
});
Fetch a WoW data resource.
Parameters
key
String - The data resource key:battlegroups
,character-achievements
,character-classes
,character-races
,guild-achievements
,guild-perks
,guild-rewards
,item-classes,
pet-types,
talents`args
Objectargs.origin
[String] - The region keyargs.locale
[String] - A locale code for this region
instance
[Object] - An axios instance configuration object
Example
blizzard.wow.data('character-races', { origin: 'us' })
.then(response => {
console.log(response.data);
});
blizzard.wow.data('character-classes', { origin: 'us' })
.then(response => {
console.log(response.data);
});
Fetch guild data.
Parameters
keys
String|Array - One or more guild resource keys:profile
,achievements
,challenge
,members
,news
args
Objectargs.name
String - The guild nameargs.realm
String - The slugified realm nameargs.origin
[String] - The region keyargs.locale
[String] - A locale code for this region
instance
[Object] - An axios instance configuration object
Example
blizzard.wow.guild(['profile', 'members'], { realm: 'amanthul', name: 'blackwolf', origin: 'us' })
.then(response => {
console.log(response.data);
});
Fetch item data.
Parameters
args
Objectargs.id
Number - The item or set IDargs.set
[Boolean] - Whether this is an item set request or notargs.bonuses
[Array] - A list of bonuses to apply to the itemargs.origin
[String] - The region keyargs.locale
[String] - A locale code for this region
instance
[Object] - An axios instance configuration object
Example
blizzard.wow.item({ id: 18803, origin: 'us' })
.then(response => {
console.log(response.data);
});
Fetch mount data.
Parameters
args
Objectargs.origin
[String] - The region keyargs.locale
[String] - A locale code for this region
instance
[Object] - An axios instance configuration object
Example
blizzard.wow.mount({ origin: 'us' })
.then(response => {
console.log(response.data);
});
Fetch pet data.
Parameters
key
String - The pet resource key:list
,ability
,species
,stats
args
Objectargs.id
[String] - The pet resource IDargs.origin
[String] - The region keyargs.locale
[String] - A locale code for this region
instance
[Object] - An axios instance configuration object
Example
blizzard.wow.pet('list', { origin: 'us' })
.then(response => {
console.log(response.data);
});
blizzard.wow.pet('ability', { id: 640, origin: 'us' })
.then(response => {
console.log(response.data);
});
blizzard.wow.pet('species', { id: 258, origin: 'us' })
.then(response => {
console.log(response.data);
});
Fetch pvp data.
Parameters
args
Objectargs.bracket
String - The pvp bracket keyargs.origin
[String] - The region keyargs.locale
[String] - A locale code for this region
instance
[Object] - An axios instance configuration object
Example
blizzard.wow.pvp({ bracket: '3v3', origin: 'us' })
.then(response => {
console.log(response.data);
});
Fetch quest data.
Parameters
args
Objectargs.id
Number - The quest IDargs.origin
[String] - The region keyargs.locale
[String] - A locale code for this region
instance
[Object] - An axios instance configuration object
Example
blizzard.wow.quest({ id: 13146, origin: 'us' })
.then(response => {
console.log(response.data);
});
Fetch realm data.
Parameters
args
Objectargs.realms
[String|Array] - One or more slugified realm namesargs.origin
[String] - The region keyargs.locale
[String] - A locale code for this region
instance
[Object] - An axios instance configuration object
Example
blizzard.wow.realms({ origin: 'us' })
.then(response => {
console.log(response.data);
});
blizzard.wow.realms({ realms: ['blackrock', 'proudmoore'], origin: 'us' })
.then(response => {
console.log(response.data);
});
Fetch recipe data.
Parameters
args
Objectargs.id
Number - The recipe IDargs.origin
[String] - The region keyargs.locale
[String] - A locale code for this region
instance
[Object] - An axios instance configuration object
Example
blizzard.wow.recipe({ id: 33994, origin: 'us' })
.then(response => {
console.log(response.data);
});
Fetch spell data.
Parameters
args
Objectargs.id
Number - The spell IDargs.origin
[String] - The region keyargs.locale
[String] - A locale code for this region
instance
[Object] - An axios instance configuration object
Example
blizzard.wow.spell({ id: 8056, origin: 'us' })
.then(response => {
console.log(response.data);
});
Fetch zone data.
Parameters
args
Objectargs.id
Number - The zone IDargs.origin
[String] - The region keyargs.locale
[String] - A locale code for this region
instance
[Object] - An axios instance configuration object
Example
blizzard.wow.zone({ origin: 'us' })
.then(response => {
console.log(response.data);
});
blizzard.wow.zone({ id: 4131, origin: 'us' })
.then(response => {
console.log(response.data);
});