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.
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
toDate. Please just keep in mind that your data is only retained for 90 days.
We’ll use the
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:
queryBuilder .count('IMPRESSION_ID') .between(fromDate, toDate) .query() .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.