# Twitch Hype Train

**URL:** <https://discuss.dev.twitch.com/t/twitch-hype-train/37156>\
**Category:** API\
**Created:** [March 3, 2022, 3:04am UTC](https://discuss.dev.twitch.com/t/twitch-hype-train/37156 "2022-03-03T03:04:10Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheKill\_996](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/thekill_996/32/6901_2.png) [@TheKill\_996](https://discuss.dev.twitch.com/u/TheKill_996)\
**Post date:** [March 3, 2022, 3:04am UTC](https://discuss.dev.twitch.com/t/twitch-hype-train/37156/1 "2022-03-03T03:04:10Z")

</div>

Hey, I was looking to develope a widget to show directly on stream the Twitch Hype Train progression, so I looked up to Twitch APIs documentation and the only thing I found is [Get Hype Train Events](https://dev.twitch.tv/docs/api/reference#get-hype-train-events).

I’m confused, how should I use it? I was expecting some sort of WebSocket spreading events in real-time, but seems like the only avaible method is an API Endpoint. How can I can retrieve Hype progress in real-time? Is this something doable? Am I missing something?

The only way I can think of is doing requests to that endpoint, but I’m worried about how many I can do and also how fast I can trigger it.

---

<div class="post-metadata">

**Author:** ![WLG3R](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/wlg3r/32/6985_2.png) [@WLG3R](https://discuss.dev.twitch.com/u/WLG3R)\
**Post date:** [March 3, 2022, 3:08am UTC](https://discuss.dev.twitch.com/t/twitch-hype-train/37156/2 "2022-03-03T03:08:58Z")

</div>

If you want real time alerts you can use EventSub. It has begin, progress, and end events.

> **[EventSub Subscription Types](https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types/)**
>
> Subscription Types

---

<div class="post-metadata">

**Author:** ![TheKill\_996](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/thekill_996/32/6901_2.png) [@TheKill\_996](https://discuss.dev.twitch.com/u/TheKill_996)\
**Post date:** [March 3, 2022, 3:17am UTC](https://discuss.dev.twitch.com/t/twitch-hype-train/37156/3 "2022-03-03T03:17:09Z")

</div>

Thanks. Do you know if this can be done withing Streamelements custom coded widget? I already worked with [PubSub](https://dev.twitch.tv/docs/pubsub) but I’m worried this time I will need a middle server from where to subscribe to the event and then send data to SE’s widget.

---

<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 3, 2022, 12:55pm UTC](https://discuss.dev.twitch.com/t/twitch-hype-train/37156/4 "2022-03-03T12:55:12Z")

</div>

At this time EventSub only offers a Webhook Transport

EventSub over sockets is in Closed Beta testing, and basically replaces PubSub.

However there is no timeline on general availability.

You are doing yourself a disservice by limiting yourserlve to SE Custom Coded Widgets. This forum is unlikely to know what SE can or cannot do, since most of use will not limit ourself to the limitations of SE.

As it stands to consume HypeTrain data “sanely” you need a middle man server to consume the EventSub information.

---

<div class="post-metadata">

**Author:** ![TheKill\_996](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/thekill_996/32/6901_2.png) [@TheKill\_996](https://discuss.dev.twitch.com/u/TheKill_996)\
**Post date:** [March 3, 2022, 3:05pm UTC](https://discuss.dev.twitch.com/t/twitch-hype-train/37156/5 "2022-03-03T15:05:15Z")

</div>

Ok, that’s not the first time I face this situation. Let’s say I never worded with a middle man server.  
From where should I start? Can you share with me any guide on how to get started? Worth mentioning that my goal is to have a service that could be used by multiple streamers, so storing sensitive data has to be mentioned somehow.

---

<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 3, 2022, 3:30pm UTC](https://discuss.dev.twitch.com/t/twitch-hype-train/37156/6 "2022-03-03T15:30:37Z")

</div>

You just need a server side script  
That is behind SSL

That server side script needs to be able to recieve POST requests.  
Like a “login form to a website” would.

Twitch will be POST-ing to you JSON formatted data in the POST.

You can probably find exmaples and/or libraries over on [Community Resources | Twitch Developers](https://dev.twitch.tv/code)

Or you can check my Github where there is filed a PHP and a NodeJS example for consuming Webhook Transport EventSub [https://github.com/BarryCarlyon/twitch\_misc/tree/main/eventsub/handlers](https://github.com/BarryCarlyon/twitch_misc/tree/main/eventsub/handlers)

You’ll also need a public web page that streamers would go to, in order to authorise your ability to read hype train data. So you’ll need a user oAuth web page.

You can then store or discard that user oAuth token as EventSub Webhooks uses an App Access Token to create Subscriptions to data feeds.

You would usually retain that token for “catch up” if you need to restart your system or experience any down time.

The “Handling Webhhook Events” guide is relatively comprehensive [Handling Events | Twitch Developers](https://dev.twitch.tv/docs/eventsub/handling-webhook-events)

---

<div class="post-metadata">

**Author:** ![TheKill\_996](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/thekill_996/32/6901_2.png) [@TheKill\_996](https://discuss.dev.twitch.com/u/TheKill_996)\
**Post date:** [March 4, 2022, 2:37am UTC](https://discuss.dev.twitch.com/t/twitch-hype-train/37156/7 "2022-03-04T02:37:41Z")

</div>

Thanks, that will help me for sure! I’m a bit worried about storing secrets/access\_tokens etc on my server, is there any specific guide on how to store these sensitive data?

---

<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 4, 2022, 12:45pm UTC](https://discuss.dev.twitch.com/t/twitch-hype-train/37156/8 "2022-03-04T12:45:07Z")

</div>

People often store client secrets in .env and config files and generally you don’t expose these in client facing code.

As for tokens, they are basically passwords so handle them the same way you handle user passwords if your website/tool has a login form.

---

<div class="post-metadata">

**Author:** ![TheKill\_996](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/thekill_996/32/6901_2.png) [@TheKill\_996](https://discuss.dev.twitch.com/u/TheKill_996)\
**Post date:** [March 28, 2022, 4:16pm UTC](https://discuss.dev.twitch.com/t/twitch-hype-train/37156/9 "2022-03-28T16:16:08Z")

</div>

I’m pretty sure this question is very well related to this topic, how can I test such Hype Train events?

---

<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 28, 2022, 4:17pm UTC](https://discuss.dev.twitch.com/t/twitch-hype-train/37156/10 "2022-03-28T16:17:45Z")

</div>

You can use the TwitchCLI to test EventSub sample messages against your endpoint

> <https://github.com/twitchdev/twitch-cli/blob/main/docs/event.md>

---

<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 27, 2022, 4:18pm UTC](https://discuss.dev.twitch.com/t/twitch-hype-train/37156/11 "2022-04-27T16:18:04Z")

</div>

Closed on April 27, 2022, 4:18pm UTC

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