justintv / Twitch-API

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

Condition if stream is on or off #675

Open Trukess opened 7 years ago

Trukess commented 7 years ago

I was reading the API documentation from twitch but didn't find what I needed, I just need a condition that give me true or false if streamer is on or off, someone can help me?

freaktechnik commented 7 years ago

You'll need https://dev.twitch.tv/docs/v5/reference/streams/.

Further this belongs to https://discuss.dev.twitch.tv and not an inactive bug tracker for obsolete API documentation.

Trukess commented 7 years ago

Thank you very much for answer me freaktechnik, where I should type:

curl -H 'Accept: application/vnd.twitchtv.v5+json' \ -H 'Client-ID: uo6dggojyb8d6soh92zknwmi5ej1q2' \ -X GET 'https://api.twitch.tv/kraken/streams/?game=Overwatch'

What kind of language is this?

scagood commented 7 years ago

curl is a command line tool. (https://curl.haxx.se/)

This means you'd put the following into your console: f41ee468e886559c0a197610d5afb0cc

The top part is the command. curl -H "Accept: application/vnd.twitchtv.v5+json" -H "Client-ID: uo6dggojyb8d6soh92zknwmi5ej1q2" -X GET "https://api.twitch.tv/kraken/streams/?game=Overwatch" The next part is the response.

Broken down this gives you: The application: curl Add a header: -H "Accept: application/vnd.twitchtv.v5+json" Add a header -H "Client-ID: uo6dggojyb8d6soh92zknwmi5ej1q2" Set the request method: -X GET Finally the url you're requesting: 'https://api.twitch.tv/kraken/streams/?game=Overwatch'

Hope this helps, sca

Trukess commented 7 years ago

Thanks for the answer scagood, so I need to install latest version from curl in my computer?

freaktechnik commented 7 years ago

No, that's just how the API documentation shows examples for making requests to the API. You can use whatever you want to make requests.

Trukess commented 7 years ago

Oh I understand, thanks freaktechnik 🍡

EpsilonAlpha commented 7 years ago

@freaktechnik to determine if a channel is online i proof that

".stream.viewers" is not NULL

and in my case if

".stream.stream_type" is "live"

so i skip out the Vodcasts.

Hopes that helps you.

Update: Currently the v5 API returns if a stream is offline: { "stream": null }

v3 version if a stream is offline { "stream": null, "_links": { "self": "https://api.twitch.tv/kraken/streams/", "channel": "https://api.twitch.tv/kraken/channels/" } }