justintv / Twitch-API

A home for details about our API
www.twitch.tv
1.72k stars 381 forks source link

Check if a user is LIVE or OFFLINE #548

Open bofinbabu opened 8 years ago

bofinbabu commented 8 years ago

I'm entirely new to twitch API. From what I've read from the documentation so far, I'm unclear how I'm going to make this simple API call which will tell if a user is streaming live or not? Note: In my particular case, the user is myself.

Decicus commented 8 years ago

If you make a call to /streams/:channel/, stream will either be an object (if LIVE) or null (if OFFLINE).

bofinbabu commented 8 years ago

Yes it's working. But it's taking about 20 seconds recognize the change (took 20 sec for that api call to return a null, instead of the object, after I stopped broadcasting) Is it normal?

bashtech commented 8 years ago

That is normal.

On Tue, May 10, 2016 at 10:11 AM Bofin Babu notifications@github.com wrote:

Yes it's working. But it's taking about 20 seconds recognize the change (took 20 sec for that api call to return a null, instead of the object, after I stopped broadcasting) Is it normal?

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/justintv/Twitch-API/issues/548#issuecomment-218169243

bofinbabu commented 8 years ago

@bashtech @Decicus It's not just 20 seconds. It's about 1 minute 45 seconds to detect that the stream has started. And it's about 3 mins to detect that the broadcasting stopped.

Is there any way to reduce these delays?

ghost commented 8 years ago

The time will vary, the endpoints are cached to improve performance, this is expected behavior.

jasongornall commented 8 years ago

bumping this.. is there anyway to speed this up?

Marioario commented 8 years ago

@TournyMasterBotCurse how long is the cache?

AVANAAR6 commented 8 years ago

Long is length, we use words,, C

-----Original Message----- From: "Ari Evans" notifications@github.com Sent: ‎09/‎06/‎2016 02:49 To: "justintv/Twitch-API" Twitch-API@noreply.github.com Subject: Re: [justintv/Twitch-API] Check if a user is LIVE or OFFLINE (#548)

@TournyMasterBotCurse how long is the cache? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

FugiTech commented 8 years ago

No, it can take anywhere up to 3 minutes for streams to change state due to various layers of caching. There is no way for you to speed this up.

jzisser9 commented 8 years ago

@Fugiman what about using event listeners to catch when a channel goes online/offline?

mavrick commented 8 years ago

@Argus9 @Fugiman here is a link if you are wondering what the event listeners are using the embeded video player https://github.com/justintv/Twitch-API/blob/master/embed-video.md#events

maxtruxa commented 8 years ago

Or you could just use the (now documented) PubSub system.

Listen for video-playback.some_channel and look for stream-up/stream-down. Documentation for the video-playback topic is available in this PR.