Error 500 in Sc2 API

API Bug Report
Prev 1 3 4 5 Next
Tuesday (10) at the earliest... of course .. oooh now it's thursday ... ok ok we wait since september ...

On EU nothing works, unranked or not ...
Yeah we gave up last night and started using the oauth endpoints instead. I suggest taking a look at rankedftw's source code on github for an idea on how they work.

Maybe shortland will be nice and write a guide or something...
@Elrel,

What we ended up doing, is using the Oauth system to fetch all the sc2 ladders, and then singling out our clan members.

You'd get more data using Oauth than if you'd just use one of the broken endpoints.

Oauth works.

Process:

https://us.battle.net/oauth/authorize?client_id=<API_KEY>&scope=sc2.profile&state=iamrandom&redirect_uri=https://localhost/&response_type=code

NOTE: redirect_uri, I have it set to "https://localhost/"
When you create your API key, this must be the same as the "CALLBACK URL" you registered it with.

It usually takes Blizzard a couple hours to update that, so I would just create a whole new API key with the new callback URL.

Also note: you can only use this "code" one time. And you do need to use it quick! After using it to fetch a token, the code becomes invalid.


Anyways, that link would redirect you to https://localhost/, in the URL of the page, it'll have the CODE you want to use.

https://localhost/?code=86bcg7jvhxrma2esxqtsxnup&state=iamrandom/


You then need to copy this code, and quickly use this code to exchange it for a
token


https://us.battle.net/oauth/token?client_id=API_KEY&client_secret=KEY_SECRET&redirect_uri=https://localhost/&scope=sc2.profile&grant_type=authorization_code&code=<GOT_CODE_FROM_ABOVE>

This'll respond with a "
token
".

This token lasts 1 month and can be used to access working sc2 data.

You need to cycle through all the ladders and leagues to find the player data you want. But it's working...

Anyways, once you have a working
token


https://us.api.battle.net/data/sc2/season/current?access_token=<TOKEN>

^ this gives you the current season of SC2, which at the moment is 30.

Then, this is where it gets a bit big and confusing.

https://us.api.battle.net/data/sc2/league/30/201/0/0?access_token=<TOKEN>

This link gives us all the ladder ID #s of 1v1 LotV bronze league.

.../30/201/0/0...


30 stands for current season, which we got before.

The second number, 201 is derived from 2 separate numbers.
200 + 1.

200 stands for LotV
1 stands for 1v1s

https://us.battle.net/forums/en/sc2/topic/20749724960


Queue ID

1 - Wings of Liberty 1v1
2 - Wings of Liberty 2v2
3 - Wings of Liberty 3v3
4 - Wings of Liberty 4v4
101 - Heart of the Swarm 1v1
102 - Heart of the Swarm 2v2
103 - Heart of the Swarm 3v3
104 - Heart of the Swarm 4v4
201 - Legacy of the Void 1v1
202 - Legacy of the Void 2v2
203 - Legacy of the Void 3v3
204 - Legacy of the Void 4v4
206 - Legacy of the Void Archon


.../30/201/0/0...


