Fetch accumulated user stream monthly total

We are working on a Discord bot that will hopefully track the amount of time streamed, on a month-to-month basis. So to test if this is plausible, is it possible to fetch from the 1st to the last day of the month, the total time accumulated for users video streamed/recorded?

Channel statistics (such as those displayed on a channels dashboard) are not accessible through any official API endpoints. If you want the historical data that Twitch provides you’ll have to manually export the CSV from the stats dashboard and process that yourself to calculate total time streamed in a month.

Alternatively, if you would like to automate things with the API and get data going forward (this wont help if you want historical data) one way would be to poll the Get Streams endpoint and make notes of when when a stream started and stopped.

Another way would be to use Stream Changed webhook and just record stream starts/stops and ignore all other changes.

From there you can just sum the time between the sets of start/stop timestamps for a given month (or any time period you like). One point to note though is that the API uses caching, so as long as ~1 minute accuracy is sufficient for your needs then you’ll be fine, but if you need more precision then that you’ll have to use other undocumented ways, or ways external to Twitch to calculate more accurately.

Sweet, thanks for your ellaborate response. I am pretty sure we can do with ~1 minute accuracy. We’ll have a look and let you guys know how we fare.

How about the stat in Dashboard that reads the total hours streamed in a 30 day period?
None of our members are partnered, yet, so I understand it will also read if the hours are more than 25. Is there an API for fetching this number?

None of the dashboard stats are available through any official API.

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