API request: personal best for particular user, game & category combination
2 years ago
Greater London, England

For executing get requests on personal-bests, I can filter by game as a query parameter as expected: https://www.speedrun.com/api/v1/users/jnz7rrdj/personal-bests?game=4pdvor1w

But I am also looking to query for a specific category.

Is there any way to get an individual's PBs only in a specific category? I tried this..: https://www.speedrun.com/api/v1/users/jnz7rrdj/personal-bests?category=z2761w0d&game=4pdvor1w

..but then realised the docs only list game, top and series as query parameters for pbs. Is there a clean way to do this (either with personal-bests, or another method)?

Edited by the author 2 years ago
YUMmy_Bacon5 likes this
United States

I dont entirely understand this but in a individual category you can check obsoleted runs and it will show previous pbs by users in the specific category

YUMmy_Bacon5 likes this
Greater London, England

I'm only interested in current PB. The first api link I provided gives me all of a player's PBs in a game, but gives all categories. I need to know a way to only return for a specific category. Currently I'm having to just loop through the results until it matches on the category I'm interested in, to retrieve the information. But this is inefficient seeing as I know the exact category I'm looking for. If I can include category in the GET request, this would solve my issue, but the method I've tried (2nd link) doesn't work.

YUMmy_Bacon5 and astrolite like this
Greater London, England

I think I figured it out. Shame there's not a flag for obsolete/current, but this works as far as I can tell: https://www.speedrun.com/api/v1/runs?game=4pdvor1w&user=jnz7rrdj&category=z2761w0d&status=verified&orderby=date&direction=desc

From this I can take result 0 for most recent verified PB

YUMmy_Bacon5 likes this
Germany

Wouldn't that display a wrong result if someone uploads an old run that isn't their PB anymore?

YUMmy_Bacon5 likes this
Greater London, England

Shouldn't be a problem ordering by 'date', as that's the date the run was performed on rather than date of submission. You can order by 'submitted' which would give the problem you mentioned. I suppose there's a chance that someone uploads an obsolete PB without putting an accurate run date. If the above doesn't improve response time much over my current workaround, I'll probably just leave it as it was because ik it works.

YUMmy_Bacon5 likes this