speedruncomorg / api

REST API Documentation for speedrun.com
346 stars 36 forks source link

User embeds on Runs queries? #10

Closed Craigbavender closed 9 years ago

Craigbavender commented 9 years ago

Any plans to implement this? The 50 request limit is rough if anyone is trying to associate a run with user for any category with > 50 runs.

CryZe commented 9 years ago

Why would you query all the runs for a category? If you want leaderboards use the old Records API with restids=yes.

Craigbavender commented 9 years ago

According to the old records API, all that I've seen available is: ?game=Game title, ?series=Series, ?user=Username. Adding restids=yes to a game query isn't doing anything for me, see: http://www.speedrun.com/api_records.php?game=Mega%20Man%20X&restid=yes

What am I doing wrong there?

And to answer your question, I'm querying runs for specific categories because currently the v1 api doesn't support getting complete leaderboard data in a single request, so I have to get game and categories, then get runs based on category ids.

CryZe commented 9 years ago

You also need amount=99999 or some large number to query all the records. Otherwise it will only return a single value. Also, this Issue is still fine, as I would want embedded users for Runs too (in some situations it's still useful).

Craigbavender commented 9 years ago

Thank you. Is there a list of available legacy api commands somewhere I can use for the time being?

CryZe commented 9 years ago

http://www.speedrun.com/Speedrunning/guide/faq00 Scroll down to the API section.

CryZe commented 9 years ago

Also your URL has restid instead of restids.

sgt-kabukiman commented 9 years ago

Querying runs in a given category is a perfectly valid usecase for the API. I see no issue with that.

When it comes to embedding the players (note that besides users there are guests), that's certainly possible. There are quite a few things that are still missing, like embedding the category, level etc. as well.

If you want to implement a proper leaderboard (and not wait until I migrated the old one), good luck and have fun. For simple things it seems easy enough, but when you have custom variables that control how and if runs obsolete each other, things get messy real quick. I would advise against crawling down that rabbit hole and instead just wait a bit more until the leaderboard is finally in our API. ;-)

Craigbavender commented 9 years ago

Sounds good, thank you. I'm going to go ahead and use the legacy api for the time being to gather the simple run data I'm after. I'll keep up with api changes and implement them as it's improved.

sgt-kabukiman commented 9 years ago

The restids parameter for api_records.php is now gone (or enabled by default, depends on your viewpoint), as run IDs are encoded on the website as well.

sgt-kabukiman commented 9 years ago

You can now embed the players in runs by using ?embed=players. Compare http://www.speedrun.com/api/v1/runs/9yoj8n7m with http://www.speedrun.com/api/v1/runs/9yoj8n7m?embed=players for a run by multiple users and one guest.

Documentation will be updated later.

sgt-kabukiman commented 9 years ago

d2693ae4dd0305b resolves this.