now, we know where to get 30 (season #), we know what 201 stands for.

The first
0
stands for either 0 "Arranged team", or 1 "Random team".

so that 0 can either be 0 or 1.
Here is a list from RFTW source code on the different variations
(https://github.com/andersroos/rankedftw/blob/e6d76d9ef597c09d55781da7ebc9ee46ef27013d/main/battle_net.py)

TEAM_TYPE = {
Mode.TEAM_1V1: 0,
Mode.RANDOM_2V2: 1,
Mode.TEAM_2V2: 0,
Mode.RANDOM_3V3: 1,
Mode.TEAM_3V3: 0,
Mode.RANDOM_4V4: 1,
Mode.TEAM_4V4: 0,
Mode.ARCHON: 0,
}


Note that 1v1 and archon only have "arranged" teams. (0).

Ok, now we know why there's that first 0 in the url, now what does that second 0 mean?

.../30/201/0/0...


It stands for the league you want to fetch ladders of.
0 - bronze
1 - silver
2 - gold
3 - platinum
4 - diamond
5 - masters
6 - grandmasters


so, for an example, if you wanted to fetch "archon GM league", the url format would be:

.../30/206/0/6...[/qoute]

which translates to:

[quote]/SEASON_ID/LOTV_ARCHON_CODE/ARRANGED_OR_RANDOM_TEAM/LEAGUE_#


now plugin what league data we want:

https://us.api.battle.net/data/sc2/league/30/204/1/3?access_token=<TOKEN>

this is [204] lotv 4v4, [1] random teams, [3] platinum league.

the page will give you a list of all the ladder ID #s of that.

You then use these ID#s in this format:

https://us.api.battle.net/data/sc2/ladder/<LADDER ID>?access_token=<TOKEN>


You can write some loop to loop through all the different ladder IDs.

Visiting that link will provide you a list of all the players in that certain ladder. It'll give you each persons individual MMR, wins/losses, and literally all the information you'd need that's not available from the broken endpoints.

You'll have to write some code to loop through all the 1v1 league ladders, and then specifically grab data from people in your clan or whatever your doing this for. (clan tag is also supplied by the data)
01/12/2017 09:40 AMPosted by JimmyCarter
@Elrel,

What we ended up doing, is using the Oauth system to fetch all the sc2 ladders, and then singling out our clan members.

You'd get more data using Oauth than if you'd just use one of the broken endpoints.


This is an amazing post. Thank you!
JimmyCarter, your explication is really good !!! I did the same thing for my website and for my players : http://colossus-orbis.com/starcraft.php

But i can't (or i don't see) find MMR, avatar and Achievements for each player. This informations are in API PROFILE only.

Thanks JimmyCarter and Remo
@Elrel,

Unfortunately can't get achievements or avatar, but you can get MMR.

It's in the JSON named under "rating"

ie:

...[{"id":13959609693000000000,"rating":4690,"wins":143,"losses":135,"ties":0,"points":1316,....

Really nice website btw!
01/13/2017 12:04 PMPosted by JimmyCarter
@Elrel,

Unfortunately can't get achievements or avatar, but you can get MMR.

It's in the JSON named under "rating"

ie:

...[{"id":13959609693000000000,"rating":4690,"wins":143,"losses":135,"ties":0,"points":1316,....

Really nice website btw!


Thanks !!

And now i understand why i couldn't find MMR. i used :
https://eu.api.battle.net/sc2/ladder/<ladder_id>?locale=fr_FR&apikey=<***>

and not :
https://eu.api.battle.net/data/sc2/ladder/<ladder_id>?access_token=<***>
Where are the devs on this? Why is it taking so long to test and rollout the update if you already fixed the bug? I worked at a game dev company and I can't understand why it is taking so long.
Yeah, to make it entirely clear, that we managed to find another way to get at some of the data we needed does not mean that the original problem has been solved! So frustrating...
I too can get results on under 1% of accounts. Likely these are people who were ranked, but left league, based on what Remo says.
It also looks like the oauth endpoints have somewhat old data. It often doesn't match the html profile.
Player clan changes aren't updated, or they are updated really infrequently.

Also impossible to get user data on unranked users with OAuth.

I think they just never implemented that feature since OAuth is search by leagues.
01/15/2017 11:50 AMPosted by Remo
It also looks like the oauth endpoints have somewhat old data. It often doesn't match the html profile.


Do you have an example? My tests show the HTML profile and OAUTH endpoints match almost exactly.
01/16/2017 05:19 PMPosted by ThePontiff
Do you have an example?


Yes, clan changes aren't updated it seems:

I don't know exactly which ladder (division) ID he's in, but "Rayvenx" left our clan a few weeks ago. But the API still shows he's in our clan.

Even his profile shows otherwise.
(Our clan tags are ConFed, ConFD, and xCFx)
http://us.battle.net/sc2/en/profile/1096650/1/Rayvenx/

^ Shows him in BornGosu, which he is currently in. API shows him still in our clan.

Another example is "HoneyBadger",
He recently joined our clan from another clan.
API still shows him in that other clan.
Profile shows him in our clan: http://us.battle.net/sc2/en/profile/1178794/1/HoneyBadger/

Besides stale clan data,
Username/name changes aren't being displayed.
Their SC2 Profile link doesn't change, which is fine

(They added in some weird 'feature' recently, where changing your name no longer invalidates the old url, infact you can type whatever you want in the 'name' part of the URL, aslong as the #/ID is correct)

Though, the API still displays them as having the old username, it doesn't change their name according to what they've changed it to.

You won't be able to see any changes unless you find this person through the API.
(I can't get the ladder # right now)

Changed his name recently:
Profile changed to adjust the name change.
http://us.battle.net/sc2/en/profile/7896247/1/SKITTLES/

API Still gives old URL link and old username in the name field. (SKITTLES)

BUT it does update the old username with current wins/losses etc.

Edit:
RayvenX can be found at ID: 201284
Hey guys.

Good news. My profile is working now.

boockie
it works!
Thanks
I'm kinda confused at what you mean ZixseN, can you explain it a bit better? I can hopefully help
It's works and on EU too ! I can't believe it !
Finally!

Join the Conversation

Return to Forum