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?
Alca
August 27, 2017, 3:43pm
2
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.
george
August 27, 2017, 6:54pm
4
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!
george
August 27, 2017, 7:18pm
6
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
system
Closed
September 26, 2017, 7:25pm
8
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.