Jacket of the game

Hi,
i’m doing alert live for some streamers and i got a problem for have jacket of the game.

i don’t know why my code don’t want to work :

$.getJSON(‘https://api.twitch.tv/kraken/games/top?limit=50&offset=0’, function(data) {picture=data[“game”][name of the game][“logo”][“medium”]});

thanks !

You’re not getting the data from the right place. The first object is an array called top with an object called game inside of it. Check out the docs here: https://github.com/justintv/Twitch-API/blob/master/v3_resources/games.md

but i don’t understand, i can get the url of the jacket there ? no ?

You can get the URL there, but you’re traversing the JSON incorrectly. In your example, you’re going into data["game"] first which isn’t the top response object. The top array is the correct place to start. You then go into [name of the game], which is a field and not an object. Read through the example response in the docs I linked, and you can follow the path to the URL. :slight_smile:

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