# Automatic detection

**URL:** <https://discuss.dev.twitch.com/t/automatic-detection/1737>\
**Category:** API\
**Created:** [March 1, 2015, 2:22pm UTC](https://discuss.dev.twitch.com/t/automatic-detection/1737 "2015-03-01T14:22:22Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Blafikox](https://avatars.discourse-cdn.com/v4/letter/b/7ab992/32.png) [@Blafikox](https://discuss.dev.twitch.com/u/Blafikox)\
**Post date:** [March 1, 2015, 2:22pm UTC](https://discuss.dev.twitch.com/t/automatic-detection/1737/1 "2015-03-01T14:22:22Z")

</div>

Hi everyone!  
I apologize for my English because I’m French …

I need your help because I’m not very good at coding and so I do not really understand the API.  
I would like to automatically detect when a stream is online or offline. When online, I want an image appears and when it is offline, another image.

I would do it in jQuery rather than php. After if we are forced with php, I would do in php.

Thank you very much for your help. 🙂

---

<div class="post-metadata">

**Author:** ![AnUnknownMiner](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/anunknownminer/32/305_2.png) [@AnUnknownMiner](https://discuss.dev.twitch.com/u/AnUnknownMiner)\
**Post date:** [March 2, 2015, 1:07am UTC](https://discuss.dev.twitch.com/t/automatic-detection/1737/2 "2015-03-02T01:07:53Z")

</div>

It’s not automatic, but here is what you can do to check.

[Streams.md](https://github.com/justintv/Twitch-API/blob/master/v3_resources/streams.md)

---

<div class="post-metadata">

**Author:** ![FiveManDown](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/fivemandown/32/335_2.png) [@FiveManDown](https://discuss.dev.twitch.com/u/FiveManDown)\
**Post date:** [March 2, 2015, 1:09pm UTC](https://discuss.dev.twitch.com/t/automatic-detection/1737/3 "2015-03-02T13:09:49Z")

</div>

> [@AnUnknownMiner](#):
>
> Streams.md

To extend on that… basically you have to request the streams by channel name and if the stream is live it will be returned in the response otherwise it wont be. That’s how you know if it is online or offline.

---

<div class="post-metadata">

**Author:** ![Fugiman](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/fugiman/32/108_2.png) [@Fugiman](https://discuss.dev.twitch.com/u/Fugiman)\
**Post date:** [March 2, 2015, 7:59pm UTC](https://discuss.dev.twitch.com/t/automatic-detection/1737/4 "2015-03-02T19:59:00Z")

</div>

You can also use [https://github.com/Fugiman/Twitch-Channel-Status](https://github.com/Fugiman/Twitch-Channel-Status) to help you get started with your solution.

---

<div class="post-metadata">

**Author:** ![Blafikox](https://avatars.discourse-cdn.com/v4/letter/b/7ab992/32.png) [@Blafikox](https://discuss.dev.twitch.com/u/Blafikox)\
**Post date:** [March 3, 2015, 3:37pm UTC](https://discuss.dev.twitch.com/t/automatic-detection/1737/5 "2015-03-03T15:37:10Z")

</div>

Yes but on my website there will be several streameurs. What I want to do is a homepage with a picture on it for each streameur: this one if the stream is offline: [http://image.noelshack.com/fichiers/2015/10/1425396841-blaf-deco](http://image.noelshack.com/fichiers/2015/10/1425396841-blaf-deco) .png  
and this one if the stream is online: [http://image.noelshack.com/fichiers/2015/10/1425396882-blaf-en-live.png](http://image.noelshack.com/fichiers/2015/10/1425396882-blaf-en-live.png)  
But there will be more images like this one on the home page. So his scripts I put them on the homepage but how to detect the correct channel?  
I do not know if you understand me …  
You want me to show you my HTML and CSS for you to understand better?

Again sorry for my english …

---

<div class="post-metadata">

**Author:** ![Fugiman](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/fugiman/32/108_2.png) [@Fugiman](https://discuss.dev.twitch.com/u/Fugiman)\
**Post date:** [March 4, 2015, 5:21am UTC](https://discuss.dev.twitch.com/t/automatic-detection/1737/6 "2015-03-04T05:21:05Z")

</div>

The script I linked to you does this for you, and it explains how to use it. Specifically, you’d do something like this:

```
<img data-twitch-channel="riotgames" data-offline-image="riotgames.png" data-online-image="riotgames-live.png">
<img data-twitch-channel="lirik" data-offline-image="lirik.png" data-online-image="lirik-live.png">
<img data-twitch-channel="beyondthesummit" data-offline-image="beyondthesummit.png" data-online-image="beyondthesummit-live.png">

<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://cdn.rawgit.com/Fugiman/Twitch-Channel-Status/1d74252edf89110507cbf3088f9c3eaa38fac9d3/twitch-channel-status.min.js"></script>

```

Does that make it clear?

---

<div class="post-metadata">

**Author:** ![Blafikox](https://avatars.discourse-cdn.com/v4/letter/b/7ab992/32.png) [@Blafikox](https://discuss.dev.twitch.com/u/Blafikox)\
**Post date:** [March 4, 2015, 11:08am UTC](https://discuss.dev.twitch.com/t/automatic-detection/1737/7 "2015-03-04T11:08:23Z")

</div>

Thank you so much !!!

---

<div class="post-metadata">

**Author:** ![system](https://d2opxh93rbxzdn.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://discuss.dev.twitch.com/u/system)\
**Post date:** [April 3, 2015, 11:11am UTC](https://discuss.dev.twitch.com/t/automatic-detection/1737/8 "2015-04-03T11:11:40Z")

</div>

Closed on April 3, 2015, 11:11am UTC

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