Getting info from API (simple)

So I’m new to twitch API, and been playing around with it a bit and got a little hang to it.
Altho im trying to load all the games, like “browse” on the site it self. But i cant seem to get it to work.

Can some one help me on this please?

SO far, i can load one game, with all the pictures. I want all games, and with the medium picture.

This is how far I’ve gotten:

$.ajax({
url: 'https://api.twitch.tv/kraken/games/top',
type: 'GET',
contentType: 'application/json',
dataType: 'jsonp',
success: function(data) {
	            	
$.each(data.top[0].game.box, function(index, value){
   //console.log("AJAX " + data.top[1].game.name);
   console.log("ID: " + index + value);

   $(".twitch-widget").append("<img src='" + value + "'>");
   		
   })          
 }
});
1 Like

Hi I’m also strarting to use the API. Can you clarify me what stands the index for?

Take a look at what you’re iterating over. $.each(data.top[0].game.box says “Take the top game, iterate over it’s boxart, and do something with each url”. You likely want $.each(data.top which says “Iterate over the top games”. Then you’d get the boxart with value.game.box.medium.

1 Like

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