Import YouTube API Data to Google Sheets

Import YouTube API Data to Google Sheets

Last Updated On August 16, 2019

In this guide, we’ll walk through how to pull data from the YouTube Data API directly into Google Sheets using the free API Connector add-on. 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


YouTube requires that all API requests contain an API key. This is the detailed, step-by-step process to get your YouTube API key:

  1. 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.
    youtube-api-img1
  2. Now in the top left, click Select a Project, which will open up a modal. Click New Project
    youtube-api-img2
  3. 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.
    youtube-api-img3
  4. Once you create your project, click on Credentials in the left-hand menu. Next, click the Create credentials dropdown and click ‘API key’.
    youtube-api-img4
  5. Your YouTube API key is now ready. You’ll see a screen containing your API key; copy this to your clipboard and click Close.
    youtube-api-img5
  6. 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:
    youtube-api-img6
  7. Congrats, you’re done! You now have access to the YouTube Data API, and can start pulling YouTube data into Google Sheets.

PART 2: CREATE YOUR API REQUEST URL


We’re going to follow the YouTube API documentation to search for specific types of videos using the “search” endpoint.

  • API root: https://www.googleapis.com/youtube/v3
  • Endpoint: /search
  • Parameters: ?part=snippet&key={API_key}
    Parameters Example: ?part=snippet&key=12345

Putting this all together, we get the full API Request URL:
https://www.googleapis.com/youtube/v3/search?part=snippet&key={API_key}

Where it says {API_key}, you’ll need to substitute your actual API key from part 1 (step 5) above.

PART 3: ENTER VALUES INTO API CONNECTOR


We’re now ready to enter all our values into API Connector to start importing YouTube data into Google Sheets:

  1. Open up Google Sheets and click Add-ons > API Connector > Create New API Request
  2. In the Create Request interface, enter the Request URL we just created:
    youtube-api-img8
  3. Leave Headers empty as we don’t need them for this request.
  4. 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.
    youtube-api-img9
  5. Name your request. Again we’ll call it ‘YouTube’
  6. Click Run and a moment later you’ll see some YouTube data populate the YouTube tab:
    youtube-api-img10

PART 4: NOTES AND EXPANSIONS

  1. 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’, so the full request URL would be https://www.googleapis.com/youtube/v3/search?part=snippet&key={API_key}&q=google sheets&maxResults=50
    youtube-api-img12

  2. To see a list of all the videos in a playlist, change the API URL path to https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&key={API_key}&playlistId={playlistId}
    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 list parameter .

Comments:0

Leave a Reply

Your email address will not be published.