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.
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:
=YT_STATS(A2) title, views, likes and comments, across four cells
=YT_TRANSCRIPT(A2) the transcript as textDrag 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.
APIs used in this guide
-
1 credit
YouTube Transcript API
The transcript of any public video with captions, as plain text, timestamped segments, SRT or WebVTT.
GET /v1/youtube/transcript -
1 credit
YouTube Video API
Exact views, likes and comment count, description, tags, chapters and channel for one video.
GET /v1/youtube/video
More guides
- How to get a YouTube transcript in Python
- How to get a YouTube transcript in Node.js
- YouTube API quota exceeded: what the error means and how to fix it
- How to find a YouTube channel ID from a handle or URL
- How to download YouTube subtitles as SRT or VTT
- youtube-transcript-api RequestBlocked or IpBlocked: why it happens and how to fix it
- How to get YouTube comments in Python
- How to search YouTube from Python
- How to list a YouTube channel's videos in Python
- How to summarize a YouTube video with an LLM in Python
- How to get YouTube video views and likes in Python
- How to get YouTube transcripts in n8n, Make and Zapier
- LangChain YoutubeLoader fails on a server: why, and a loader that works
- How to get a YouTube channel's subscriber count in Python
- How to give Claude or Cursor access to YouTube (MCP server)