├── LICENSE
├── README.md
├── battlenet-api.js
├── lib
├── account
│ └── user.js
├── core.js
├── d3
│ ├── data.js
│ ├── era.js
│ ├── profile.js
│ └── season.js
├── sc2
│ ├── data.js
│ ├── ladder.js
│ └── profile.js
└── wow
│ ├── achievement.js
│ ├── auction.js
│ ├── battlepet.js
│ ├── boss.js
│ ├── challenge.js
│ ├── character.js
│ ├── data.js
│ ├── guild.js
│ ├── item.js
│ ├── mount.js
│ ├── pvp.js
│ ├── quest.js
│ ├── realm.js
│ ├── recipe.js
│ └── spell.js
└── package.json
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Ben Weier
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Battle.net API
2 |
3 | 
4 |
5 | ### battlenet-api is now deprecated and no longer maintained. A ground-up rewrite is available at [blizzard.js](https://github.com/benweier/blizzard.js) featuring a major version number, a cleaner API, promises support, a test suite, richer documentation, and an example app.
6 |
7 | Please migrate to blizzard.js as any issues will be redirected.
8 |
9 | ---
10 |
11 | A Node.JS library for the Battle.net Community Platform API.
12 |
13 | _battlenet-api_ is my attempt to provide a simple, easy-to-use interface that is up-to-date and well-documented for access to all available Battle.net Community Platform API methods. You are free to use it where and how you like as the library doesn't perform any content checking, rate limiting, or Terms of Service enforcement.
14 |
15 | # Install
16 |
17 | Add `battlenet-api` to your `package.json` file and install with:
18 |
19 | ```
20 | npm install
21 | ```
22 |
23 | Or add and install it in a single step:
24 | ```
25 | npm install battlenet-api --save
26 | ```
27 |
28 | # How to use
29 |
30 | Step 1: `require()` the Battle.net API within your application:
31 |
32 | ```javascript
33 | var bnet = require('battlenet-api')();
34 | ```
35 |
36 | Step 2: Call the API methods to request data:
37 |
38 | ```javascript
39 | bnet.wow.character.profile(parameters, [config,] callback);
40 | ```
41 |
42 | Step 3: ???
43 |
44 | Step 4: Profit.
45 |
46 | ## Battle.net API Key
47 |
48 | Your private Battle.net API key must be present in order to get a valid Battle.net API response. There are several ways to include it in the request:
49 |
50 | **As an optional parameter with each method**
51 | ```javascript
52 | bnet.wow.character.profile(parameters, {apikey: your_api_key}, callback);
53 | ```
54 |
55 | **As an optional parameter with require**
56 | ```javascript
57 | var bnet = require('battlenet-api')(your_api_key);
58 | ```
59 |
60 | **As a system environment variable**
61 | ```
62 | $ sudo BNET_ID=[your_api_key] node server.js
63 | ```
64 |
65 | While all three ways of using the API key can be used together, the Method usage will override the Require usage which will override the Environment Variable usage. Use the most appropriate way of setting the API key that suits your needs. Please see the documentation at the [Blizzard Developer Portal](https://dev.battle.net) to obtain your own Battle.net API key.
66 |
67 | # Documentation
68 |
69 | Each API method accepts a parameters object, an _optional_ configuration object, and a callback function to execute once the request has completed. The available request parameters for each method are explained in the [Overview](#overview).
70 |
71 | ```javascript
72 | bnet.wow.character.profile(parameters, [config,] callback);
73 | ```
74 |
75 | `parameters`: _Required_. The individual per-method parameters can be found in the overview. **ALL** API methods will accept an `origin` and `locale`.
76 | * `origin` _Required_. This indicates which regional API endpoint to use and will match the region in which the user plays. The supported origins depends on the game you are requesting data for.
77 | * `locale` _Optional_. This localizes the returned results to the specified language. The supported locales depend on which `origin` is used, and when no `locale` is supplied the Battle.net API will default to the primary language of that region.
78 |
79 | `config`: _Optional_. Compatible with the [request](https://www.npmjs.com/package/request) module. Accepts the following configuration options:
80 | * `apikey` Your Battle.net API key is set here if not supplied by the Require or Environment Variable.
81 | * `timeout` Defaults to 10000.
82 | * `gzip` Defaults to true.
83 | * `maxRedirects` Defaults to 10.
84 | * `followRedirect` Defaults to true.
85 | * `tunnel`
86 | * `proxy`
87 | * `proxyHeaderWhiteList`
88 | * `proxyHeaderExclusiveList`
89 |
90 | `callback` _Required_. The callback function accepts two arguments `error` and `response`.
91 | * `error` is only applicable when there's a connection issue to the API. Otherwise `null`.
92 | * `body` is the request response body parsed as JSON. If a request is successful this value can still return API errors such as 'Character not found' or 'Account forbidden'.
93 | * `res` is the response information such as `headers` and `statusCode`.
94 |
95 | A fully-formed request will look something like this:
96 | ```javascript
97 | bnet.wow.character.guild({
98 | origin: 'us',
99 | realm: 'amanthul',
100 | name: 'charni'
101 | }, {
102 | apikey: BNET_ID
103 | }, function(err, body, res) {
104 | console.log(body);
105 | });
106 | ```
107 |
108 | ### Encoding
109 |
110 | All API paths are passed through `encodeURI()` to product URL-safe values. e.g. Character names like "Légōlâs" result in "L%C3%A9g%C5%8Dl%C3%A2s".
111 | Note that WoW realm slugs should contain no special characters requiring encoding. e.g. "Aman'thul" is slugified to "amanthul". Use the Realm Status API to fetch the full realm list and their associated slugs.
112 |
113 |
114 | ## Overview
115 |
116 | ### [User Account](#account)
117 |
118 | * [ID](#account-user)
119 | * [BattleTag](#account-battletag)
120 | * [World of Warcraft OAuth Profile](#account-wow)
121 | * [Starcraft II OAuth Profile](#account-sc2)
122 |
123 | ### [World of Warcraft](#wow)
124 |
125 | * [Achievement](#wow-achievement)
126 | * [Auction](#wow-auction)
127 | * [Battle Pet](#wow-battle-pet)
128 | * [Ability](#wow-battle-pet-ability)
129 | * [Species](#wow-battle-pet-species)
130 | * [Stats](#wow-battle-pet-stats)
131 | * [Boss](#wow-boss)
132 | * [Master List](#wow-boss-master-list)
133 | * [Boss](#wow-boss-boss)
134 | * [Challenge](#wow-challenge)
135 | * [Realm Leaderboard](#wow-challenge-realm-leaderboard)
136 | * [Region Leaderboard](#wow-challenge-region-leaderboard)
137 | * [Character](#wow-character)
138 | * [Aggregate](#character-aggregate)
139 | * [Achievements](#wow-character-achievements)
140 | * [Appearance](#wow-character-appearance)
141 | * [Audit](#wow-character-audit)
142 | * [Feed](#wow-character-feed)
143 | * [Guild](#wow-character-guild)
144 | * [Hunter Pets](#wow-character-hunter-pets)
145 | * [Items](#wow-character-items)
146 | * [Mounts](#wow-character-mounts)
147 | * [Pets](#wow-character-pets)
148 | * [Pet Slots](#wow-character-pet-slots)
149 | * [Profile](#wow-character-profile)
150 | * [Progression](#wow-character-progression)
151 | * [PVP](#wow-character-pvp)
152 | * [Quests](#wow-character-quests)
153 | * [Reputation](#wow-character-reputation)
154 | * [Stats](#wow-character-stats)
155 | * [Statistics](#wow-character-statistics)
156 | * [Talents](#wow-character-talents)
157 | * [Titles](#wow-character-titles)
158 | * [Data Resources](#wow-data)
159 | * [Battlegroups](#wow-data-battlegroups)
160 | * [Character Achievements](#wow-data-character-achievements)
161 | * [Character Classes](#wow-data-character-classes)
162 | * [Character Races](#wow-data-character-races)
163 | * [Guild Achievements](#wow-data-guild-achievements)
164 | * [Guild Perks](#wow-data-guild-perks)
165 | * [Guild Rewards](#wow-data-guild-rewards)
166 | * [Item Classes](#wow-data-item-classes)
167 | * [Pet Types](#wow-data-pet-types)
168 | * [Talents](#wow-data-talents)
169 | * [Guild](#wow-guild)
170 | * [Aggregate](#wow-guild-aggregate)
171 | * [Achievements](#wow-guild-achievements)
172 | * [Challenge](#wow-guild-challenge)
173 | * [Members](#wow-guild-members)
174 | * [News](#wow-guild-news)
175 | * [Profile](#wow-guild-profile)
176 | * [Item](#wow-item)
177 | * [Item](#wow-item-item)
178 | * [Item Set](#wow-item-item-set)
179 | * [Mount](#wow-mount)
180 | * [PVP](#wow-pvp)
181 | * [Leaderboards](#wow-pvp-leaderboards)
182 | * [Quest](#wow-quest)
183 | * [Realm Status](#wow-realm-status)
184 | * [Recipe](#wow-recipe)
185 | * [Spell](#wow-spell)
186 |
187 | ### [Starcraft 2](#sc2)
188 |
189 | * [Data Resources](#sc2-data)
190 | * [Achievements](#sc2-data-achievements)
191 | * [Rewards](#sc2-data-rewards)
192 | * [Ladder](#sc2-ladder)
193 | * [Profile](#sc2-profile)
194 | * [Profile](#sc2-profile-profile)
195 | * [Ladders](#sc2-profile-ladders)
196 | * [Match History](#sc2-profile-match-history)
197 |
198 | ### [Diablo 3](#d3)
199 |
200 | * [Seasons](#d3-season)
201 | * [Index](#d3-season-index)
202 | * [Season](#d3-season-season)
203 | * [Leaderboard](#d3-season-leaderboard)
204 | * [Eras](#d3-era)
205 | * [Index](#d3-era-index)
206 | * [Era](#d3-era-era)
207 | * [Leaderboard](#d3-era-leaderboard)
208 | * [Data Resources](#d3-data)
209 | * [Artisan](#d3-data-artisan)
210 | * [Follower](#d3-data-follower)
211 | * [Item](#d3-data-item)
212 | * [Profile](#d3-profile)
213 | * [Career](#d3-profile-career)
214 | * [Hero](#d3-profile-hero)
215 |
216 | ---
217 |
218 |
219 | ## User Account
220 |
221 | The User Account API methods are available via the `account` object of _battlenet-api_.
222 |
223 | All User Account requests take `access_token` as a request parameter. Access tokens are generated with OAuth 2.0 and are valid for 30 days. How you implement OAuth is up to you, although I recommend checking out Blizzard's own [passport-bnet](https://www.npmjs.com/package/passport-bnet) package and reading the [Using OAuth](https://dev.battle.net/docs/read/oauth) article for more details.
224 |
225 | The supported origins for the Account API are: `us`, `eu`, `kr`, `tw`, and `cn`.
226 |
227 | ---
228 |
229 |
230 | ### User ID
231 |
232 | Returns the authenticated user's account ID and BattleTag.
233 |
234 | *Usage*
235 |
236 | ```javascript
237 | bnet.account.user({origin: 'us', access_token: users_access_token}, callback);
238 | ```
239 |
240 | ---
241 |
242 |
243 | ### World of Warcraft OAuth Profile
244 |
245 | Returns data for an authenticated user's World of Warcraft Profile.
246 |
247 | *Usage*
248 |
249 | ```javascript
250 | bnet.account.wow({origin: 'us', access_token: users_access_token}, callback);
251 | ```
252 |
253 | ---
254 |
255 |
256 | ### Starcraft II OAuth Profile
257 |
258 | Returns data for an authenticated user's Starcraft III Profile.
259 |
260 | *Usage*
261 |
262 | ```javascript
263 | bnet.account.sc2({origin: 'us', access_token: users_access_token}, callback);
264 | ```
265 |
266 | ---
267 |
268 |
269 | ## World of Warcraft
270 |
271 | The World of Warcraft API methods are available via the `wow` object of _battlenet-api_.
272 |
273 | ```javascript
274 | var wow = bnet.wow;
275 | ```
276 |
277 | The supported origins and locales for the World of Warcraft API are:
278 |
279 | Origin | Locales
280 | ------ | -------
281 | `us` | `en_US`, `es_MX`, `pt_BR`
282 | `eu` | `en_GB`, `es_ES`, `fr_FR`, `ru_RU`, `de_DE`, `pl_PL`, `pt_PT`, `it_IT`
283 | `kr` | `ko_KR`
284 | `tw` | `zh_TW`
285 | `cn` | `zh_CN`
286 |
287 | ---
288 |
289 |
290 | ### Achievement
291 |
292 | *Parameters*
293 |
294 | `id` the unique achievement ID.
295 |
296 | *Usage*
297 |
298 | ```javascript
299 | bnet.wow.achievement({origin: 'us', id: 2144}, callback);
300 | ```
301 |
302 | ---
303 |
304 |
305 | ### Auction
306 |
307 | *Parameters*
308 |
309 | `realm` the slugified realm name.
310 |
311 | *Usage*
312 |
313 | ```javascript
314 | bnet.wow.auction({origin: 'us', realm: 'amanthul'}, callback);
315 | ```
316 |
317 | ---
318 |
319 |
320 | ### Battle Pet
321 |
322 |
323 | #### Abilities
324 |
325 | *Parameters*
326 |
327 | `id` the unique ID of the battle pet ability.
328 |
329 | *Usage*
330 |
331 | ```javascript
332 | bnet.wow.battlePet.ability({origin: 'us', id: 640}, callback);
333 | ```
334 |
335 |
336 | #### Species
337 |
338 | *Parameters*
339 |
340 | `id` the unique ID of the battle pet species.
341 |
342 | *Usage*
343 |
344 | ```javascript
345 | bnet.wow.battlePet.species({origin: 'us', id: 258}, callback);
346 | ```
347 |
348 |
349 | #### Stats
350 |
351 | *Parameters*
352 |
353 | `id` the unique ID of the battle pet species.
354 |
355 | `fields` an object containing the battle pet `level`, `breedId`, and `qualityId`
356 |
357 | *Usage*
358 |
359 | ```javascript
360 | bnet.wow.battlePet.stats({origin: 'us', id: 258, fields: { level: 25, breedId: 5, qualityId: 4 }}, callback);
361 | ```
362 |
363 | ---
364 |
365 |
366 | ### Boss
367 |
368 |
369 | #### Master List
370 |
371 | Return the Boss master list.
372 |
373 | *Usage*
374 |
375 | ```javascript
376 | bnet.wow.boss.masterList({origin: 'us'}, callback);
377 | ```
378 |
379 |
380 | #### Boss
381 |
382 | Returns an individual Boss specified by id.
383 |
384 | *Parameters*
385 |
386 | `id` The boss id.
387 |
388 | *Usage*
389 |
390 | ```javascript
391 | bnet.wow.boss.boss({origin: 'us', id: 24723}, callback);
392 | ```
393 |
394 | ---
395 |
396 |
397 | ### Challenge
398 |
399 |
400 | #### Realm Leaderboard
401 |
402 | *Parameters*
403 |
404 | `realm` the slugified realm name.
405 |
406 | *Usage*
407 |
408 | ```javascript
409 | bnet.wow.challenge.realmLeaderboard({origin: 'us', realm: 'amanthul'}, callback);
410 | ```
411 |
412 |
413 | #### Region Leaderboard
414 |
415 | *Usage*
416 |
417 | ```javascript
418 | bnet.wow.challenge.regionLeaderboard({origin: 'us'}, callback);
419 | ```
420 |
421 | ---
422 |
423 |
424 | ### Character
425 |
426 | All World of Warcraft character requests require the following parameters:
427 |
428 | `realm` the slugified realm of the character.
429 |
430 | `name` the name of the character.
431 |
432 |
433 | #### Profile
434 |
435 | Returns basic profile data about the character.
436 |
437 | *Usage*
438 |
439 | ```javascript
440 | bnet.wow.character.profile({origin: 'us', realm: 'amanthul', name: 'charni'}, callback);
441 | ```
442 |
443 |
444 | #### Achievements
445 |
446 | Returns the achievement data of the character.
447 |
448 | *Usage*
449 |
450 | ```javascript
451 | bnet.wow.character.achievements({origin: 'us', realm: 'amanthul', name: 'charni'}, callback);
452 | ```
453 |
454 |
455 | #### Appearance
456 |
457 | Returns the appearance data of the character.
458 |
459 | *Usage*
460 |
461 | ```javascript
462 | bnet.wow.character.appearance({origin: 'us', realm: 'amanthul', name: 'charni'}, callback);
463 | ```
464 |
465 |
466 | #### Feed
467 |
468 | Returns the character activity feed.
469 |
470 | *Usage*
471 |
472 | ```javascript
473 | bnet.wow.character.feed({origin: 'us', realm: 'amanthul', name: 'charni'}, callback);
474 | ```
475 |
476 |
477 | #### Guild
478 |
479 | Returns the guild data of the character.
480 |
481 | *Usage*
482 |
483 | ```javascript
484 | bnet.wow.character.guild({origin: 'us', realm: 'amanthul', name: 'charni'}, callback);
485 | ```
486 |
487 |
488 | #### Hunter Pets
489 |
490 | Returns the hunter pet data of the character (where applicable).
491 |
492 | *Usage*
493 |
494 | ```javascript
495 | bnet.wow.character.hunterPets({origin: 'us', realm: 'amanthul', name: 'charni'}, callback);
496 | ```
497 |
498 |
499 | #### Items
500 |
501 | Returns the item data of the character.
502 |
503 | *Usage*
504 |
505 | ```javascript
506 | bnet.wow.character.items({origin: 'us', realm: 'amanthul', name: 'charni'}, callback);
507 | ```
508 |
509 |
510 | #### Mounts
511 |
512 | Returns the mount data of the character.
513 |
514 | *Usage*
515 |
516 | ```javascript
517 | bnet.wow.character.mounts({origin: 'us', realm: 'amanthul', name: 'charni'}, callback);
518 | ```
519 |
520 |
521 | #### Pets
522 |
523 | Returns the pet data of the character.
524 |
525 | *Usage*
526 |
527 | ```javascript
528 | bnet.wow.character.pets({origin: 'us', realm: 'amanthul', name: 'charni'}, callback);
529 | ```
530 |
531 |
532 | #### Pet Slots
533 |
534 | Returns the pet slots data of the character.
535 |
536 | *Usage*
537 |
538 | ```javascript
539 | bnet.wow.character.petSlots({origin: 'us', realm: 'amanthul', name: 'charni'}, callback);
540 | ```
541 |
542 |
543 | #### Progression
544 |
545 | Returns the progression data of the character.
546 |
547 | *Usage*
548 |
549 | ```javascript
550 | bnet.wow.character.progression({origin: 'us', realm: 'amanthul', name: 'charni'}, callback);
551 | ```
552 |
553 |
554 | #### PVP
555 |
556 | Returns the PVP data of the character.
557 |
558 | *Usage*
559 |
560 | ```javascript
561 | bnet.wow.character.pvp({origin: 'us', realm: 'amanthul', name: 'charni'}, callback);
562 | ```
563 |
564 |
565 | #### Quests
566 |
567 | Returns the quest data of the character.
568 |
569 | *Usage*
570 |
571 | ```javascript
572 | bnet.wow.character.quests({origin: 'us', realm: 'amanthul', name: 'charni'}, callback);
573 | ```
574 |
575 |
576 | #### Reputation
577 |
578 | Returns the reputation data of the character.
579 |
580 | *Usage*
581 |
582 | ```javascript
583 | bnet.wow.character.reputation({origin: 'us', realm: 'amanthul', name: 'charni'}, callback);
584 | ```
585 |
586 |
587 | #### Stats
588 |
589 | Returns the character sheet stats of the character like Strength and Agility. Note the difference between the `stats` and `statistics` methods.
590 |
591 | *Usage*
592 |
593 | ```javascript
594 | bnet.wow.character.stats({origin: 'us', realm: 'amanthul', name: 'charni'}, callback);
595 | ```
596 |
597 |
598 | #### Statistics
599 |
600 | Returns the gameplay statistics of the character like 'Used X bandages' etc. Note the difference between the `stats` and `statistics` methods.
601 |
602 | *Usage*
603 |
604 | ```javascript
605 | bnet.wow.character.statistics({origin: 'us', realm: 'amanthul', name: 'charni'}, callback);
606 | ```
607 |
608 |
609 | #### Talents
610 |
611 | Returns the talent data of the character.
612 |
613 | *Usage*
614 |
615 | ```javascript
616 | bnet.wow.character.talents({origin: 'us', realm: 'amanthul', name: 'charni'}, callback);
617 | ```
618 |
619 |
620 | #### Titles
621 |
622 | Returns the title data of the character.
623 |
624 | *Usage*
625 |
626 | ```javascript
627 | bnet.wow.character.titles({origin: 'us', realm: 'amanthul', name: 'charni'}, callback);
628 | ```
629 |
630 |
631 | #### Audit
632 |
633 | Returns an audit of the character's equipment.
634 |
635 | *Usage*
636 |
637 | ```javascript
638 | bnet.wow.character.audit({origin: 'us', realm: 'amanthul', name: 'charni'}, callback);
639 | ```
640 |
641 |
642 | #### Aggregate
643 |
644 | Returns the specified character fields aggregated in a single request.
645 |
646 | *Parameters*
647 |
648 | `fields` an array of one or more character fields.
649 |
650 | *Usage*
651 |
652 | ```javascript
653 | bnet.wow.character.aggregate({origin: 'us', realm: 'amanthul', name: 'charni', fields: ['pets', 'petSlots']}, callback);
654 | ```
655 |
656 | ---
657 |
658 |
659 | ### Data Resources
660 |
661 |
662 | #### Battlegroups
663 |
664 | *Usage*
665 |
666 | ```javascript
667 | bnet.wow.data.battlegroups({origin: 'us'}, callback);
668 | ```
669 |
670 |
671 | #### Character Achievements
672 |
673 | *Usage*
674 |
675 | ```javascript
676 | bnet.wow.data.characterAchievements({origin: 'us'}, callback);
677 | ```
678 |
679 |
680 | #### Character Classes
681 |
682 | *Usage*
683 |
684 | ```javascript
685 | bnet.wow.data.characterClasses({origin: 'us'}, callback);
686 | ```
687 |
688 |
689 | #### Character Races
690 |
691 | *Usage*
692 |
693 | ```javascript
694 | bnet.wow.data.characterRaces({origin: 'us'}, callback);
695 | ```
696 |
697 |
698 | #### Guild Achievements
699 |
700 | *Usage*
701 |
702 | ```javascript
703 | bnet.wow.data.guildAchievements({origin: 'us'}, callback);
704 | ```
705 |
706 |
707 | #### Guild Perks
708 |
709 | *Usage*
710 |
711 | ```javascript
712 | bnet.wow.data.guildPerks({origin: 'us'}, callback);
713 | ```
714 |
715 |
716 | #### Guild Rewards
717 |
718 | *Usage*
719 |
720 | ```javascript
721 | bnet.wow.data.guildRewards({origin: 'us'}, callback);
722 | ```
723 |
724 |
725 | #### Item Classes
726 |
727 | *Usage*
728 |
729 | ```javascript
730 | bnet.wow.data.itemClasses({origin: 'us'}, callback);
731 | ```
732 |
733 |
734 | #### Pet Types
735 |
736 | *Usage*
737 |
738 | ```javascript
739 | bnet.wow.data.petTypes({origin: 'us'}, callback);
740 | ```
741 |
742 |
743 | #### Talents
744 |
745 | *Usage*
746 |
747 | ```javascript
748 | bnet.wow.data.talents({origin: 'us'}, callback);
749 | ```
750 |
751 | ---
752 |
753 |
754 | ### Item
755 |
756 |
757 | #### Item
758 |
759 | Returns the item data of the specified item ID.
760 |
761 | *Parameters*
762 |
763 | `id` the unique item ID.
764 |
765 | `context` _optional_ the context used to select a specific version of an item.
766 |
767 | `bonusList` _optional_ an array of bonus list of IDs applied to the item.
768 |
769 | *Usage*
770 |
771 | ```javascript
772 | bnet.wow.item.item({origin: 'us', id: 18803}, callback);
773 | ```
774 |
775 |
776 | #### Item Set
777 |
778 | Returns the item set data of the specified set ID.
779 |
780 | *Parameters*
781 |
782 | `id` the unique item set ID.
783 |
784 | *Usage*
785 |
786 | ```javascript
787 | bnet.wow.item.set({origin: 'us', id: 1060}, callback);
788 | ```
789 |
790 | ---
791 |
792 |
793 | ### Mount
794 |
795 | Returns the Mount master list.
796 |
797 | *Usage*
798 |
799 | ```javascript
800 | bnet.wow.mount({origin: 'us'}, callback);
801 | ```
802 |
803 | ---
804 |
805 |
806 | ### Guild
807 |
808 | All World of Warcraft guild requests require the following parameters:
809 |
810 | `realm` the slugified realm of the guild.
811 |
812 | `name` the name of the guild.
813 |
814 |
815 | #### Aggregate
816 |
817 | Returns the specified guild fields aggregated in a single request.
818 |
819 | *Parameters*
820 |
821 | `fields` an array of one or more guild fields.
822 |
823 | *Usage*
824 |
825 | ```javascript
826 | bnet.wow.guild.aggregate({origin: 'us', realm: 'amanthul', name: 'blackwolf', fields: ['members', 'achievements']}, callback);
827 | ```
828 |
829 |
830 | #### Achievements
831 |
832 | Returns the achievement data of the guild.
833 |
834 | *Usage*
835 |
836 | ```javascript
837 | bnet.wow.guild.achievements({origin: 'us', realm: 'amanthul', name: 'blackwolf'}, callback);
838 | ```
839 |
840 |
841 | #### Challenge
842 |
843 | Returns the challenge data of the guild.
844 |
845 | *Usage*
846 |
847 | ```javascript
848 | bnet.wow.guild.challenge({origin: 'us', realm: 'amanthul', name: 'blackwolf'}, callback);
849 | ```
850 |
851 |
852 | #### Members
853 |
854 | Returns the members data of the guild.
855 |
856 | *Usage*
857 |
858 | ```javascript
859 | bnet.wow.guild.members({origin: 'us', realm: 'amanthul', name: 'blackwolf'}, callback);
860 | ```
861 |
862 |
863 | #### News
864 |
865 | Returns the news data of the guild.
866 |
867 | *Usage*
868 |
869 | ```javascript
870 | bnet.wow.guild.news({origin: 'us', realm: 'amanthul', name: 'blackwolf'}, callback);
871 | ```
872 |
873 |
874 | #### Profile
875 |
876 | Returns basic profile data of the guild.
877 |
878 | *Usage*
879 |
880 | ```javascript
881 | bnet.wow.guild.profile({origin: 'us', realm: 'amanthul', name: 'blackwolf'}, callback);
882 | ```
883 |
884 | ---
885 |
886 |
887 | ### PVP
888 |
889 |
890 | #### Leaderboards
891 |
892 | *Parameters*
893 |
894 | `bracket` [`2v2`, `3v3`, `5v5`, `rbg`]
895 |
896 | *Usage*
897 |
898 | ```javascript
899 | bnet.wow.pvp.leaderboards({origin: 'us', bracket: '2v2'}, callback);
900 | ```
901 |
902 | ---
903 |
904 |
905 | ### Quest
906 |
907 | *Parameters*
908 |
909 | `id` the unique quest ID.
910 |
911 | *Usage*
912 |
913 | ```javascript
914 | bnet.wow.quest({origin: 'us', id: 13146}, callback);
915 | ```
916 |
917 | ---
918 |
919 |
920 | ### Realm Status
921 |
922 | *Parameters*
923 |
924 | `realms` [optional] an array of one or more realms to limit.
925 |
926 | *Usage*
927 |
928 | All realms
929 |
930 | ```javascript
931 | bnet.wow.realmStatus({origin: 'us'}, callback);
932 | ```
933 |
934 | Selected realms
935 |
936 | ```javascript
937 | bnet.wow.realmStatus({origin: 'us', realms: ['proudmoore', 'blackrock']}, callback);
938 | ```
939 |
940 | ---
941 |
942 |
943 | ### Recipe
944 |
945 | *Parameters*
946 |
947 | `id` the unique recipe ID.
948 |
949 | *Usage*
950 |
951 | ```javascript
952 | bnet.wow.recipe({origin: 'us', id: 33994}, callback);
953 | ```
954 |
955 | ---
956 |
957 |
958 | ### Spell
959 |
960 | *Parameters*
961 |
962 | `id` the unique spell ID.
963 |
964 | *Usage*
965 |
966 | ```javascript
967 | bnet.wow.spell({origin: 'us', id: 8056}, callback);
968 | ```
969 |
970 | ---
971 |
972 |
973 | ## Starcraft 2
974 |
975 | The Starcraft 2 API methods are available via the `sc2` object of _battlenet-api_.
976 |
977 | ```javascript
978 | var sc2 = bnet.sc2;
979 | ```
980 |
981 | The supported origins and locales for the Starcraft 2 API are:
982 |
983 | Origin | Locales
984 | ------ | -------
985 | `us` | `en_US`, `es_MX`, `pt_BR`
986 | `eu` | `en_GB`, `es_ES`, `fr_FR`, `ru_RU`, `de_DE`, `pl_PL`, `pt_PT`, `it_IT`
987 | `sea` | `en_US`
988 | `kr` | `ko_KR`
989 | `tw` | `zh_TW`
990 | `cn` | `zh_CN`
991 |
992 | ---
993 |
994 |
995 | ### Profile
996 |
997 | All Starcraft 2 profile requests require the following parameters.
998 |
999 | `id` the unique player ID.
1000 |
1001 | `region` the player's region ID.
1002 |
1003 | `name` the player's profile name.
1004 |
1005 |
1006 | #### Profile
1007 |
1008 | Returns basic profile data for the specified player.
1009 |
1010 | *Usage*
1011 |
1012 | ```javascript
1013 | bnet.sc2.profile.profile({origin: 'us', id: 2137104, region: 1, name: 'skt'}, callback);
1014 | ```
1015 |
1016 |
1017 | #### Ladders
1018 |
1019 | Returns ladder data for the specified player.
1020 |
1021 | *Usage*
1022 |
1023 | ```javascript
1024 | bnet.sc2.profile.ladders({origin: 'us', id: 2137104, region: 1, name: 'skt'}, callback);
1025 | ```
1026 |
1027 |
1028 | #### Match history
1029 |
1030 | Returns match history data for the specified player.
1031 |
1032 | *Usage*
1033 |
1034 | ```javascript
1035 | bnet.sc2.profile.matchHistory({origin: 'us', id: 2137104, region: 1, name: 'skt'}, callback);
1036 | ```
1037 |
1038 | ---
1039 |
1040 |
1041 | ### Ladder
1042 |
1043 | *Parameters*
1044 |
1045 | `id` the unique ladder ID.
1046 |
1047 | *Usage*
1048 |
1049 | ```javascript
1050 | bnet.sc2.ladder({origin: 'us', id: 655}, callback);
1051 | ```
1052 |
1053 | ---
1054 |
1055 |
1056 | ### Data Resources
1057 |
1058 |
1059 | #### Achievements
1060 |
1061 | *Usage*
1062 |
1063 | ```javascript
1064 | bnet.sc2.data.achievements({origin: 'us'}, callback);
1065 | ```
1066 |
1067 |
1068 | #### Rewards
1069 |
1070 | *Usage*
1071 |
1072 | ```javascript
1073 | bnet.sc2.data.rewards({origin: 'us'}, callback);
1074 | ```
1075 |
1076 | ---
1077 |
1078 |
1079 | ## Diablo 3
1080 |
1081 | The Diablo 3 API methods are available via the `d3` object of _battlenet-api_.
1082 |
1083 | ```javascript
1084 | var d3 = bnet.d3;
1085 | ```
1086 |
1087 | The supported origins and locales for the Diablo 3 API are:
1088 |
1089 | Origin | Locales
1090 | ------ | -------
1091 | `us` | `en_US`, `es_MX`, `pt_BR`
1092 | `eu` | `en_GB`, `es_ES`, `fr_FR`, `ru_RU`, `de_DE`, `pl_PL`, `pt_PT`, `it_IT`
1093 | `kr` | `ko_KR`
1094 | `tw` | `zh_TW`
1095 | `cn` | `zh_CN`
1096 |
1097 | ---
1098 |
1099 |
1100 | ### Season
1101 |
1102 |
1103 | #### Index
1104 |
1105 | Returns base information about available seasons.
1106 |
1107 | *Usage*
1108 |
1109 | ```javascript
1110 | bnet.d3.season.index({origin: 'us'}, callback);
1111 | ```
1112 |
1113 |
1114 | #### Season
1115 |
1116 | Returns a leaderboard list for a particular season.
1117 |
1118 | *Parameters*
1119 |
1120 | `season` the season ID.
1121 |
1122 | *Usage*
1123 |
1124 | ```javascript
1125 | bnet.d3.season.season({origin: 'us', season: 1}, callback);
1126 | ```
1127 |
1128 |
1129 | #### Leaderboard
1130 |
1131 | Returns a leaderboard.
1132 |
1133 | *Parameters*
1134 |
1135 | `season` the season ID.
1136 |
1137 | `leaderboard` the leaderboard to lookup, found in the Season API call.
1138 |
1139 | *Usage*
1140 |
1141 | ```javascript
1142 | bnet.d3.season.leaderboard({origin: 'us', season: 1, leaderboard: 'achievement-points'}, callback);
1143 | ```
1144 |
1145 | ---
1146 |
1147 |
1148 | ### Season
1149 |
1150 |
1151 | #### Index
1152 |
1153 | Returns base information about available eras.
1154 |
1155 | *Usage*
1156 |
1157 | ```javascript
1158 | bnet.d3.era.index({origin: 'us'}, callback);
1159 | ```
1160 |
1161 |
1162 | #### Era
1163 |
1164 | Returns a leaderboard list for a particular era.
1165 |
1166 | *Parameters*
1167 |
1168 | `era` the era ID.
1169 |
1170 | *Usage*
1171 |
1172 | ```javascript
1173 | bnet.d3.era.era({origin: 'us', season: 1}, callback);
1174 | ```
1175 |
1176 |
1177 | #### Leaderboard
1178 |
1179 | Returns a leaderboard.
1180 |
1181 | *Parameters*
1182 |
1183 | `era` the era ID.
1184 |
1185 | `leaderboard` the leaderboard to lookup, found in the Era API call.
1186 |
1187 | *Usage*
1188 |
1189 | ```javascript
1190 | bnet.d3.era.leaderboard({origin: 'us', season: 1, leaderboard: 'rift-barbarian'}, callback);
1191 | ```
1192 |
1193 | ---
1194 |
1195 |
1196 | ### Data Resources
1197 |
1198 |
1199 | #### Artisan
1200 |
1201 | *Parameters*
1202 |
1203 | `artisan` the name of the artisan [`blacksmith`, `jeweller`, `mystic`]
1204 |
1205 | *Usage*
1206 |
1207 | ```javascript
1208 | bnet.d3.data.artisan({origin: 'us', artisan: 'blacksmith'}, callback);
1209 | ```
1210 |
1211 |
1212 | #### Follower
1213 |
1214 | *Parameters*
1215 |
1216 | `follower` the name of the follower [`templar`, `enchantress`, `scoundrel`]
1217 |
1218 | *Usage*
1219 |
1220 | ```javascript
1221 | bnet.d3.data.follower({origin: 'us', follower: 'blacksmith'}, callback);
1222 | ```
1223 |
1224 |
1225 | #### Item
1226 |
1227 | *Parameters*
1228 |
1229 | `item` the item data string.
1230 |
1231 | *Usage*
1232 |
1233 | ```javascript
1234 | bnet.d3.data.item({origin: 'us', item: 'CrABCL-oudQGEgcIBBWZWjYNHWU61OAdyg3pEx07J28kHevi5AUd8dNq1TCLAjj_AkAAUBJYBGD_AmorCgwIABDX3bKmiICA4DESGwi5u5abChIHCAQVIpaumDCPAjgAQAFYBJABAGorCgwIABCl3rKmiICA4DESGwiR9M-gAhIHCAQVIpaumDCLAjgAQAFYBJABAIABRqUBOydvJK0Bj5DKULUBAXBvArgB9aCdsg7AAQEYsuqy0wFQAFgC'} callback);
1235 | ```
1236 |
1237 | ---
1238 |
1239 |
1240 | ### Profile
1241 |
1242 |
1243 | #### Career
1244 |
1245 | *Parameters*
1246 |
1247 | `tag` the player's battle tag.
1248 |
1249 | ```javascript
1250 | bnet.d3.profile.career({origin: 'us', tag: 'skt-1884'}, callback);
1251 | ```
1252 |
1253 |
1254 | #### Hero
1255 |
1256 | *Parameters*
1257 |
1258 | `tag` the player battle tag.
1259 |
1260 | `hero` the hero ID.
1261 |
1262 | ```javascript
1263 | bnet.d3.profile.hero({origin: 'us', tag: 'skt-1884', hero: 287801}, callback);
1264 | ```
1265 |
1266 | ---
1267 |
--------------------------------------------------------------------------------
/battlenet-api.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Battle.net API Wrapper.
3 | */
4 | var request = require('request'),
5 | extend = require('extend');
6 |
7 | module.exports = function(options) {
8 | 'use strict';
9 |
10 | if (typeof options !== 'object') {
11 | options = {
12 | BNET_ID: options || false
13 | };
14 | }
15 |
16 | var battlenet = require('./lib/core')(request, extend, options);
17 |
18 | return {
19 | account: require('./lib/account/user')(battlenet),
20 | wow: {
21 | achievement: require('./lib/wow/achievement')(battlenet),
22 | auction: require('./lib/wow/auction')(battlenet),
23 | battlePet: require('./lib/wow/battlepet')(battlenet),
24 | boss: require('./lib/wow/boss')(battlenet),
25 | challenge: require('./lib/wow/challenge')(battlenet),
26 | character: require('./lib/wow/character')(battlenet),
27 | data: require('./lib/wow/data')(battlenet),
28 | guild: require('./lib/wow/guild')(battlenet),
29 | item: require('./lib/wow/item')(battlenet),
30 | mount: require('./lib/wow/mount')(battlenet),
31 | pvp: require('./lib/wow/pvp')(battlenet),
32 | quest: require('./lib/wow/quest')(battlenet),
33 | realmStatus: require('./lib/wow/realm')(battlenet),
34 | recipe: require('./lib/wow/recipe')(battlenet),
35 | spell: require('./lib/wow/spell')(battlenet)
36 | },
37 | sc2: {
38 | data: require('./lib/sc2/data')(battlenet),
39 | ladder: require('./lib/sc2/ladder')(battlenet),
40 | profile: require('./lib/sc2/profile')(battlenet)
41 | },
42 | d3: {
43 | data: require('./lib/d3/data')(battlenet),
44 | era: require('./lib/d3/era')(battlenet),
45 | profile: require('./lib/d3/profile')(battlenet),
46 | season: require('./lib/d3/season')(battlenet)
47 | }
48 | };
49 | };
50 |
--------------------------------------------------------------------------------
/lib/account/user.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Blizzard User Account API.
3 | */
4 |
5 | module.exports = function(battlenet) {
6 | 'use strict';
7 |
8 | var account = function(params, config, callback) {
9 | config.qs = {
10 | access_token: params.access_token
11 | };
12 | battlenet.fetch(params, config, callback);
13 | };
14 |
15 | return {
16 | user: function() {
17 | var args = battlenet.args.apply(null, arguments);
18 | args.params.path = '/account/user';
19 | account(args.params, args.config, args.callback);
20 | },
21 |
22 | wow: function() {
23 | var args = battlenet.args.apply(null, arguments);
24 | args.params.path = '/wow/user/characters';
25 | account(args.params, args.config, args.callback);
26 | },
27 |
28 | sc2: function() {
29 | var args = battlenet.args.apply(null, arguments);
30 | args.params.path = '/sc2/profile/user';
31 | account(args.params, args.config, args.callback);
32 | }
33 | };
34 |
35 | };
36 |
--------------------------------------------------------------------------------
/lib/core.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Battle.net API Request.
3 | */
4 |
5 | module.exports = function(request, extend, options) {
6 | 'use strict';
7 |
8 | var version = 'v0.13.0';
9 |
10 | // Default request configuration.
11 | var requiredDefaults = {
12 | method: 'GET',
13 | encoding: 'UTF-8',
14 | headers: {
15 | 'User-Agent': 'Node.js/' + process.version + ' battlenet-api/' + version
16 | },
17 | json: true,
18 | qs: {}
19 | };
20 |
21 | // Optional defaults that may be overridden.
22 | var optionalDefaults = {
23 | timeout: options.timeout || 10000,
24 | followRedirect: options.followRedirect || true,
25 | maxRedirects: options.maxRedirects || 10,
26 | gzip: options.gzip || true
27 | };
28 |
29 | var mapOriginToEndpoint = function(origin) {
30 | var endpoints = {
31 | us: {
32 | hostname: 'us.api.battle.net',
33 | defaultLocale: 'en_US'
34 | },
35 | eu: {
36 | hostname: 'eu.api.battle.net',
37 | defaultLocale: 'en_GB'
38 | },
39 | sea: {
40 | hostname: 'sea.api.battle.net',
41 | defaultLocale: 'en_US'
42 | },
43 | kr: {
44 | hostname: 'kr.api.battle.net',
45 | defaultLocale: 'ko_KR'
46 | },
47 | tw: {
48 | hostname: 'tw.api.battle.net',
49 | defaultLocale: 'zh_TW'
50 | },
51 | cn: {
52 | hostname: 'api.battlenet.com.cn',
53 | defaultLocale: 'zh_CN'
54 | }
55 | };
56 |
57 | if (origin in endpoints) {
58 | return endpoints[origin];
59 | }
60 |
61 | return endpoints.us;
62 | };
63 |
64 | return {
65 |
66 | pick: function(obj) {
67 | var result = {};
68 |
69 | if (obj === null) return result;
70 |
71 | var keys = Array.prototype.concat.apply([], Array.prototype.slice.call(arguments, 1));
72 | obj = new Object(obj);
73 | for (var i = 0, length = keys.length; i < length; i++) {
74 | var key = keys[i];
75 | if (key in obj) result[key] = obj[key];
76 | }
77 |
78 | return result;
79 | },
80 |
81 | args: function() {
82 | var args = [],
83 | params = {},
84 | config = {},
85 | callback = function() {};
86 |
87 | // Retrieve the function arguments as an array with falsey values removed.
88 | Array.prototype.push.apply(args, arguments);
89 | args = args.filter(function(val) {
90 | return val !== undefined;
91 | });
92 |
93 | // First argument becomes our request data.
94 | params = args.shift();
95 | // Last arguments becomes our callback function.
96 | callback = args.pop();
97 | // If anything is left it becomes our request config.
98 | if (args.length > 0) config = args.shift();
99 |
100 | return {
101 | params: params,
102 | config: config,
103 | callback: callback
104 | };
105 | },
106 |
107 | fetch: function(params, config, callback) {
108 | var keys = ['url', 'qs', 'timeout', 'followRedirect', 'maxRedirects', 'encoding', 'gzip', 'tunnel', 'proxy', 'proxyHeaderWhiteList', 'proxyHeaderExclusiveList'],
109 | endpoint = mapOriginToEndpoint(params.origin),
110 | path = params.path || '',
111 | locale = params.locale || endpoint.defaultLocale,
112 | apikey = config.apikey || options.BNET_ID || process.env.BNET_ID || process.env.BATTLENET_API_KEY || '';
113 |
114 | // Extend the default settings and parameters into a single request object
115 | var req = extend(true, {
116 | url: 'https://' + endpoint.hostname + encodeURI(path),
117 | qs: {
118 | locale: locale,
119 | apikey: apikey
120 | }
121 | }, requiredDefaults, optionalDefaults, this.pick(config, keys));
122 |
123 | if (typeof callback === 'function') {
124 | request(req, function(err, res, body) {
125 | callback(err, body, res);
126 | });
127 | }
128 | }
129 |
130 | };
131 |
132 | };
133 |
--------------------------------------------------------------------------------
/lib/d3/data.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Diablo III Data API.
3 | */
4 |
5 | module.exports = function(battlenet) {
6 | 'use strict';
7 |
8 | return {
9 |
10 | item: function() {
11 | var args = battlenet.args.apply(null, arguments);
12 | args.params.path = '/d3/data/item/' + args.params.item;
13 | args.params.item = args.params.item.replace(/^item\//, '');
14 | battlenet.fetch(args.params, args.config, args.callback);
15 | },
16 |
17 | follower: function() {
18 | var args = battlenet.args.apply(null, arguments);
19 | args.params.path = '/d3/data/follower/' + args.params.follower;
20 | battlenet.fetch(args.params, args.config, args.callback);
21 | },
22 |
23 | artisan: function() {
24 | var args = battlenet.args.apply(null, arguments);
25 | args.params.path = '/d3/data/artisan/' + args.params.artisan;
26 | battlenet.fetch(args.params, args.config, args.callback);
27 | }
28 |
29 | };
30 |
31 | };
32 |
--------------------------------------------------------------------------------
/lib/d3/era.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Diablo III Era API.
3 | */
4 |
5 | module.exports = function(battlenet) {
6 | 'use strict';
7 |
8 | return {
9 |
10 | index: function() {
11 | var args = battlenet.args.apply(null, arguments);
12 | args.params.path = '/data/d3/era/';
13 | battlenet.fetch(args.params, args.config, args.callback);
14 | },
15 |
16 | era: function() {
17 | var args = battlenet.args.apply(null, arguments);
18 | args.params.path = '/data/d3/era/' + args.params.id;
19 | battlenet.fetch(args.params, args.config, args.callback);
20 | },
21 |
22 | leaderboard: function() {
23 | var args = battlenet.args.apply(null, arguments);
24 | args.params.path = '/data/d3/era/' + args.params.id + '/' + args.params.leaderboard;
25 | battlenet.fetch(args.params, args.config, args.callback);
26 | }
27 |
28 | };
29 |
30 | };
31 |
--------------------------------------------------------------------------------
/lib/d3/profile.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Diablo III Profile API.
3 | */
4 |
5 | module.exports = function(battlenet) {
6 | 'use strict';
7 |
8 | return {
9 |
10 | career: function() {
11 | var args = battlenet.args.apply(null, arguments);
12 | args.params.path = '/d3/profile/' + args.params.tag + '/';
13 | battlenet.fetch(args.params, args.config, args.callback);
14 | },
15 |
16 | hero: function() {
17 | var args = battlenet.args.apply(null, arguments);
18 | args.params.path = '/d3/profile/' + args.params.tag + '/hero/' + args.params.hero;
19 | battlenet.fetch(args.params, args.config, args.callback);
20 | }
21 |
22 | };
23 |
24 | };
25 |
--------------------------------------------------------------------------------
/lib/d3/season.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Diablo III Season API.
3 | */
4 |
5 | module.exports = function(battlenet) {
6 | 'use strict';
7 |
8 | return {
9 |
10 | index: function() {
11 | var args = battlenet.args.apply(null, arguments);
12 | args.params.path = '/data/d3/season/';
13 | battlenet.fetch(args.params, args.config, args.callback);
14 | },
15 |
16 | season: function() {
17 | var args = battlenet.args.apply(null, arguments);
18 | args.params.path = '/data/d3/season/' + args.params.id;
19 | battlenet.fetch(args.params, args.config, args.callback);
20 | },
21 |
22 | leaderboard: function() {
23 | var args = battlenet.args.apply(null, arguments);
24 | args.params.path = '/data/d3/season/' + args.params.id + '/' + args.params.leaderboard;
25 | battlenet.fetch(args.params, args.config, args.callback);
26 | }
27 |
28 | };
29 |
30 | };
31 |
--------------------------------------------------------------------------------
/lib/sc2/data.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Starcraft II Data API.
3 | */
4 |
5 | module.exports = function(battlenet) {
6 | 'use strict';
7 |
8 | return {
9 |
10 | achievements: function() {
11 | var args = battlenet.args.apply(null, arguments);
12 | args.params.path = '/sc2/data/achievements';
13 | battlenet.fetch(args.params, args.config, args.callback);
14 | },
15 |
16 | rewards: function() {
17 | var args = battlenet.args.apply(null, arguments);
18 | args.params.path = '/sc2/data/rewards';
19 | battlenet.fetch(args.params, args.config, args.callback);
20 | }
21 |
22 | };
23 |
24 | };
25 |
--------------------------------------------------------------------------------
/lib/sc2/ladder.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Starcraft II Ladder API.
3 | */
4 |
5 | module.exports = function(battlenet) {
6 | 'use strict';
7 |
8 | return function() {
9 | var args = battlenet.args.apply(null, arguments);
10 | args.params.path = '/sc2/ladder/' + args.params.id;
11 | battlenet.fetch(args.params, args.config, args.callback);
12 | };
13 |
14 | };
15 |
--------------------------------------------------------------------------------
/lib/sc2/profile.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Starcraft II Profile API.
3 | */
4 |
5 | module.exports = function(battlenet) {
6 | 'use strict';
7 |
8 | return {
9 |
10 | profile: function() {
11 | var args = battlenet.args.apply(null, arguments);
12 | args.params.path = '/sc2/profile/' + args.params.id + '/' + args.params.region + '/' + args.params.name + '/';
13 | battlenet.fetch(args.params, args.config, args.callback);
14 | },
15 |
16 | ladders: function() {
17 | var args = battlenet.args.apply(null, arguments);
18 | args.params.path = '/sc2/profile/' + args.params.id + '/' + args.params.region + '/' + args.params.name + '/ladders';
19 | battlenet.fetch(args.params, args.config, args.callback);
20 | },
21 |
22 | matchHistory: function() {
23 | var args = battlenet.args.apply(null, arguments);
24 | args.params.path = '/sc2/profile/' + args.params.id + '/' + args.params.region + '/' + args.params.name + '/matches';
25 | battlenet.fetch(args.params, args.config, args.callback);
26 | }
27 |
28 | };
29 |
30 | };
31 |
--------------------------------------------------------------------------------
/lib/wow/achievement.js:
--------------------------------------------------------------------------------
1 | /**
2 | * World of Warcraft Achievement API.
3 | */
4 |
5 | module.exports = function(battlenet) {
6 | 'use strict';
7 |
8 | return function() {
9 | var args = battlenet.args.apply(null, arguments);
10 | args.params.path = '/wow/achievement/' + args.params.id;
11 | battlenet.fetch(args.params, args.config, args.callback);
12 | };
13 | };
14 |
--------------------------------------------------------------------------------
/lib/wow/auction.js:
--------------------------------------------------------------------------------
1 | /**
2 | * World of Warcraft Auction API.
3 | */
4 |
5 | module.exports = function(battlenet) {
6 | 'use strict';
7 |
8 | return function() {
9 | var args = battlenet.args.apply(null, arguments);
10 | args.params.path = '/wow/auction/data/' + args.params.realm;
11 | battlenet.fetch(args.params, args.config, args.callback);
12 | };
13 |
14 | };
15 |
--------------------------------------------------------------------------------
/lib/wow/battlepet.js:
--------------------------------------------------------------------------------
1 | /**
2 | * World of Warcraft Battle Pet API.
3 | */
4 |
5 | module.exports = function(battlenet) {
6 | 'use strict';
7 |
8 | return {
9 |
10 | ability: function() {
11 | var args = battlenet.args.apply(null, arguments);
12 | args.params.path = '/wow/battlePet/ability/' + args.params.id;
13 | battlenet.fetch(args.params, args.config, args.callback);
14 | },
15 |
16 | species: function() {
17 | var args = battlenet.args.apply(null, arguments);
18 | args.params.path = '/wow/battlePet/species/' + args.params.id;
19 | battlenet.fetch(args.params, args.config, args.callback);
20 | },
21 |
22 | stats: function() {
23 | var args = battlenet.args.apply(null, arguments),
24 | fields = ['level', 'breedId', 'qualityId'];
25 | args.params.path = '/wow/battlePet/stats/' + args.params.id;
26 | args.config.qs = battlenet.pick(args.params.fields, fields);
27 | battlenet.fetch(args.params, args.config, args.callback);
28 | }
29 |
30 | };
31 |
32 | };
33 |
--------------------------------------------------------------------------------
/lib/wow/boss.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * World of Warcraft Boss API.
5 | */
6 | module.exports = function(battlenet) {
7 |
8 | return {
9 |
10 | masterList: function() {
11 | const args = battlenet.args.apply(null, arguments);
12 |
13 | args.params.path = '/wow/boss/';
14 | battlenet.fetch(args.params, args.config, args.callback);
15 | },
16 |
17 | boss: function() {
18 | const args = battlenet.args.apply(null, arguments);
19 |
20 | args.params.path = '/wow/boss/' + args.params.id;
21 | battlenet.fetch(args.params, args.config, args.callback);
22 | }
23 |
24 | };
25 |
26 | };
27 |
--------------------------------------------------------------------------------
/lib/wow/challenge.js:
--------------------------------------------------------------------------------
1 | /**
2 | * World of Warcraft Challenge API.
3 | */
4 |
5 | module.exports = function(battlenet) {
6 | 'use strict';
7 |
8 | return {
9 |
10 | realmLeaderboard: function() {
11 | var args = battlenet.args.apply(null, arguments);
12 | args.params.path = '/wow/challenge/' + args.params.realm;
13 | battlenet.fetch(args.params, args.config, args.callback);
14 | },
15 |
16 | regionLeaderboard: function() {
17 | var args = battlenet.args.apply(null, arguments);
18 | args.params.path = '/wow/challenge/region';
19 | battlenet.fetch(args.params, args.config, args.callback);
20 | }
21 |
22 | };
23 |
24 | };
25 |
--------------------------------------------------------------------------------
/lib/wow/character.js:
--------------------------------------------------------------------------------
1 | /**
2 | * World of Warcraft Character API.
3 | */
4 |
5 | module.exports = function(battlenet) {
6 | 'use strict';
7 |
8 | var character = function(params, config, callback) {
9 | params.path = '/wow/character/' + params.realm + '/' + params.name;
10 | config.qs = {
11 | fields: params.fields.toString()
12 | };
13 | battlenet.fetch(params, config, callback);
14 | };
15 |
16 | return {
17 |
18 | profile: function() {
19 | var args = battlenet.args.apply(null, arguments);
20 | args.params.fields = [];
21 | character(args.params, args.config, args.callback);
22 | },
23 |
24 | achievements: function() {
25 | var args = battlenet.args.apply(null, arguments);
26 | args.params.fields = ['achievements'];
27 | character(args.params, args.config, args.callback);
28 | },
29 |
30 | appearance: function() {
31 | var args = battlenet.args.apply(null, arguments);
32 | args.params.fields = ['appearance'];
33 | character(args.params, args.config, args.callback);
34 | },
35 |
36 | feed: function() {
37 | var args = battlenet.args.apply(null, arguments);
38 | args.params.fields = ['feed'];
39 | character(args.params, args.config, args.callback);
40 | },
41 |
42 | guild: function() {
43 | var args = battlenet.args.apply(null, arguments);
44 | args.params.fields = ['guild'];
45 | character(args.params, args.config, args.callback);
46 | },
47 |
48 | hunterPets: function() {
49 | var args = battlenet.args.apply(null, arguments);
50 | args.params.fields = ['hunterPets'];
51 | character(args.params, args.config, args.callback);
52 | },
53 |
54 | items: function() {
55 | var args = battlenet.args.apply(null, arguments);
56 | args.params.fields = ['items'];
57 | character(args.params, args.config, args.callback);
58 | },
59 |
60 | mounts: function() {
61 | var args = battlenet.args.apply(null, arguments);
62 | args.params.fields = ['mounts'];
63 | character(args.params, args.config, args.callback);
64 | },
65 |
66 | pets: function() {
67 | var args = battlenet.args.apply(null, arguments);
68 | args.params.fields = ['pets'];
69 | character(args.params, args.config, args.callback);
70 | },
71 |
72 | petSlots: function() {
73 | var args = battlenet.args.apply(null, arguments);
74 | args.params.fields = ['petSlots'];
75 | character(args.params, args.config, args.callback);
76 | },
77 |
78 | professions: function() {
79 | var args = battlenet.args.apply(null, arguments);
80 | args.params.fields = ['professions'];
81 | character(args.params, args.config, args.callback);
82 | },
83 |
84 | progression: function() {
85 | var args = battlenet.args.apply(null, arguments);
86 | args.params.fields = ['progression'];
87 | character(args.params, args.config, args.callback);
88 | },
89 |
90 | pvp: function() {
91 | var args = battlenet.args.apply(null, arguments);
92 | args.params.fields = ['pvp'];
93 | character(args.params, args.config, args.callback);
94 | },
95 |
96 | quests: function() {
97 | var args = battlenet.args.apply(null, arguments);
98 | args.params.fields = ['quests'];
99 | character(args.params, args.config, args.callback);
100 | },
101 |
102 | reputation: function() {
103 | var args = battlenet.args.apply(null, arguments);
104 | args.params.fields = ['reputation'];
105 | character(args.params, args.config, args.callback);
106 | },
107 |
108 | stats: function() {
109 | var args = battlenet.args.apply(null, arguments);
110 | args.params.fields = ['stats'];
111 | character(args.params, args.config, args.callback);
112 | },
113 |
114 | statistics: function() {
115 | var args = battlenet.args.apply(null, arguments);
116 | args.params.fields = ['statistics'];
117 | character(args.params, args.config, args.callback);
118 | },
119 |
120 | talents: function() {
121 | var args = battlenet.args.apply(null, arguments);
122 | args.params.fields = ['talents'];
123 | character(args.params, args.config, args.callback);
124 | },
125 |
126 | titles: function() {
127 | var args = battlenet.args.apply(null, arguments);
128 | args.params.fields = ['titles'];
129 | character(args.params, args.config, args.callback);
130 | },
131 |
132 | audit: function() {
133 | var args = battlenet.args.apply(null, arguments);
134 | args.params.fields = ['audit'];
135 | character(args.params, args.config, args.callback);
136 | },
137 |
138 | aggregate: function() {
139 | var args = battlenet.args.apply(null, arguments);
140 | character(args.params, args.config, args.callback);
141 | }
142 |
143 | };
144 |
145 | };
146 |
--------------------------------------------------------------------------------
/lib/wow/data.js:
--------------------------------------------------------------------------------
1 | /**
2 | * World of Warcraft Data Resources API.
3 | */
4 |
5 | module.exports = function(battlenet) {
6 | 'use strict';
7 |
8 | return {
9 |
10 | battlegroups: function() {
11 | var args = battlenet.args.apply(null, arguments);
12 | args.params.path = '/wow/data/battlegroups/';
13 | battlenet.fetch(args.params, args.config, args.callback);
14 | },
15 |
16 | characterRaces: function() {
17 | var args = battlenet.args.apply(null, arguments);
18 | args.params.path = '/wow/data/character/races';
19 | battlenet.fetch(args.params, args.config, args.callback);
20 | },
21 |
22 | characterClasses: function() {
23 | var args = battlenet.args.apply(null, arguments);
24 | args.params.path = '/wow/data/character/classes';
25 | battlenet.fetch(args.params, args.config, args.callback);
26 | },
27 |
28 | characterAchievements: function() {
29 | var args = battlenet.args.apply(null, arguments);
30 | args.params.path = '/wow/data/character/achievements';
31 | battlenet.fetch(args.params, args.config, args.callback);
32 | },
33 |
34 | guildRewards: function() {
35 | var args = battlenet.args.apply(null, arguments);
36 | args.params.path = '/wow/data/guild/rewards';
37 | battlenet.fetch(args.params, args.config, args.callback);
38 | },
39 |
40 | guildPerks: function() {
41 | var args = battlenet.args.apply(null, arguments);
42 | args.params.path = '/wow/data/guild/perks';
43 | battlenet.fetch(args.params, args.config, args.callback);
44 | },
45 |
46 | guildAchievements: function() {
47 | var args = battlenet.args.apply(null, arguments);
48 | args.params.path = '/wow/data/guild/achievements';
49 | battlenet.fetch(args.params, args.config, args.callback);
50 | },
51 |
52 | itemClasses: function() {
53 | var args = battlenet.args.apply(null, arguments);
54 | args.params.path = '/wow/data/item/classes';
55 | battlenet.fetch(args.params, args.config, args.callback);
56 | },
57 |
58 | talents: function() {
59 | var args = battlenet.args.apply(null, arguments);
60 | args.params.path = '/wow/data/talents';
61 | battlenet.fetch(args.params, args.config, args.callback);
62 | },
63 |
64 | petTypes: function() {
65 | var args = battlenet.args.apply(null, arguments);
66 | args.params.path = '/wow/data/pet/types';
67 | battlenet.fetch(args.params, args.config, args.callback);
68 | }
69 |
70 | };
71 |
72 | };
73 |
--------------------------------------------------------------------------------
/lib/wow/guild.js:
--------------------------------------------------------------------------------
1 | /**
2 | * World of Warcraft Guild API.
3 | */
4 |
5 | module.exports = function(battlenet) {
6 | 'use strict';
7 |
8 | var guild = function(params, config, callback) {
9 | params.path = '/wow/guild/' + params.realm + '/' + params.name;
10 | config.qs = {
11 | fields: params.fields.toString()
12 | };
13 | battlenet.fetch(params, config, callback);
14 | };
15 |
16 | return {
17 |
18 | profile: function() {
19 | var args = battlenet.args.apply(null, arguments);
20 | args.params.fields = [];
21 | guild(args.params, args.config, args.callback);
22 | },
23 |
24 | members: function() {
25 | var args = battlenet.args.apply(null, arguments);
26 | args.params.fields = ['members'];
27 | guild(args.params, args.config, args.callback);
28 | },
29 |
30 | achievements: function() {
31 | var args = battlenet.args.apply(null, arguments);
32 | args.params.fields = ['achievements'];
33 | guild(args.params, args.config, args.callback);
34 | },
35 |
36 | news: function() {
37 | var args = battlenet.args.apply(null, arguments);
38 | args.params.fields = ['news'];
39 | guild(args.params, args.config, args.callback);
40 | },
41 |
42 | challenge: function() {
43 | var args = battlenet.args.apply(null, arguments);
44 | args.params.fields = ['challenge'];
45 | guild(args.params, args.config, args.callback);
46 | },
47 |
48 | aggregate: function() {
49 | var args = battlenet.args.apply(null, arguments);
50 | guild(args.params, args.config, args.callback);
51 | }
52 |
53 | };
54 |
55 | };
56 |
--------------------------------------------------------------------------------
/lib/wow/item.js:
--------------------------------------------------------------------------------
1 | /**
2 | * World of Warcraft Item API.
3 | */
4 |
5 | module.exports = function(battlenet) {
6 | 'use strict';
7 |
8 | return {
9 |
10 | item: function() {
11 | var args = battlenet.args.apply(null, arguments);
12 | var path = '/wow/item/' + args.params.id;
13 |
14 | if (args.params.context) {
15 | path += '/' + args.params.context;
16 | }
17 |
18 | if (args.params.bonusList) {
19 | args.config.qs = {
20 | bl: args.params.bonusList.toString()
21 | };
22 | }
23 |
24 | args.params.path = path;
25 |
26 | battlenet.fetch(args.params, args.config, args.callback);
27 | },
28 |
29 | set: function() {
30 | var args = battlenet.args.apply(null, arguments);
31 | args.params.path = '/wow/item/set/' + args.params.id;
32 | battlenet.fetch(args.params, args.config, args.callback);
33 | }
34 | };
35 |
36 | };
37 |
--------------------------------------------------------------------------------
/lib/wow/mount.js:
--------------------------------------------------------------------------------
1 | /**
2 | * World of Warcraft Mount API.
3 | */
4 |
5 | module.exports = function(battlenet) {
6 | 'use strict';
7 |
8 | return function() {
9 | var args = battlenet.args.apply(null, arguments);
10 | args.params.path = '/wow/mount/';
11 |
12 | battlenet.fetch(args.params, args.config, args.callback);
13 | };
14 |
15 | };
16 |
--------------------------------------------------------------------------------
/lib/wow/pvp.js:
--------------------------------------------------------------------------------
1 | /**
2 | * World of Warcraft PVP API.
3 | */
4 |
5 | module.exports = function(battlenet) {
6 | 'use strict';
7 |
8 | return {
9 |
10 | leaderboards: function() {
11 | var args = battlenet.args.apply(null, arguments);
12 | args.params.path = '/wow/leaderboard/' + args.params.bracket;
13 | battlenet.fetch(args.params, args.config, args.callback);
14 | }
15 |
16 | };
17 |
18 | };
19 |
--------------------------------------------------------------------------------
/lib/wow/quest.js:
--------------------------------------------------------------------------------
1 | /**
2 | * World of Warcraft Quest API.
3 | */
4 |
5 | module.exports = function(battlenet) {
6 | 'use strict';
7 |
8 | return function() {
9 | var args = battlenet.args.apply(null, arguments);
10 | args.params.path = '/wow/quest/' + args.params.id;
11 | battlenet.fetch(args.params, args.config, args.callback);
12 | };
13 |
14 | };
15 |
--------------------------------------------------------------------------------
/lib/wow/realm.js:
--------------------------------------------------------------------------------
1 | /**
2 | * World of Warcraft Realm Status API.
3 | */
4 |
5 | module.exports = function(battlenet) {
6 | 'use strict';
7 |
8 | return function() {
9 | var args = battlenet.args.apply(null, arguments);
10 | args.params.path = '/wow/realm/status';
11 |
12 | if (args.params.realms) {
13 | args.config.qs = {
14 | realms: args.params.realms.toString()
15 | };
16 | }
17 |
18 | battlenet.fetch(args.params, args.config, args.callback);
19 | };
20 |
21 | };
22 |
--------------------------------------------------------------------------------
/lib/wow/recipe.js:
--------------------------------------------------------------------------------
1 | /**
2 | * World of Warcraft Recipe API.
3 | */
4 |
5 | module.exports = function(battlenet) {
6 | 'use strict';
7 |
8 | return function() {
9 | var args = battlenet.args.apply(null, arguments);
10 | args.params.path = '/wow/recipe/' + args.params.id;
11 | battlenet.fetch(args.params, args.config, args.callback);
12 | };
13 |
14 | };
15 |
--------------------------------------------------------------------------------
/lib/wow/spell.js:
--------------------------------------------------------------------------------
1 | /**
2 | * World of Warcraft Spell API.
3 | */
4 |
5 | module.exports = function(battlenet) {
6 | 'use strict';
7 |
8 | return function() {
9 | var args = battlenet.args.apply(null, arguments);
10 | args.params.path = '/wow/spell/' + args.params.id;
11 | battlenet.fetch(args.params, args.config, args.callback);
12 | };
13 |
14 | };
15 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "author": "Ben Weier (https://github.com/benweier)",
3 | "name": "battlenet-api",
4 | "description": "A Node.JS library for the Battle.net Community Platform API",
5 | "version": "0.13.0-deprecated",
6 | "homepage": "https://github.com/benweier/battlenet-api",
7 | "license": "MIT",
8 | "keywords": [
9 | "battlenet",
10 | "battle.net",
11 | "bnet",
12 | "api",
13 | "world of warcraft",
14 | "warcraft",
15 | "wow",
16 | "starcraft",
17 | "sc2",
18 | "diablo",
19 | "d3"
20 | ],
21 | "repository": {
22 | "type": "git",
23 | "url": "git://github.com/benweier/battlenet-api.git"
24 | },
25 | "bugs": {
26 | "url": "https://github.com/benweier/battlenet-api/issues"
27 | },
28 | "main": "battlenet-api.js",
29 | "dependencies": {
30 | "request": "^2.40.0",
31 | "extend": "^2.0.0"
32 | }
33 | }
34 |
--------------------------------------------------------------------------------