GraphQL Analytics API
Stream provides analytics about both live video and video uploaded to Stream, via the GraphQL API described below, as well as in the Stream dashboard ↗.
The Stream Analytics API uses the Cloudflare GraphQL Analytics API, which can be used across many Cloudflare products. For more about GraphQL, rate limits, filters, and sorting, refer to the Cloudflare GraphQL Analytics API docs.
- Generate a Cloudflare API token ↗ with the Account Analytics permission.
- Use a GraphQL client of your choice to make your first query. Postman ↗ has a built-in GraphQL client which can help you run your first query and introspect the GraphQL schema to understand what is possible.
Refer to the sections below for available metrics, dimensions, fields, and example queries.
Stream collects data about the number of minutes of video delivered to viewers for all live and on-demand videos played via HLS or DASH, regardless of whether or not you use the Stream Player.
Field | Description |
---|---|
date | Date |
datetime | DateTime |
uid | UID of the video |
clientCountryName | ISO 3166 alpha2 country code from the client who viewed the video |
creator | The Creator ID associated with individual videos, if present |
Some filters, like date
, can be used with operators, such as gt
(greater than) and lt
(less than), as shown in the example query below. For more advanced filtering options, refer to filtering.
Node | Field | Description |
---|---|---|
streamMinutesViewedAdaptiveGroups | minutesViewed | Minutes of video delivered |
GraphQL API supports seek pagination: using filters, you can specify the last video UID so the response only includes data for videos after the last video UID.
The query below will return data for 2 videos that follow video UID 5646153f8dea17f44d542a42e76cfd
:
Here are the steps to implementing pagination:
- Call the first query without uid_gt filter to get the first set of videos
- Grab the last video UID from the response from the first query
- Call next query by specifying uid_gt property and set it to the last video UID. This will return the next set of videos
For more on pagination, refer to the Cloudflare GraphQL Analytics API docs.
- The maximum query interval in a single query is 31 days
- The maximum data retention period is 90 days