[Suggestion] Get game by ID

Hi,

I know many people have been requesting this or something similar. I’m also aware that Twitch doesn’t normally discuss potential features, so I guess this is just my two cents. Hopefull we’ll get this with v5 release in Feb.

My use case:

So my app keeps a historic record of total viewers and channels for a handful of games. It uses this data to identify trends using lots of fun maths.

The problem:

In order to get the viewers and channels for the games I want, I have to use the Get Top Games endpoint which understandably returns a max of 100 games at a time. Some of the games I track only have a few viewers and with Twitch averaging 1500-2000 live games, I find myself making 15-20 requests before I find all the games I’m tracking. I have to parse each response and end up completely discarding about 90% of them.

From a client side perspective this presents a number of problems.

  • It adds complexity to your code
  • It taxes your rate-limit for api calls
  • It’s generally wasteful resource-wise

Possible Solution:

Make games requestable by ID using an endpoint such as this:

GET https://api.twitch.tv/kraken/games/id/{game_id}[,{game_id},{game_id},...]

Which would return something like this:

{
"game_id": {
    "channels": 953,
    "viewers": 171708,
    "game": {
        "_id": 32399,
        "box": {
            "large": "https://static-cdn.jtvnw.net/ttv-boxart/Counter-Strike:%20Global%20Offensive-272x380.jpg",
            "medium": "https://static-cdn.jtvnw.net/ttv-boxart/Counter-Strike:%20Global%20Offensive-136x190.jpg",
            "small": "https://static-cdn.jtvnw.net/ttv-boxart/Counter-Strike:%20Global%20Offensive-52x72.jpg",
            "template": "https://static-cdn.jtvnw.net/ttv-boxart/Counter-Strike:%20Global%20Offensive-{width}x{height}.jpg"
        },
        "giantbomb_id": 36113,
        "logo": {
            "large": "https://static-cdn.jtvnw.net/ttv-logoart/Counter-Strike:%20Global%20Offensive-240x144.jpg",
            "medium": "https://static-cdn.jtvnw.net/ttv-logoart/Counter-Strike:%20Global%20Offensive-120x72.jpg",
            "small": "https://static-cdn.jtvnw.net/ttv-logoart/Counter-Strike:%20Global%20Offensive-60x36.jpg",
            "template": "https://static-cdn.jtvnw.net/ttv-logoart/Counter-Strike:%20Global%20Offensive-{width}x{height}.jpg"
        },
        "name": "Counter-Strike: Global Offensive",
        "popularity": 170487
    }
}
}

Now I understand that Twitch uses GiantBomb info for some of its data (I assume that’s the “game”: {…} part) which is probably why this hasn’t already been implemented since this contains the id. I wouldn’t mind grabbing what I need from GiantBomb, however, I assume that the viewer and channel counts are on the Twitch side. So, if it would make this easier I would settle for just getting the viewer and channel counts.

{
"game_id": {
    "channels": 953,
    "viewers": 171708,
    "name": "Counter-Strike: Global Offensive", // other people want this
    "giantbomb_id": 36113, // maybe this would be useful too
}
}

Anyways, I know I’m not alone here. In my search for a better way I visited hundreds of threads discussing this. Hopefully this is something you guys can make happen for v5.

(Oh, if there actually is a better way to do this please let me know :))

It seems like there is at least something behind the https://api.twitch.tv/kraken/game/ endpoint, since it is actually returning

{
“error”: “Not Found”,
“status”: 404,
“message”: “Game not found”
}

you might find something by experimenting, a simple id isnt enough apparently :confused:

Also, i would support that endpoint, since it can be useful for statistic stuff (e.g. you want to track a single game)

It’s by name, e.g. https://api.twitch.tv/kraken/game/League%20of%20Legends

I could definitely settle for grabbing it by the name. However, I can’t seem to get your suggestion to work. I tried appending my client_id and changing game to games with no success. I just get this response:

{"error":"Not Found","status":404,"message":""}

It’s version 5. https://dev.twitch.tv/docs/v5/guides/using-the-twitch-api/#requests

{
	"game": {
		"name": "League of Legends",
		"popularity": 85798,
		"_id": 21779,
		"giantbomb_id": 24024,
		"box": {
			"large": "https://static-cdn.jtvnw.net/ttv-boxart/League%20of%20Legends-272x380.jpg",
			"medium": "https://static-cdn.jtvnw.net/ttv-boxart/League%20of%20Legends-136x190.jpg",
			"small": "https://static-cdn.jtvnw.net/ttv-boxart/League%20of%20Legends-52x72.jpg",
			"template": "https://static-cdn.jtvnw.net/ttv-boxart/League%20of%20Legends-{width}x{height}.jpg"
		},
		"logo": {
			"large": "https://static-cdn.jtvnw.net/ttv-logoart/League%20of%20Legends-240x144.jpg",
			"medium": "https://static-cdn.jtvnw.net/ttv-logoart/League%20of%20Legends-120x72.jpg",
			"small": "https://static-cdn.jtvnw.net/ttv-logoart/League%20of%20Legends-60x36.jpg",
			"template": "https://static-cdn.jtvnw.net/ttv-logoart/League%20of%20Legends-{width}x{height}.jpg"
		},
		"localized_name": "League of Legends",
		"locale": "en-us"
	}
}

The biggest issue with not having an id-lookup possibility is that you can’t store a valid reference to a Twitch game, because the game’s title can change at any point - as has happened several times.

If you use the id as a reference, it becomes worthless on a title change, since you can’t use it to look up the title.
If you use the title, it becomes worthless on a title change, since it’s no longer referenced in Twitch’s game library.

Only way to do it is to keep a local copy of Twitch’s entire game library, and keep it up-to-date. That’s a lot of work for something that should be so simple!

Well, I got the game lookup by name working. Thanks everyone for helping with that. Still, I think there should be a lookup by id. :confused:

I’d also really like to see getting a game by id. I’m resorting to searching by name for now, but since I’m trying to access a specific game I’ve stored a reference to, I’m concerned I’m not going to get the correct game back, at least, not always.

This seems like a must have imho.

Have you looked at our newly-announced roadmap for the new Twitch API? You might see something there that’ll help. :wink:

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