PubSub: video-playback

Hey guys,

I was sent here by one of your employees who’s discussing the partnership with our eSports platform, as he didn’t have the required API knowledge.

We’re currently implementing a feature on our platform where you link your Twitch account and, when you’re live, a story is automatically posted on your profile, linking to your Twitch channel. A message in our tournament chat will also be posted, notifying the other participants of your stream.

Our current version is using the PubSub API, but we’re subscribing to the video-playback topic. This isn’t officially documented in your docs, but it is on your Github. So we’re wondering if this is already allowed to be used by a third party?

If it is, I think we’ll also be needing an increase in our allowed connections. Docs state that there’s a maximum of 50 subscriptions per connection. But seeing as we have more than 11.000 registered users, we’ll reach this threshold quite fast.

If needed, you can always contact me at jasper@kayzr.com if you need further details about our collaboration with Twitch.

Thank in advance!

Video-playback is not supported.

The github has some notes (in error) and a PR request that someone added of his gathered notes, but it’s not in the dev.twitch.tv documentation because it’s not supported for use by third parties and can and will change at any time, or just not work™.

With 11k users theres probably a better way than using pubsub to determine live status, but I’m not doing your work for you… :stuck_out_tongue:

Not supported? It’s actually already working in our development environment. I’m just wondering if we’re allowed to use it in production.

And I don’t really see what could be better than using pubsub. We don’t want to periodically query the Twitch API, because that puts unnecessary strain on our servers. Our whole platform is already working with sockets, as the whole app is realtime.

If it ain’t documented it ain’t supported, that means if and when it breaks you can’t complain about it. I myself use this topic, but I have two other backup methods for when the topic fails, and it fails a fair bit.

Which means you could use it in production but when it breaks, you need to have a backup.

You probably shouldn’t use it in production, because, Twitch wouldn’t grant you a elevated rate for an “unofficial”/unsupported API. You need to check 11k users? Using an unsupported API on a thing with a limited connection/subscription count?

So the only “official”/supported way of checking live status is the Twitch API under https://api.twitch.tv/kraken

And the only supported pubsub topics are whispers and bits.

Of course I don’t work for Twitch, but sounds like you might wanna email dev success and outline your usage case, but this pubsub topic, is not in official use. Technically it doesn’t exist.

Well, it is documented, but only on the Github.

A presence system broadcasting a user’s online status to all their friends.

And for your suggestion on using the current API: I’m really not inclined to make a call every minute to the API to see if our users came online. We have a full-fledged realtime web app that has over 500 concurrent users on a typical weekday, so it’s not just a simple PHP website that has a few pageviews per hour and can query the API whenever a page is requested.

We are in contact with Twitch for a partnership, but our contact person said this was the best place to ask API specific questions.

GitHub is deprecated as a documentation source. See: Twitch Developer site launch

The reference to video-playback is included in error on https://github.com/justintv/Twitch-API/tree/master/PubSub the only part that “appears” to be documented is the topic name itself, none of it’s message responses is listed.

PubSub Documented: https://github.com/justintv/Twitch-API/tree/master/PubSub
Bits Documented: https://github.com/justintv/Twitch-API/blob/master/PubSub/bits.md
Whispers Documented: https://github.com/justintv/Twitch-API/blob/master/PubSub/whispers.md
VidoePlayback Documented: None.

All of the above GitHub documentation links are invalid and no longer supported and are superseeded by dev.twitch.tv github means nothing

PubSub documentation: https://dev.twitch.tv/docs/v5/guides/PubSub/
Bits Documentation: https://dev.twitch.tv/docs/v5/guides/PubSub/bits/
Whispers Documentation: https://dev.twitch.tv/docs/v5/guides/PubSub/whispers/
VideoPlayback Documentation: none.

I hope this clears it up for you?

The presence systems is not the video-playback topic, and is also undocumeted and thus unsupported.

DevSuccess is a WHOLE different department to the Twitch Partnership department, which deals with ability for users to Subscribe to a channel.

Aha, I didn’t know the GitHub was deprecated, thanks for clearing that up.

Still, I’d love to get in contact with a Twitch official for this case :slight_smile:

Barry is correct in all of his assessment. The video-playback PubSub topic isn’t a supported topic at this time. If it becomes a supported topic, the documentation will be updated to reflect that. The supported way to poll for liveness is to use the streams endpoint. If you have more questions, please let me know! :slight_smile:

But then what do you suggest as my ideal approach?

If, for example, we have 500 users who have linked their Twitch account, do you expect us to call the streams endpoint 500 times per minute? But what about users who linked their Twitch but rarely steam? Why should we call the endpoint for them? And what if it’s nighttime in our region, why should we still poll the endpoint every minute?

The pubsub was the perfect solution for us, but this doesn’t seem an option anymore?

PubSub isn’t an option at this time.

The approach to this problem is the same as other integrations that show live status. In short: poll the streams API, cache the responses, request stream info from your cache for subsequent users, and then refresh cache every 3 - 5 minutes. Our API endpoints are cached for at least 1 - 3 minutes anyway, so it doesn’t make sense to poll constantly for this information.

Well, that’s a shame really. We have a live chat room during our tournaments, via where we would automatically announce if a player started streaming. A delay of 3 minutes really gives a very poor user experience…

Not really, all streamers have the same “notification delay”, and as such a lot of streamers start their stream with an intro of some description in order for some time to pass in order to allow all the notifications to go out, including but not limited to email, mobile push notification and curse.

Gotta actually give time for people to actually turn up and login, in reaction to a going live notification.

shrug

Note that the /kraken/streams endpoint has a channel parameter that allows you to request a comma-separated list of channels (ids on v5) to get the stream object for. I think the max is 100 per request, although I’m not sure if too long URLs could cause issues at some point. But either way, it doesn’t have to be 500 requests for 500 users.

I feel your pain on the constant endpoint calling… I have a Discord bot that polls the /streams endpoint periodically to announce live streams in discord… and it seems that having it run the checks with 2 minutes between the calls has been rather efficient (and the bot tracks over 4.5k unique channels, 500 unique games)… the announcements typically are sent to the appropriate channels within 3-5 minutes of the streamer going live, and I feel that’s a relatively fair delay…

and if your site is on LAMP, you could easily enough set a CRON task and never have to worry about it again (unless the API changes from v5)… you can call up to 100 channels per request and the guideline is 1 request per second… so for 11000 channels, what is that, a hair less than 2 minutes to make all the calls… that does not seem unreasonable at all

Is it good idea to just follow by bot all channels I want to track (may be thousands) and get /streams/followed endpoint every minute for example?

1 Like

To be honest, that was one approach we were also considering. It seemed the more logic and the least server-heavy.

We eventually decided not to go with it, since people in this topic clearly suggested the streams endpoint. If it turns out that the streams/followed way is the new way to go, please let me know!

@ague I’d take @ee_man suggestion. I’ve used that one before.

Make the bot follow some accounts and call the followed end point

That said, tracking 4.5k unique channels is a huge task.

I was about to suggest “well jsut read your email inbox and have the bot read the going live email notifications” but then that doesn’t account for going offline…

That is not a feasible option for my bot… but i don’t want to derail this thread any further… you can pm me if you’d like and we can discuss further

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