How to just check if a channel is live?

In case it helps anyone else, I’m just doing this and it works perfectly.

I firstly grab the data from: https://api.twitch.tv/helix/streams?user_id=mychannel

Then, I also query for the name of the game if it exists: https://api.twitch.tv/helix/games?id=idfromtheaboverequest

Then I save it to a local file (bundling in a game name if it exists), this is done on a cron once a minute so we never even touch the sides of the API limit - it also means actually loading it for users is super fast.

Then, with JS we do a simple check on the file:

	var json_file = "twitchstatus.json";
	$.getJSON(json_file, function(t) 
	{
		if (t["data"].length > 0 && t["data"][0].type == 'live')
		{
			if (t["game_name"].length > 0)
			{
				// we have a game name, use it here
			}
			else if (t["data"][0].title.length > 0)
			{
				// no game name, use the stream title
			}
			
			// show a "we're live" bar here
		}
	})