Getting Stream Analytics for Each Video


Take a look at the question at the bottom.

I’m currently trying to get the analytics of my videos.

I’ve found the Stream documentation and also searched here in the forum. This topic already mentions some of what I need:

I want to generate a monthly report of all metrics associated with all videos my site has uploaded to Cloudflare Stream with the report containing 1 row of metrics for each videoId hosted. I want to bill my users based on the same billing data that Cloudflare Stream is billing me.

When using Fetching bulk analytics I can accomplish this.

However, I also want to display the “per video metrics” for my users (number of plays and minutes streamed). When querying the GraphQL API the time period is limited to one month. That’s fine for billing (when done monthly) but I cannot display my users the total number of plays and minutes streamed.

I could use the Fetching per-video analytics but when I do this very often I may hit the API rate limit very quickly. I could tackle it with some caching and queueing but it seems hacky and would be an unnecessary load for the API.

Rate limiting
The Cloudflare API sets a maximum of 1,200 requests in a five minute period.
Source: Cloudflare API documentation

Is there a way to perform a bulk request to the GraphQL API where I can get metrics for the whole time (since the video has been uploaded until now) for each video seperately in one request?

Thanks in advance.

Another thing that isn’t clear for me is this point:

View analytics is collected only when the Stream player is used. If you use a third party player, view metrics will not appear as part of these metrics.
Source: Fetching bulk analytics

I’m not sure which part of the metrics does this apply to. Of course, if my users would use another player I would still be billed for the minutes streamed but are the metrics collect so that I can query them with the API or how would could I get this information otherwise?

This example shows how to fetch analytics for all videos:

Couple of things to keep in mind:

  1. You will need to use Pagination (described on that page) if you have thousands of videos
  2. The GraphQL analytics retains analytics for 90 days

To answer your question about billing vs. viewer analytics, we bill based on videos delivered to the client (effectively this means we use server-side data for this.) This is not exposed in our analytics. Our analytics are purely based on client-side data and this is why it requires you to use our player.

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