# Show Iframe when live and message when off line

**URL:** <https://discuss.dev.twitch.com/t/show-iframe-when-live-and-message-when-off-line/37619>\
**Category:** API\
**Created:** [March 29, 2022, 5:42am UTC](https://discuss.dev.twitch.com/t/show-iframe-when-live-and-message-when-off-line/37619 "2022-03-29T05:42:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ocrammgg](https://avatars.discourse-cdn.com/v4/letter/o/ce7236/32.png) [@ocrammgg](https://discuss.dev.twitch.com/u/ocrammgg)\
**Post date:** [March 29, 2022, 5:42am UTC](https://discuss.dev.twitch.com/t/show-iframe-when-live-and-message-when-off-line/37619/1 "2022-03-29T05:42:25Z")

</div>

Hello! I’m creating a personal web and would like to add a section of my streams, so I thought it would be a good idea to use the twitch API to display the iframe of my stream when I’m online and display a message like “Not online” when I’m not. But I can’t find the right way to do this so I would really appreciate if someone could give me at least an idea how it could be done. Thanks!

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [March 29, 2022, 12:11pm UTC](https://discuss.dev.twitch.com/t/show-iframe-when-live-and-message-when-off-line/37619/2 "2022-03-29T12:11:25Z")

</div>

1. On your backend/cron job generate an [App Access/Client Creds token](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth#oauth-client-credentials-flow)
2. Call [Get Streams](https://dev.twitch.tv/docs/api/reference#get-streams)
3. Store the Result in a db/cache/something

or

1. Create an [EventSub handler/listener](https://dev.twitch.tv/docs/eventsub)
2. On your backend/cron job generate an [App Access/Client Creds token](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth#oauth-client-credentials-flow)
3. Subscribe to [Stream Online/Offline](https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types#stream-subscriptions)
4. When your Stream State changes, Twitch will tell you via a HTTP Post Store the Result in a db/cache/something

THEN

Your Front End will use the valud from your db/cache/something to decide if to show the iFrame or a message instead.

This will also give you access to the Stream Title and Game

With EventSub you would use [channel.update](https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types#channelupdate), with Long Polling the API yoru Cron Job would grab it from it’s Get Streams Check

---

<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 28, 2022, 12:11pm UTC](https://discuss.dev.twitch.com/t/show-iframe-when-live-and-message-when-off-line/37619/3 "2022-04-28T12:11:52Z")

</div>

Closed on April 28, 2022, 12:11pm UTC

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