Tutorials · 3 min read

pichart of operating systems

api.video Analytics: Create a pie chart showing what operating system is most popular to view

Using D3, Observable, and Python, we'll create a pie chart showing what operating system is most popular to view video content with.

Erikka Innes

April 12, 2021

You can use api.video's analytics with Observable to create a lot of different charts. We've already made a choropleth, a map that shows viewer density by marker size, and now today we'll create a pie chart.


For this tutorial, you'll need:

  • api.video account - sign up here
  • Observable account - sign up here
  • Python installed with requests, pandas, csv
pichart of operating systems

Retrieve Your Data

To retrieve your data, you're going to authenticate with your api.video API key. Then when you have the token, you retrieve all live streams, VODs and the sessions associated with them. Before going into the code sample, if you want you can check out the API reference documentation for live streams here: Live streams


Create a DataFrame with Your CSV File

With this code snippet, we'll create a dataframe, and drop information down to only what we'll need for our pie chart. The other information was included for reference, and in case you want to do something else with this subset of data.


The code sample assumes your csv file is in the same folder as your code.

Now we're ready to build our map in Observable.

Configure Observable

In this section, we walk through how to get your pie chart set up on Observable. If you haven't done so, sign up for an Observable account. Then do the following:

  1. Navigate to our Observable notebook Pie Chart for api.video Analytics Data.
  2. Click the three dots in the upper right corner. A menu opens.
  3. From the menu, choose Fork. Now you have your own copy of the map to edit and play around with.
  4. Click the three dots in the upper right corner again and choose File attachments.
  5. Add the csv file you made using the pandas code.

Everything should work. You might find that the count for each operating system doesn't show, or the operating system name doesn't show if the pie slice would be too small. You can tweak the titles in the CSV to make them shorter, leave it, or you can try a Donut Chart to see if that looks better.

There's lots of things you can learn from your data.

donut chart operating systems

Analyzing Your Data

You can analyze your data many ways. For our example, because this is an api.video account, we might use this data a few different ways. We might assume that creating content suited to Mac and Linux is ideal, because half of our viewers are looking at demos from platforms that are Mac or Linux related. But, we might also make a choice to create more Windows focused content, because we have a lot of viewers from Windows operating systems.

If we were building demos for mobile, this pie chart might indicate that Android demos would be more popular than iOS.

Another way to interpret the data would be that we have less viewers from certain platforms because we don't target their use cases in our demos as much. With trial and error, we could use this data to make some educated guesses, tweak our content strategy and then come back and check the data.

You could also combine this information with details about what country a viewer is from, and then figure out if certain regions have platform preferences.

Have fun playing around with your data!

Try out more than 80 features for free

Access all the features for as long as you need.
No commitment or credit card required

Video API, simplified

Fully customizable API to manage everything video. From encoding to delivery, in minutes.

Built for Speed

The fastest video encoding platform. Serve your users globally with 140+ points of presence. 

Let end-users upload videos

Finally, an API that allows your end-users to upload videos and start live streams in a few clicks.


Volume discounts and usage-based pricing to ensure you don’t exceed your budget.