Use YouTube as a data source

Resources

Available in the Connector Gallery

Yes, click here to view the Connector Gallery.

API Documentation YouTube Analytics API
YouTube Data API

Authentication Method

OAuth Token Authentication
Response Format JSON
Sample YouTube Analytics Query

https://www.googleapis.com/youtube/analytics/v1/reports?ids=ChannelID&start-date={date.add(-30).format()}&end-date={date.today}&metrics=views,subscribersGained,subscribersLost&dimensions=day&sort=day

Step-by-Step

Creating a data source using YouTube

To create a data source using YouTube, you need to accomplish four tasks:

  • Find YouTube in the Connector Gallery
  • Authenticate with YouTube. 
  • Find your YouTube channel ID.
  • Write a query and enter it in Klipfolio. 

 

Find YouTube in the Connector Gallery

To create a data source using YouTube, go to the Connector Gallery page in Klipfolio and select YouTube.

What you need to connect to YouTube

1. Authenticate with YouTube

To connect your YouTube data, enter your Google username and password for the account that is connected to your YouTube channel.

2. Find a YouTube Channel ID

You have a few options for getting your channel ID:

  1. You can find your YouTube Channel ID in your advanced account settings page in YouTube.
  2. You can find another company's channel ID by going to the channel homepage and navigating up to the URL.


Write a query and enter it in Klipfolio

Here's a video on how to use the pre-built YouTube queries in the Connector Gallery:

Want to build your own YouTube query? Learn more about YouTube data requests

There are key elements in all data requests but each service has its own requirements. 

The key elements of YouTube queries are:

  • YouTube Analytics Base URL
  • Channel ID
  • Date Ranges
  • Metrics and Dimensions

For example:

https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel%3D%3DMINE&start-date={date.add(-30).format()}&end-date={date.today}&metrics=views,subscribersGained,subscribersLost&dimensions=day&sort=day

Let's break this query down and look at each part (by color):

YouTube Analytics Base URL

A base URL is the consistent part of your web address. Everything that follows it is known as parameters and usually begins with a question mark. The base URL for our example query is:

https://www.googleapis.com/youtube/analytics/v1/reports?

Channel ID

If you want data from the YouTube channel that you manage, you can either enter ids=channel%3D%3DMINE if you authenticated with the Google account that you manage. Or, you can enter your Channel ID or the Channel ID of another YouTube channel. See 0:01:21 min in the video above to learn where to find your Channel ID in YouTube.

Date Ranges

You can build a dynamic date range for your YouTube query that gives you rolling dates as the data source refreshes when you are logged into Klipfolio. In this example, our date range is the last 30 days from today.

start-date={date.add(-30).format()}&end-date={date.today}

Metrics and Dimensions

The YouTube Analytics API example query above uses metrics and dimensions to create useful reports. 

Metrics

Metrics are individual measurements of user activity, ad performance, or earnings. In our example, we are using the metrics 'Views', 'Subscribers Gained', and 'Subscribers Lost', but there are many more that you find in the YouTube Analytics API Documentation and use in your query.

Dimensions

Dimensions are common criteria that are used to aggregate data, such as the date on which user activity occurred or the country where users were located. In the example query above, we use the dimension 'day'.

Build it yourself!

Now that you know about the structure of a YouTube query, it's time to build your own! This is when API documentation becomes your friend. YouTube has a few different APIs, but there are many more that you find in the YouTube Analytics API Documentation to use in your query. But using the YouTube Analytics API Documentation is a great reference as you craft your own query.

Another YouTube API that can be useful for building visualizations is the YouTube Data API Documentation. You can use the YouTube Data API to retrieve and manipulate YouTube resources like videos, channels, and playlists.

Related Links