I’m attempting to determine if a user is online using the API. I can find the user and return all the information associated with them, i.e. display_name, followers, game, status… but to determine if someone is online, looking at previous posts in the forum, I see that people have used the below code
From the code snippet you provided, it appears like you’re hitting the /channels/<channel-id> endpoint. To check whether or not someone is online, use the /streams/<channel-id> endpoint. If a stream is offline, the stream object in the response will be null.
Ok, below is my code. I’m not using the nameARRAY variable, I can see everything output into the console. Six, it does seem like I should be using the /streams/ endpoint, but, will I still be able to pull all the same information from the /channels/ endpoint or will I have to make a separate API call for it?
Alright, I believe I figured it out. I added a second API call to the /streams/ that I’ve tested successfully with known offline and online users… or channels?
Sorry for the late reply, but you should only need to make one API call since the channel object is embedded in the stream response. Although, there have been known issues where caches can be updated at different times giving slightly out of date results. That being said that should be a non-issue for the most part and just hitting streams endpoint should be fine.
Yeah, this confusion is why they were merged into one object in Helix