YouTube data is available via the YouTube Analytics and Reporting API v.3. The process to access YouTube data is by far one of the easiest, but programming skills are required.
First, you will need to generate your API key to access data from within Python, R or your programming language of choice:
1. Login to your Google Account
2. Go to the Google Developers API Console page
3. Click on "+Enable APIs and Services"
4. Search and select the YouTube Data API v.3. Click to enable the API.
5. Go back to the homepage of your project by clicking the Google API logo at the top left. Then, click on the "Credentials" tab on the left side of the page.
6. Click on the blue "create credentials" button then select "API key". This will generate a YouTube API key, which you will need before creating your Oauth 2.0 client ID.
7. Next, click on the blue "create credentials" button again but this time select "OAuth client ID".
8. Complete the application page by selecting "other", adding a name and clicking "Create".
Congrats! You have generated your OAuth 2.0 client ID. You can always see it again by clicking the edit button on the credentials page. Since you are not requesting any user data, you will not need to complete the OAuth consent screen to submit further information to Google.
Now you have the information that you need to start calling the API from your programming language of choice. How do you get started with this?
9. YouTube has extensive documentation on how to pull data using the API along with a code generator to help you along the way. These resources are available for Python, Java and a number of other programming languages. For R users, you can try the tuber package.
In the future, DRI will try to upload sample code from our own analyses to help you get started with this step, so stay tuned!
Before going through all the steps to access YouTube data, what will you actually get?
You can search for collection of videos, channel and playlists that match the query parameters that you specify (e.g. keyword, location, etc). Based on this search, you can get number of metrics. YouTube provides an full description of what's available, here.
In more simple terms, you can get stats on on a specific videos including:
view count | like count | dislike count |
favorite count | comment count | video category |
video tags | video description | video title |
You can also find out more about a specific channel including:
channel title | number of view | number of subscribers |
number of videos | channel description | country |
view count | comment count | subscriber count |
video count |