Mass Scrape Keywords from Youtube Videos using Google Sheet

And we are back with another amazing Google Sheet tutorial. This time I am going to share this Google Sheet Script that Bulk Scrape Keywords from any Youtube Video using only your Google Sheet.

In the past tutorials we have shown you how to scrape all the videos from a Youtube Channel, and this time we are going to scrape the keywords from those videos of course using a google sheet script and Youtube API.

PART 1: Get your Youtube V3 API

All of our Youtube Script tutorials involve having an Youtube API we keep it this way to keep our script clean and follows Youtube terms of use.

  • Go to your Project Dashboard, in the left side menu, find and click the API’s and Services > Library
  • Search and find “Youtube V3“. Click and “Enable” it.
  • Next, is Go to the left side menu and click “Credentials” > “Create Credentials” and choose “API Key
  • Next, is copy the generated API key to our script.

PART 2: Enter Our Script to your Google Sheet Script panel

Next part, is to copy script below replacing the YOUR_API_KEY with your own generated API Key in the Part 1.

  • Open up your Google Sheet and create “New Sheet” on the Top menu go to “Extensions” and then “App Scripts” and then Paste the code below.
function getVideoTags() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  var range = sheet.getDataRange();
  var values = range.getValues();

  for (var i = 1; i < values.length; i++) {
    var videoUrl = values[i][0];
    if (videoUrl) {
      var videoId = extractVideoId(videoUrl);
      if (videoId) {
        var tags = getTagsForVideo(videoId);
        sheet.getRange(i + 1, 2).setValue(tags ? tags.join(", ") : "This video has no keywords");

function extractVideoId(url) {
  var match = url.match(/(?:https?:\/\/)?(?:www\.)?youtube\.com\/watch\?v=([^&]+)/);
  return match ? match[1] : null;

function getTagsForVideo(videoId) {
  var apiKey = 'YOUR_API_KEY'; // Replace with your API key
  var url = '' + videoId + '&key=' + apiKey + '&part=snippet';
  try {
    var response = UrlFetchApp.fetch(url);
    var json = JSON.parse(response.getContentText());
    if (json.items.length > 0 && json.items[0].snippet && json.items[0].snippet.tags) {
      return json.items[0].snippet.tags;
    } else {
      return null; // Video has no keywords or not found
  } catch (e) {
    Logger.log('Error retrieving tags for video ID ' + videoId + ': ' + e.toString());
    return null; // Error occurred
  • Gather Your Video links and paste it in the Column A of your sheet.
  • Save and Run the script. The first time you will run the script you will be ask to “Review Permissions“. You need to “Allow” it to run.
  • Next, check your Sheet to see the list of the keywords in the Column B.

Note that some video publishers do not add keywords on their videos, so you wont see keywords being propagated and you will see “This video has no keywords” instead.

Here’s a video Tutorial

Special thanks to our user EvergreenSEO for providing the question and so we created a script for it!

That’s all for today, thanks for coming by. Don’t forget to share to your friends on social media if you find this tutorial useful.

Leave a Comment