Skip to main content

Get viewer engagement

This guide provides information about registering and retrieving views from a video using the dashboard or the Livepeer player API.

Register views

To collect and register viewership metrics, you need to configure your player. Currently the viewership data is only registered if you're using the Livepeer player. It also comes fully configured for the best playback experience with Livepeer, so it's the recommended way to get started. You can follow this guide to setup the Livepeer player.

We are currently working on support for viewership data using custom players as well. If you need any urgent help with this get in touch and we may be able to assist you.

Retrieve viewership metrics

Caveats

The viewership API is still in development. Currently, we only support start views, views when you open or start watching an asset. In the future, we'll support additional viewership and engagement metrics so you can understand your user's experience.

The Livepeer API allows you to send video files to Livepeer and get them ready for optimized playback. Videos can be provided either by you (static content) or your users, given your application offers an interface for them to do so.

Step 1: Get the asset.id of an existing asset

Get the asset.id of an existing asset. An asset.id can be found in the response object of any API call working with assets. If you haven't created an asset yet, you can follow the upload a video asset guide to do so.

Step 2: Retrieve viewership data

Once you have the asset.id, you can make a request to get the viewership data.

const getViews = await fetch(
"https://livepeer.studio/api/data/views/{assetId}/total",
{
method: "GET",
headers: {
Authorization: `Bearer ${process.env.API_TOKEN}`,
},
}
);