I’m getting a list of “programming” channels with a channels query. That’s working fine. Then I’m trying to query the streams with each channel ID returned to check if the channel is currently streaming using the status as I’ve read elsewhere in this forum. For this second query I’m getting a 400 error for each request.
This format for the request seems to match what I see in the documentation, except that the documentation always seems to use numerical channel IDs. What am I doing wrong?
Update: I figured it out. I didn’t realize that there was a separate “_id” field in the response representing the channel ID. I thought the name was the channel ID
$.ajax({
url: 'https://api.twitch.tv/kraken/search/channels?query=programming',
headers: {
'Accept': 'application/vnd.twitchtv.v5+json',
'Client-ID': clientId,
},
}).done(function(data){
console.log(data);
twitchData.channels = data.channels;
for (var i = 0; i < twitchData.channels.length; i++) {
var name = twitchData.channels[i].name;
$.ajax({
url: 'https://api.twitch.tv/kraken/streams/' + name,
headers: {
'Accept': 'application/vnd.twitchtv.v5+json',
'Client-ID': clientId,
},
}).done(function(data){
console.log(data);
});
}
});