Getting started with the Analytics API

Overview

The Bitmovin Analytics API lets us query for usage data of our videos. We can filter, aggregate and group data in the API request already, so we’re able to fetch precisely the data we need. In this section you’ll learn how to analyze the performance of your video platform and how to learn more about people watching your videos.

Installation

To get started, we need the Bitmovin API client. We’ll use the JavaScript client in all examples, but there are clients for several other languages as well. If you haven’t already, install the Bitmovin client:

Your first Query

The query builder provides us with a nice query interface. We always have to pass the time period we’re interested in. Here we use the first two weeks of the current month, but feel free to specify your own fromDate and toDate. Please just keep in mind that your data is only retained for 90 days.

We’ll use the queryBuilder, fromDate and toDate in most examples of this guide, so make sure they’re available in your code.

Let’s try running a query for the total number of video impressions:

1queryBuilder

2.count('IMPRESSION_ID')

3.between(fromDate, toDate)

4.query()

5.then(console.log);

If everything worked out, the number of video impressions in the given interval is printed to your console.

As you’ll learn in the following sections, the queryBuilder offers you several methods to filter, aggregate, group, sort and limit your data.

After you’ve composed your query, you call the query() method which submits the API request and returns a promise. This promise resolves when the API request finishes. In our case we want to log the result to the console, so we pass console.log as callback function to the then() method of the promise.