« YouTube Data Scraper

How to Get a YouTube API Key

Sign Up to Scrape YouTube Data

Steve Spagnola
Written by Steve Spagnola
Last updated April 13, 2024

Generate a YouTube API Key

If you’re using the YouTube Data API to scrape public YouTube data (like comments, video statistics, search results, etc…), then you’ll need a YouTube API Key in order to access the API and scrape the YouTube data you need.

6om_Sn547q8 ▶️

We’ll walk you through how to create a new YouTube API Key (all you need is a Google Account), how to secure it, and how to access it in the future. Either read the steps below, or watch the above video to get started.

1. Head to the Google Cloud

First, head to the YouTube Data API Credentials Section within the Google Cloud Platform.

Simply log in with your Google account if prompted. If you are brand new to Google Cloud, then don’t worry - you’ll be asked to accept their terms of service in the popup below and you can then get started:

Welcome to the Google Cloud Platform

2. Create a Project

The Google Cloud is organized around “projects,” so you’ll need to make a new one in order to get a YouTube API Key. Simply click the Create Project button below:

Click Create Project

Now pick a name for your new project, here we chose YouTube Data API Scraper:

Name Your New Project

Once you’re done, you should see something like this with the name of your project in the top blue bar. Make sure the left side says “YouTube Data API” as in the screenshot below. If not, just navigate back to the YouTube Data API Credentials Section and you should see it:

New Project YouTube Data API

3. Create Credentials

We’ll now create a YouTube API Key for our new project. Simply select the Create Credentials and then select API key from the dropdown:

Select Create Credentials and then API key

4. Copy Your Key

Now on the next screen, you’ll see your YouTube API Key in a popup that you can copy (store this in a safe place like a password manager that only you have access to):

Copy your API key

You’ll also see your new YouTube API Key generated under the “API Keys” section of the page (if you need to access it later). Click the “copy” icon to the right of the “Key” and you’ll copy the key to your clipboard:

Copy your API key

5. Enable the YouTube Data API

One more step before the API Key will actually work - we need to enable the project to use the YouTube Data API! Simply follow this link to Enable the YouTube Data API and you’ll see a screen to Enable to API (just verify the proper project is selected above on the blue bar):

Enable YouTube Data API

6. Restrict API Key Usage

You may have noticed a little warning triangle to the left of the API key name with the following warning:

API Key Unrestricted Warning

This means that if anyone else were to obtain your API Key, they could use it to access any enabled service on your Google Cloud project (not just public YouTube data). To fix this, click Edit settings on the popup and we’ll set some “API restrictions” - scroll to that section and click Restrict key:

Click Restrict key

Now select the YouTube Data API v3 from the dropdown and click Save:

Restrict this key to the YouTube Data API

Hooray! The annoying warning triangle went away and we can sleep at night!

No more warning triangle

Obtain an Existing YouTube API Key

If you already created a YouTube API Key and need to obtain it, simply head to the YouTube Data API Credentials Section and you should see it under “API Keys” where you can simply copy the value:

Copy your API key

If you don’t see the key there, you may need to switch projects to a project that does have an API key. Simply click the “down arrow” next to the current project to select a new project, or create a new project if needed:

Select a new or different project if needed

Note, that if you don’t use your API key for a while (like 60 days), YouTube may revoke it and you won’t be able to use the API key in that project again - you’ll see a weird error about exceeding your quota. To get around this, simply create a new project and repeat the steps above in part I.

Using Your YouTube API Key

Congratulations! Now that you have a YouTube API Key, you can use it to scrape public YouTube data! If you’re accessing the YouTube Data API directly, just provide this value as the key GET parameter in your HTTP requests.

You can also use the Stevesie Data Platform to scrape YouTube data as CSV files. Simply head to the YouTube Search Integration (or any other endpoint) and paste in your API key:

Paste in API key

Execute the endpoint and you’ll see up to 50 results that you can now download with your new API key!

Download Scraped YouTube data

You may see an error message that says “If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.” - this is normal, simply wait a few more minutes and try again or review the error message for help from Google.

Sign Up to Scrape YouTube Data