Get Stream by User not working

I’m trying to fetch streams by user ids, I’m using the following endpoint:

https://api.twitch.tv/kraken/streams/< channel ID >?client_id=< client ID >

I have registered my website and obtained a valid client id. The “Get Live Streams” is working but not the one that I’m looking for! I can’t understand why is it not working? If I’m making a mistake somewhere, what is it?

Make sure you’re using the correct version of the API https://dev.twitch.tv/docs/v5/guides/using-the-twitch-api/ v5 is what you want to use. It defaults to v3 currently.

Yes! I’m using the v5 version of the API.

Can you provide more information about what is not working like an error message or response?

The endpoint https://api.twitch.tv/kraken/streams/26490481 (summit1g for example) is working correctly for me when passing client ID and v5 version via headers.

I’m using jQuery’s $.getJSON() method for fetching the data, which looks like this -

$.getJSON(“https://api.twitch.tv/kraken/streams/< user id >?client_id=< client id >”, function(json) {
console.log(json);
});

The output is following for any user id, whether the channel is offline or online -

{
“stream”: null,
“_links”: {
“self”: “https://api.twitch.tv/kraken/streams/79776140”,
“channel”: “https://api.twitch.tv/kraken/channels/79776140
}
}

which doesn’t comply to the response format in the documentation!

You aren’t specifying the API version in your request so it is defaulting to v3 and you need v5.

jQuery example:

$.ajax({
 type: 'GET',
 url: 'https://api.twitch.tv/kraken/streams/26490481',
 headers: {
   'Client-ID': '<removed>',
   'Accept': 'application/vnd.twitchtv.v5+json'
 },
 success: function(data) {
   console.log(data);
 }
});

I couldn’t realise it earlier. Thank you very much for helping me, it’s working now :slight_smile:

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