Twitch channel status - Need to show as online when in host mode

Hi,

I am using the Twitch API to get the status of the channel, however it shows as offline, when the channel in hosting another channel. The code is below.

Is there away to get the script to display as Online, whne it being used to hosted another channel or streaming

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    
<script>
var twitchUserName = 'TWITCH_CHANNEL'
$(document).ready(function() {    
$.getJSON("https://api.twitch.tv/kraken/streams/"+twitchUserName+"?callback=?",function(streamData) {
console.log('Stream Data:', streamData)
    
if (streamData && streamData.stream) {
$('#streamWidget').html("Online")
} else {
$('#streamWidget').html("Offline")
}
})
});
</script>

<div id='streamWidget' style="text-align:center;">querying twitch</div>

Thanks

There’s an undocumented endpoint (subject to change or disappear at any time without warning) that can be used to check what channel a channel is hosting, if any:

http://tmi.twitch.tv/hosts?include_logins=1&host=35936871 (esl_csgob, currently hosting esl_csgo), where the host parameter is the hosting channel’s ID from the /users endpoint.

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