How to get YouTube transcripts and video stats in Google Sheets

Checked on 2026-11-18.

If your list of videos lives in a spreadsheet, the data can arrive there too. Two small custom functions turn a video link in one cell into its transcript, or into its title, views and likes, in the next ones.

1. Paste the script

In your sheet, open Extensions, then Apps Script. Replace what is in the editor with this and save.

JavaScript
const API = "https://pipefetch.com/v1/youtube";

function pipefetch_(path, video) {
  const key = PropertiesService.getScriptProperties().getProperty("PIPEFETCH_API_KEY");
  const res = UrlFetchApp.fetch(API + path + "?video=" + encodeURIComponent(video), {
    headers: { "x-api-key": key },
    muteHttpExceptions: true,
  });
  if (res.getResponseCode() === 404) return null;  // nothing to return; not charged
  const body = JSON.parse(res.getContentText());
  if (res.getResponseCode() !== 200) throw new Error(body.error.message);
  return body.data;
}

/** The transcript of a YouTube video. =YT_TRANSCRIPT(A2) */
function YT_TRANSCRIPT(video) {
  const data = pipefetch_("/transcript", video);
  if (!data) return "No captions";
  return data.text.slice(0, 50000);  // a cell holds 50,000 characters at most
}

/** Title, views, likes and comment count of a YouTube video, in four cells. =YT_STATS(A2) */
function YT_STATS(video) {
  const data = pipefetch_("/video", video);
  if (!data) return "Video not found";
  return [[data.title, data.viewCount, data.likeCount, data.commentCount]];
}

2. Store your API key

Do not type the key into the script or into a cell, where everyone with access to the sheet can read it. In the Apps Script editor open Project Settings (the gear icon), scroll to Script properties, and add a property named PIPEFETCH_API_KEY with your key as its value. You get a key, with 100 free credits, in the dashboard.

3. Use the functions

Put video links or IDs in column A, then:

Terminal
=YT_STATS(A2)        title, views, likes and comments, across four cells
=YT_TRANSCRIPT(A2)   the transcript as text

Drag the formula down to fill the column. Each cell is one request and takes a few seconds to fill.

The limits to know

  • Every cell costs a credit. A formula dragged over 500 rows is 500 requests. A video without captions costs nothing.
  • Freeze the results. Sheets runs a custom function again when its input changes. Once a column is filled, copy it and paste it back with Paste special, Values only, so nothing is fetched twice.
  • 30 seconds per cell. Google stops a custom function that runs longer. Requests here usually take 2 to 7 seconds, so this is rarely a problem; a cell that shows an error can be recalculated by re-entering the formula.
  • 50,000 characters per cell. That is roughly the transcript of a 50-minute talk. The script cuts longer transcripts at that length; for full text of long videos use the API from code instead.

More columns

The video answer has more fields than the four above: publish date, duration, description, tags and the channel's subscriber count. Add them to the list in YT_STATS; the reference names every field. The same pattern works for the other endpoints, such as a channel's latest uploads.

Try it with 100 free credits. No card, no Google Cloud project, no OAuth. Get an API key or read the docs.