Import YouTube API Data to Google Sheets
In this guide, we’ll walk through how to pull data from the YouTube Data API directly into Google Sheets using the API Connector add-on for Sheets. We’ll first get an API key from YouTube, and then set up a request to pull in video details and metrics from YouTube to your spreadsheet.
- Part 1: Get your YouTube Data API Key
- Part 2: Create your API Request URL
- Part 3: Pull YouTube API Data into Sheets
- Part 4: YouTube API Notes
YouTube requires that all API requests contain an API key. This is the detailed, step-by-step process to get your YouTube API key:
- Navigate to https://console.developers.google.com/. If this is your first time accessing this page, you’ll be prompted to accept Google Cloud Platform’s terms of service. Click agree and continue.
- Now in the top left, click Select a Project, which will open up a modal. Click New Project
- This will open up the New Project modal. You can name your project anything, but let’s call it YouTube API. You’ll also be prompted to browse for a Location (aka folder). For our purposes here, it doesn’t matter which one you pick.
- Once you create your project, click on Credentials in the left-hand menu. Next, click the Create credentials dropdown and click ‘API key’.
- Your YouTube API key is now ready. You’ll see a screen containing your API key; copy this to your clipboard and click Close.
- There’s still one last step: you need to enable the YouTube API in your project. To do this, click Library and search for ‘YouTube Data API’. Alternately, you can navigate there directly with this link: https://console.developers.google.com/apis/library/youtube.googleapis.com. Click Enable as shown:
- Congrats, you’re done! You now have access to the YouTube Data API, and can start pulling YouTube data into Google Sheets.
- API root: https://www.googleapis.com/youtube/v3
- Endpoint: /search
- Parameters: ?part=snippet&key=YOUR_API_KEY
Parameters Example: ?part=snippet&key=12345
Putting this all together, we get the full API Request URL:
Where it says YOUR_API_KEY, you’ll need to substitute your actual API key from part 1 (step 5) above.
We’re now ready to enter all our values into API Connector and import YouTube data into Google Sheets:
- Open up Google Sheets and click Add-ons > API Connector > Create New API Request
- In the Create Request interface, enter the Request URL we just created:
- Leave Headers empty as we don’t need them for this request.
- Create a new tab. You can call it whatever you like, but here we’ll call it ‘YouTube’. While still in that tab, click ‘Set’ to use that tab as your data destination.
- Name your request. Again we’ll call it ‘YouTube’
- Click Run and a moment later you’ll see some YouTube data populate the YouTube tab:
- Now that the basic Request URL is set up, you can modify it using parameters listed in the documentation. For example, you may want to change the number of results to 50 (default is 5) and search for videos related to a specific query string, say ‘google sheets’. You’d do that using the parameters ‘maxResults’ and ‘q’, creating the following request URL:
- To see a list of all the videos in a playlist, change the API URL path to include the playlistId parameter:
You can find your playlist ID by clicking into a YouTube video in your playlist and checking the URL. It will be located inside the
- To see statistics like views and subscribers for your own channel (or any public channel), you can use the following URL. Substitute in your own channel ID, which you can get in YouTube by clicking on your photo in the top right corner, then Settings > Advanced Settings > Channel ID:
- You can filter your results using the “fields” parameter as described here: https://developers.google.com/youtube/v3/getting-started. For example: