benweier / blizzard.js Goto Github PK
View Code? Open in Web Editor NEWA promise-based Node.JS library for the Blizzard Battle.net Community Platform API
License: MIT License
A promise-based Node.JS library for the Blizzard Battle.net Community Platform API
License: MIT License
Blizzard announced depreacting the old mashery portal and switching all api access over to their own new portal.
Are you aware of this and will there be changes necessary to this library and apps that use this?
It would be great to have a .d.ts file with the typings so that it would be easier to use this great library with Typescript (@types/blizzard.js)
I am trying to get the stats for Healmycrits-Dalaran (US)
If I use the URL in a browser (https://us.api.battle.net/wow/character/dalaran/Healmycrits?fields=statistics&locale=en_US&apikey=BLIZZARD_API_ID) it works correctly and returns the intended JSON
{
"lastModified": 1518328740000,
"name": "Healmycrits",
"realm": "Dalaran",
"battlegroup": "Rampage",
"class": 2,
"race": 10,
"gender": 0,
"level": 110,
"achievementPoints": 15685,
"thumbnail": "dalaran/49/176616497-avatar.jpg",
"calcClass": "b",
"faction": 1,
"statistics": {...},
"totalHonorableKills": 82
}
But when I try to use blizzard.js on anything that doesn't require an access_token
then I get the response
{ code: 403, type: 'Forbidden', detail: 'Account Inactive'}
The following is my attempt at the code. The commented out Mythic Stats work, but retrieving the stats for Healmycrits below returns the Code 403 JSON.
var express = require('express');
var router = express.Router();
const blizzard = require('../config/blizzard');
var access_token;
/* GET home page. */
router.get('/', function(req, res, next) {
var locale = req.query.locale;
var mounts;
blizzard.data.credentials({id: 'BLIZZARD_API_ID', secret: 'BLIZZARD_API_SECRET', origin: 'us' })
.then(response => {
access_token = response.data['access_token'];
console.log(access_token);
blizzard.data.validate({ origin: 'us', token: access_token })
.then(response => {
console.log(response.data);
// blizzard.data.mythicChallengeMode({ access_token: access_token, namespace: 'dynamic-us', origin: 'us' })
// .then(response => {
// console.log(response.data);
// })
// .catch(err => console.log(err.response.data));
blizzard.wow.character(['profile'], { name: 'Healmycrits', realm: "dalaran"})
.then(response => {
console.log(response.data);
})
.catch(err => console.log(err.response.data));
})
.catch(err => console.log(err.response.data));
})
.catch(err => console.log(err.response.data));
res.render('stats', { title: 'Express', mounts: mounts });
});
I know I'm doing something wrong but I've been looking at the code for too long and can't figure it out
Thanks in advance :)
I'm trying to use this library specifically for WoW Classic as documented.
I am trying to create a WoW Classic instance like below
import { wow } from 'blizzard.js'
const wowClassicClient = await wow.classic.createInstance({
...
})
But whenever I use wowClassicClient I only get retail specific data back.
For example await wowClassicClient.playableClass()
returns all 12 retail classes. Searching for items returns the retail versions.
Am I missing something somewhere?
Thanks
Hi !
I'm currently trying to build an application in node.js, but I have a problem in the blizzard.wow.character part.
I try to get the achievements of a member, but it doesn't seem to work, here's my code :
const blizzard = require('blizzard.js').initialize({ apikey: API_KEY }); blizzard.wow.character(['profile', 'achievements'], { realm: 'Sargeras', name: 'Isak', origin: 'eu' }) .then(response => { console.log(response.data); });
It doesn't throw any warning, just return the basic data :
{ lastModified: 1477672730000,
name: 'Isak',
realm: 'Sargeras',
battlegroup: 'Embuscade / Hinterhalt',
class: 10,
race: 10,
gender: 1,
level: 110,
achievementPoints: 19590,
thumbnail: 'sargeras/168/106068392-avatar.jpg',
calcClass: 'f',
faction: 1,
totalHonorableKills: 526 }
Here is my package.json for blizzard.js :
"blizzard.js": "^1.3.0"
Thanks for your work anyway ! :)
Hey,
Doesn't seem like there is currently a way to access the /profile/wow/character/{realmSlug}/{characterName}/pvp-bracket/{pvpBracket}
endpoint?
https://github.com/benweier/blizzard.js/wiki/Hearthstone
currently gameMode is supported in cardSearch but not in card
Branch | Build failing 🚨 |
---|---|
Dependency | mocha |
Current Version | 3.4.1 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As mocha is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.
I recommend you give this issue a high priority. I’m sure you can resolve this 💪
The new version differs by 7 commits.
a15b20a
:ship: Release v3.4.2
fc802a9
:memo: Add Changelog for v3.4.2
10ff0ec
Eagerly set process.exitCode (#2820)
fc35691
Merge pull request #2818 from makepanic/issue/2802
3e7152f
Remove call to deprecated os.tmpDir (#2802)
e249434
Merge pull request #2807 from mochajs/npm-script-lint
17a1770
Move linting into an npm script. Relates to #2805
See the full diff
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot 🌴
New WoW Game Data API as described here: https://us.battle.net/forums/en/bnet/topic/20757557566
Branch | Build failing 🚨 |
---|---|
Dependency | axios |
Current Version | 0.16.1 |
Type | dependency |
This version is covered by your current version range and after updating it in your project the build failed.
axios is a direct dependency of this project this is very likely breaking your project right now. If other packages depend on you it’s very likely also breaking them.
I recommend you give this issue a very high priority. I’m sure you can resolve this 💪
The new version differs by 12 commits.
46e275c
Releasing 0.16.2
e040815
Updating Changelog
3579da4
Merge pull request #930 from luciy/master
e4e3212
Convert the method parameter to lowercase
d1278df
Merge pull request #887 from fgnass/no-buffer-in-browser
1beb245
Fixing typo in comment blocks of createError() and enhanceError() functions (#857)
c849467
use Buffer global in http.js
c82753c
Use is-buffer instead of Buffer.isBuffer
f31317a
Merge pull request #830 from mzabriskie/feature/include-request-in-errors
1e76ea3
Adding documentation for error.request
22ce6db
Adding request to error objects when it is available
e0d59eb
Adding failing tests that verify errors contain the request
See the full diff
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot 🌴
I'm trying to use the passport_bnet package Blizzard released so that the flow would be:
Authorize -> Get token + id + BTag -> Feed token into /account/us/user endpoint.
This flow works when I go to https://us.api.battle.net/account/user?access_token=~~~~~ end point directly, but not when I use the wrapper.
Thoughts/insight? I'm just continuously getting 403/Forbidden on the hit. I'm thinking it's due to an callback issue, but wondering if you've seen these two combined.
Other-wise, how do you get the token of a user to actually receive their battle_tag/characters?
Hey,
Both /data/wow/pvp-season/{pvpSeasonId}/pvp-leaderboard/index
and /data/wow/pvp-season/{pvpSeasonId}/pvp-leaderboard/{pvpBracket}
seem to be missing
6.7.0
to 6.8.0
.This version is covered by your current version range and after updating it in your project the build failed.
eslint-config-prettier is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
The new version differs by 3 commits.
d6bf4c0
eslint-config-prettier v6.8.0
f2736c2
Update npm packages
4d16ebc
Disable @typescript-eslint/no-extra-semi (#129)
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
Hello,
I cant seem to get the total (eqquiped) item level with this blizzard.js.
Other data i can get just not the item level. Does anyone has a solution for this?
Groet,
Kopertje
Hello, I'm trying to use this lib on a Typescript Vue app, but I get this error while trying to instantiate the client.
the culprit line according to chrome:
this.ua = `Node.js/${process.versions.node} Blizzard.js/${this.version}`;
my current dependencies:
"dependencies": {
"blizzard.js": "^4.1.0",
"bootstrap": "^4.6.0",
"bootstrap-vue": "^2.21.2",
"core-js": "^3.6.5",
"css-loader": "^5.0.1",
"html-loader": "^1.3.2",
"register-service-worker": "^1.7.1",
"vue": "^2.6.11",
"vue-class-component": "^7.2.3",
"vue-property-decorator": "^9.1.2",
"vue-router": "^3.2.0",
"vue-style-loader": "^4.1.2",
"vuex": "^3.4.0"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^2.33.0",
"@typescript-eslint/parser": "^2.33.0",
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-plugin-pwa": "~4.5.0",
"@vue/cli-plugin-router": "~4.5.0",
"@vue/cli-plugin-typescript": "~4.5.0",
"@vue/cli-plugin-vuex": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@vue/eslint-config-prettier": "^6.0.0",
"@vue/eslint-config-typescript": "^5.0.2",
"eslint": "^6.7.2",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-vue": "^6.2.2",
"node-sass": "^4.12.0",
"npm-run-all": "^4.1.5",
"prettier": "^1.19.1",
"sass-loader": "^8.0.2",
"typescript": "~4.2.2",
"vue-template-compiler": "^2.6.11"
}
Using Node LTS 14.16.0 with npm 6.14.11
Can you point me in the right direction? Thank you.
Looks like blizzard added support for Auction House data in the classic game data APIs at some point.
Does this library support those endpoints yet?
axios <0.21.1
Severity: high
Server-Side Request Forgery - https://npmjs.com/advisories/1594
No fix available
I'm met with a high severity warning when installing this package.
1.0.0
to 1.0.1
.This version is covered by your current version range and after updating it in your project the build failed.
docdash is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
The new version differs by 6 commits.
abc3830
[version] 1.0.1
0b77798
Added Changelog
a11b484
Merge pull request #46 from olivbau/patch-1
f776c40
Remove line-height: 160%
9deab82
Merge pull request #44 from sergey48k/sergey48k-patch-1
0e52acb
Added hall-of-fame to README
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
This morning my app started getting 400 Bad Request errors from the API. It looks like the oath/token request is sending a GET request which is no longer allowed by the API.
https://develop.battle.net/documentation/battle-net/oauth-apis
There was some discussion about a similiar problem back in September and the change was reverted by Blizzard, but it seems to be happening again.
https://us.forums.blizzard.com/en/blizzard/t/api-error-get-method-is-not-allowed/11938
Here is the section of code from my app that is resulting in 400 Bad Request response:
const wowClient = await blizzard.wow.createInstance({
key: mainconfig.bnetclientid,
secret: mainconfig.bnetclientsecret,
origin: 'us', // optional
locale: 'en_US', // optional
token: {} // optional
}).catch( err => { console.log(err); });
blizzard.js:137
...params,
^^^
SyntaxError: Unexpected token ...
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (D:\ProjectW\node_modules\blizzard.js\index.js:21:18)
I use the latest version available with npm.
To recreate this problem I just wanted to authenticate with my Oauth client ID and secret.
using: const credentials = await blizzard.get().data.credentials({id: battleNetApiKey, secret: battleNetApiSecret, origin: 'us' })
gives me attached error. what am i doing wrong?
thanks in advance!
credential-error-output.txt
Hey,
Perhaps this has not been implemented, but I don't seem to be able to get any types when using this library?
E.g., if I do the below I do not get any hints on what is returned by this query.
let profile = await wowClient.characterPVP({
realm: "silvermoon",
name: "abc",
})
console.log(profile.data.)
New to blizzard.js, working with passport-bnet and it works just fine for authentication but needing to pull from the game apis.
Using the example on the readme I'm getting:
Error: Request failed with status code 403
My actual code:
const keys = require('./config/keys')
const blizzard = require('blizzard.js').initialize({
key: keys.bnet.bnet_id,
secret: keys.bnet.bnet_secret ,
origin: 'us',
locale: 'en_US'
});
async function example () {
try {
await blizzard.getApplicationToken()
.then(response => {
blizzard.defaults.token = response.data.access_token
});
const item = await blizzard.wow.item({ id: 168185 });
console.log(item)
} catch (err) {
console.error(err);
}
}
example();
The response url is not accurate for receiving an item it seems,
responseUrl: 'https://us.api.blizzard.com/wow/item/168185?locale=en_US',
does not work but
responseUrl: 'https://us.api.blizzard.com/data/wow/item/168185?locale=en_US',
But that appears to be the url for a different function in blizzard.js.
I do have to add ?namespace=static-us&locale=en_US&access_token=<cool_token> for the test to work.
I don't know if the initialize parameters aren't making it through or what's up but if this example should work, it does not.
Using node v12.18.2 and blizzard.js 3.2.0
Hi, I would like to know is there any way to handle errors for Unhandled promise rejection ?
Thanks
22.1.0
to 22.1.1
.This version is covered by your current version range and after updating it in your project the build failed.
eslint-plugin-jest is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
The new version differs by 1 commits.
73c9187
fix: add guard for missing assertion invocation (#58)
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
Authorization for the new Game Data endpoints (#44) is now accomplished via OAuth access tokens.
It would be nice to have the client credential flow implemented in this library to retrieve an access token.
More details here: https://dev.battle.net/docs/read/oauth#ClientCredentialsFlow
Hi Ben!
Let's be honest, according to readme.md
I should just copy/paste Step 1 & Step 2 and then receive an pretty accurate json with character data. But instead of this, anyone who will be doing the same steps receive only 401 error in console.log.
So, all those, who already checked the code or use this module for quite a long time already knows that there should be 'token' param, just like this:
const blizzard = require('blizzard.js').initialize({
key: 'key',
secret: 'secret',
});
blizzard.getApplicationToken()
.then(response => {
blizzard.defaults.token = response.data.access_token
blizzard.wow.character(['profile'], { origin: 'us', realm: 'amanthul', name: 'charni' })
.then(response => {
console.log(response.data);
});
});
But I'm not sure that I am doing it 'right'. Probably there is a better way to import my 'token' during .initialize
phase. So maybe we should update/refresh the docs?
See title.
Hello,
I'm having issued getting a response from any GET requests for wow/realm list.
I've tried with/without region, /wow/realm/status as specified in the document, and numerous variations of it. What is the end point for a list of realms?
To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:
.travis.yml
package.json
files, so that was left aloneIf you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.
Greenkeeper has checked the engines
key in any package.json
file, the .nvmrc
file, and the .travis.yml
file, if present.
engines
was only updated if it defined a single version, not a range..nvmrc
was updated to Node.js 10.travis.yml
was only changed if there was a root-level node_js
that didn’t already include Node.js 10, such as node
or lts/*
. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.For many simpler .travis.yml
configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
5.15.3
to 5.16.0
.This version is covered by your current version range and after updating it in your project the build failed.
eslint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
dfef227
Build: gensite passes rulesMeta to formatter rendering (#11567) (Kevin Partington)c06d38c
Fix: Allow HTML formatter to handle no meta data (#11566) (Ilya Volodin)87a5c03
Docs: func-style
: clarify when allowArrowFunctions
is used (#11548) (Oliver Joseph Ash)bc3e427
Update: pass rule meta to formatters RFC 10 (#11551) (Chris Meyer)b452f27
Chore: Update README to pull in reviewer data (#11506) (Nicholas C. Zakas)afe3d25
Upgrade: Bump js-yaml dependency to fix Denial of Service vulnerability (#11550) (Vernon de Goede)4fe7eb7
Chore: use nyc instead of istanbul (#11532) (Toru Nagashima)f16af43
Chore: fix formatters/table test (#11534) (Toru Nagashima)78358a8
Docs: fix duplicate punctuation in CLI docs (#11528) (Teddy Katz)The new version differs by 11 commits.
ded2f94
5.16.0
ea36e13
Build: changelog update for 5.16.0
dfef227
Build: gensite passes rulesMeta to formatter rendering (#11567)
c06d38c
Fix: Allow HTML formatter to handle no meta data (#11566)
87a5c03
Docs: func-style
: clarify when allowArrowFunctions
is used (#11548)
bc3e427
Update: pass rule meta to formatters RFC 10 (#11551)
b452f27
Chore: Update README to pull in reviewer data (#11506)
afe3d25
Upgrade: Bump js-yaml dependency to fix Denial of Service vulnerability (#11550)
4fe7eb7
Chore: use nyc instead of istanbul (#11532)
f16af43
Chore: fix formatters/table test (#11534)
78358a8
Docs: fix duplicate punctuation in CLI docs (#11528)
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
Blizzard announced new endpoints for game data a couple of days ago, guess we should update blizzard.js
, right?
And if the answer is yes
then how should we do this? I could open new PR#95 with (my) updates, but the problem is, that some new game data endpoints are named exactly the same as (old)-community ones. Especially items, so what is the best option:
WoW.prototype.item
request with new endpoint, like item:id/item:setWoW.prototype.item = function getItem({ id, set = false, bonuses, ...args }) {
const path = set ? `/wow/item/set/${id}` : `/wow/item/${id}`;
return this.blizzard.get(
path,
merge({}, args, {
params: {
...(bonuses ? { bl: bonuses.toString() } : {}),
},
}),
);
};
WoW.prototype.itemData = function getItemData(id, ...args) {
return this.blizzard.get(
`/data/wow/item/${id}`,
merge({}, args, {
namespace: 'static',
}),
);
};
This is my current code
const client = await wow.classic.createInstance({
key: config.client_id,
secret: config.client_secret,
origin: "eu",
locale: "en_US",
});
await client.getApplicationToken().then(response => {
config.token = response.data.access_token;
});
let x = await client.realmSearch({token: config.token, secret: config.client_secret, locale: "en_US"});
console.log(JSON.stringify(x.data));
The output is classic era servers which are in all locales instead of en_US, and the SOM servers are also missing, not sure if thats because of the API or the library
Hi,
First time picking up any java as well as anything to do with an api. However my aim is to create a discord bot that would feed this information back when prompted. I have managed to setup up my discord bot and configure its commands as well as use your example to pull some information from the API however I am confused as to how to get the data from the response.data and into a string where i can report it back out.
I was just wondering if you would be able to give me some advice in regards converting the response data which for your example looked like this for me after inputing a name of a player on draenor from wowprogress.
{ lastModified: 1489993871000,
name: 'Plexandie',
realm: 'Draenor',
battlegroup: 'Embuscade / Hinterhalt',
class: 3,
race: 8,
gender: 0,
level: 110,
achievementPoints: 15200,
thumbnail: 'draenor/181/95257781-avatar.jpg',
calcClass: 'Y',
faction: 1,
totalHonorableKills: 270 }
I would like to potentially convert this data into an array where i can call certain parts of it e.g. tooninfo.name = name from the list of data above.
tooninfo.realm = realm etc etc
If you could help me with this issues i would be extremely grateful.
Thanks.
Override in endpoint.js
ist wrong for: /wow/en/user/characters
According to: https://us.battle.net/forums/en/bnet/topic/20769607186
Im trying to include that in a angularjs project, but without success.
How to add this component on a angularjs project?
newly implemented feature, credentials, in version 2.0.0 does not work for origin: eu, kr, tw.
Below endpoints does not exist:
https://eu.api.battle.net/oauth/token
https://kr.api.battle.net/oauth/token
https://tw.api.battle.net/oauth/token
Am I using wrong origins?
Thanks in advance!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.