Clips API returns status code 200 on bad request

Here’s an example of a bad request:

https://api.twitch.tv/kraken/clips/top?game=League+of+LEARGENRDS

I’d expect this to return with something like HTTP status code 400 or 404. However it returns with status code 200, indicating a successful response. This is the response JSON:

{
  "clips": [],
  "_cursor": ""
}

What’s bad about the request? An empty result can still be a successful one; there are indeed no clips for a game called “League of LEARGENRDS”.

Because Twitch has a list of valid game names, as defined by the games endpoint:

League of LEARGENRDS is not in the list.

More generally, the HTTP error codes exist to be used, and ignoring them does developers a disservice. HTTP libraries have a bunch of features built around using the error codes. In my case, I’m going to have to put some extra logic in, that I wouldn’t have to otherwise, making my code that little bit uglier.

The game value isn’t technically restricted to those listed. Most unlisted won’t have any and most of the ones that do are typos of the game directory entry. See https://api.twitch.tv/kraken/clips/top?game=Counter-Strike+Global+Offensive&api_version=4 vs. https://api.twitch.tv/kraken/clips/top?game=Counter-Strike:+Global+Offensive&api_version=4 (notice the colon)

That’s just a search endpoint for people who are currently playing, of you used the api put request to set your game you could indeed find your game listed there.

Ahh, okay, I didn’t realize the nature of the games endpoint. Nevermind!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.