Getting current viewers of a Twitch Stream

Hi there,

I want to make an app with Twitch integration, where loyalty stands in front. For this I want to fetch the viewers of a stream through an API. I don’t want to create a bot in this case as there is no interaction with it.

Basically, I found the URL https://tmi.twitch.tv/group/user/username/chatters on this site but I don’t want to abuse that endpoint, and what to make sure it is alright to use in bigger numbers in case I want to track a bigger amount of streamers (who have authorized it basically).

So… is there a rate limit to this API? Anything I need to keep in mind? Alternative API’s that work without having to create a bot etc?

First thing to make note of, the chatters endpoint returns a list of users connected to chat and in that streams channel. this means that it is NOT a list of viewers. There will be some viewers who are not logged in to Twitch or who may be watching on an embed where there isn’t a chat which means they wont show in the list, and the list will also include the many bots that join all channels on Twitch which are not actually viewing the stream at all.

Secondly, it’s an undocumented endpoint, meaning it can and will break at any time (and frequently does) and without warning. So use at your own risk.

As for rate limit, it’s not a documented endpoint so doesn’t have the usual rate limit rules, but just use common sense as you should be fine. For example the results are cached just like any other API endpoint, so hitting it more than once a minute for each channel you want to get a list of chatters for will be somewhat redundant and can actually start giving you inconsistent data if you poll too frequently due to potentially hitting a cache server with new data, and then a different server that may have older data.

Also you should make sure the data that you store is in compliance with the GDPR, the Developer Agreement, and any other laws on storing user data.

Thanks! I was aware of the limitation on the endpoint regarding viewers/chatters. I accept that limit for loyalty settings anyways.

Would there be better options in getting the chatters than what I’m proposing here?

The only other option would be to use an extension. This has the added benefit that not only would a streamer have to add it to their channel, but the users themselves would have to opt-in to it by sharing their ID with the extension.

An extension means it’s MUCH easier to be compliant with the laws/guidelines compared to using the chatters endpoint which will be getting data on some users who may not wish to be tracked and potentially not even be aware it’s happening, and also easily provides a way for users view the ToS of the extension and know what user data is being collected and also how to request that their user data be removed if requested.

That is actually pretty interesting indeed! Thanks a lot for that, I’ll dive into extensions.

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