API: Getting the amount of runners along the position of the run
6 years ago
Québec
Avasam
He/Him, They/Them
6 years ago

I created an issue on Github, ( https://github.com/speedruncom/api/issues/45 ) but since I don't know how often you guys actually check on there, I'll make a post here as well.

Some context: I'm making a global leaderboard where a higher position gives more points based on how many people run the game/category/level/etc. (There's a few rules to make sure this system can't be abused, but this is irrelevant to the API)

My problem: I need to do a new request for every player's PB. Wich will make me hit the 100 request/minute really, really fast.

My suggestion: I need the runs returned by "/users/{id}/personal-bests" to also display the ammount of runners along the position of the run or support embed leaderboards so that I can count the runners myself.

This way I could know a run is 5th/23 place in one request instead of having to do a new request for every player's PB.

Edited by the author 4 years ago
Québec
Avasam
He/Him, They/Them
6 years ago

So far it looks like you are. The bot is currently going through every single one of the 87080+ users and should be done in roughly a week if nothing goes wrong. https://www.avasam.dev/global-scoreboard

I'll also release a tool to let people update any user they want one at a time. It already works, it's just not ready for a public launch.

Edit: Wow that link was outdated. It was still referencing an old google sheets from college days XD

Edited by the author 3 years ago
Québec
Avasam
He/Him, They/Them
4 years ago

While this wouldn't be as useful for me now as when I asked about it back then (see reason below). Knowing at least the leaderboard size could still prove very useful to prevent some useless calls to the api when there's not enough runners.

Since then I've started using the time of all the PBs on a board to compare relatively to a specific run's time. As well as a bunch of other infos from the leaderboard. I've opted for a caching/memoizing system, with checkpoint on webworker timeout and eventually a requests pool as well.

Edited by the author 4 years ago
United States

This is really cool!

TCM likes this