Check if stream is online or offline with javascript?

I’m trying to set up my website to display my stream when I’m live and to display something else when I’m not. I currently have the following working:

$.getJSON('', function(channel) {

    if (channel["stream"] == null) { 

    } else {

It works, however it doesn’t seem to update for a couple minutes or so after I go live or stop streaming. Is there a way to make this more responsive? It doesn’t need to be instant but more than 30 seconds or so makes me think something isn’t working right here.

Help appreciated!

The endpoints are cached and are not real-time. They are usually off by 1 - 2 minutes. I have seen it take longer at times as well.


That’s unfortunate. I guess I’ll have to live with it.

Perhaps with the upcoming Helix API, there will be some performance improvements or perhaps even a WebHook to let us know when stream statuses change that is fired closer to real-time:

Twitch Trello:

1 Like

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