Currently the response from the “Search Categories” end point does not return the number of viewers.
In other threads BarryCarylon has a suggested method which is simply to aggregate all of the streams under a gameid/categoryid. Browser Categories | Twitch API Example
However this solution is not scalable for my needs. For my application I want to get values for the top ~200-2000 categories once every 8 or so hours. The rate limit would become a problem and leave some games that have lots of streamers as being inaccurate.
Using dev tools on twitch.tv I see that this category viewers exists in the graphql response
"name": "New World",
"displayName": "New World",
"description": "Explore a thrilling, open-world MMO filled with danger and opportunity where you'll forge a new destiny for yourself as an adventurer shipwrecked on the supernatural island of Aeternum. Endless opportunities to fight, forage, and forge await you among the island's wilderness and ruins. Channel supernatural forces or wield deadly weapons in a classless, real-time combat system, and fight alone, with a small team, or in massed armies for PvE and PvP battles—the choices are all yours.",
However I’ve been advised to not use the graphql endpoint for app development, so I will not.
Are there any plans on exposing this information on the twitch-cli / heilx any time soon? Or should I come up with a creative way to sum up thousands of streams and account for raids and sudden user transitions between rate-limit refreshes?
My current plan is to use the “get-streams” endpoint. Get the top ~20000 streams and bucket them into a dictionary of game_id to viewers. Then use those for my categories. It should hopefully be ~95% accurate. Which might be good enough here. That would be 200 requests as opposed to ~10 requests if the categories were query-able.
Generallty the information is instantly out of date, or not practical to provide to consumers of the API (caching etc)
This would of been my recommendation, since well, that is me!
Perhaps only load the first page or two of streams rather than going deeper.
It may also suggest that Twitch doesn’t want to support this sort of statistical gathering, hence the no view counts on the category based endpoints. And the apparent “difficultly” in what you are trying to do.
This is against the Developer TOS
Developers should only use the endpoints documented in the documentation
Anything else can change, break, or even stop existing at any time. Since Twitch won’t advance warning us for changes to things developers are not expected to be using.
You can make feature requests on the uservoice, don’t forget to cite your usecase/reasoning!
Sounds somewhat sensible. Since you’ll also only need to do game fetches for gameID’s you don’t have cached.
After 10/20 pages or so you start to get weirdness anyway. As channels will jump about on pages and be returned multiple times.
IE You load page 15, a big streamer comes online and appears instanly on
page 1, which pushes streamer
bob from the last entry on page 15 to the first entry on page 16 for example.
The tail end of streams will have various fun things like that, so you’d need to deduplicate.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.