Skip to content

Instantly share code, notes, and snippets.

@HADB
Last active November 15, 2021 08:58
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HADB/d1a11ff4df691cb466f2637190dd3eeb to your computer and use it in GitHub Desktop.
Save HADB/d1a11ff4df691cb466f2637190dd3eeb to your computer and use it in GitHub Desktop.
Two ways to fetch starcraft 2 ladders data of KR region

Hi, there! Here's how I fetch the data of KR region in sczone-crawler.

We know that the League api and Legacy Ladder api are not working as expected in KR region. But other apis still work. So we just have to find a way to get the ladders.

An inefficient way:

  1. Loop all the characters of KR.
  2. Use Profile Ladder Summary api (/sc2/profile/:regionId/:realmId/:profileId/ladder/summary) with each profileId above to get all ladders of each character.
  3. Use Profile Ladder api (/sc2/profile/:regionId/:realmId/:profileId/ladder/:ladderId) with profileId and ladderId above to get all teams of each ladder.
  4. Add new characters found in these ladder teams.

I found that the ladder numbers of each region is self-increasing. So there's a more efficient way. No need to traverse all characters to find new ladders. Just need to increase the number to test if new ladder exists.

My new way:

  1. Loop from min active ladder number to max active ladder number + 15 (Assuming all ladders are active at first and test 15 more numbers for new season. It seems that there is a gap of about 10 ladder numbers between two seasons.)
  2. Use Legacy Ladder api (/sc2/legacy/ladder/:regionId/:ladderId) with each ladderId above to get all characters of each ladder. (Although it will return stale data of inactive ladders, but it will also return fresh data of active ladders. Use this api just to get a profileId we need to use in the following step.)
  3. Use Profile Ladder api (/sc2/profile/:regionId/:realmId/:profileId/ladder/:ladderId) with the first character profileId in above characters and ladderId to get all teams of each ladder.
  4. If no data found in the above step, then mark the ladder as inactive.
  5. If current ladder number is larger than max active ladder number and has teams data, then add the new active ladder.
  6. If current ladder has teams data and was marked inactive before, mark it active again.

After the frist loop, all inactive ladders are marked inactive. And we will loop only active ladders in following loops.

@nephest
Copy link

nephest commented Nov 15, 2021

If anyone is wondering if this is legit, SC2 Pulse uses the same algorithm, and this is the only way afaik,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment