Pulling a whole YouTube channel's transcripts without getting blocked halfway
By Hayden Barnett · · 5 min read
- YouTube
- Transcripts
- MCP
- Claude Code
The job looks simple. Every Monday, take one YouTube channel, grab its last 50 videos, pull the captions, and have a model write a digest. On your laptop it works. You move it to a VPS or a serverless function, schedule it, and the next Monday it falls over around video 20 with something like this:
ERROR: [youtube] <video id>: Sign in to confirm you're not a bot. Use --cookies-from-browser or --cookies for the authentication.
or, from the caption fetch itself:
WARNING: Unable to download video subtitles for 'en': HTTP Error 429: Too Many Requests
The first 19 transcripts came back fine, so it’s tempting to blame the code. It isn’t the code. YouTube treats traffic from datacenter IP ranges (AWS, GCP, Azure, most VPS providers) with much less patience than traffic from a home connection. A run of back-to-back watch-page and caption requests from one cloud IP trips a rate limit or a bot check, and once it trips, every request from that IP fails for a while. Retrying immediately makes it worse.
The usual fixes all have a cost:
- Sleeping between videos helps a little, but a 50-video job now takes an hour and still fails on a bad day.
- Passing browser cookies ties the job to a logged-in Google account. Cookies expire, and an account that pulls captions in bulk can get flagged.
- Rotating proxies works, but now you’re running a proxy pool, paying for bandwidth, and debugging which exit node got burned.
If what you want is the transcript and not a hobby in anti-bot engineering, move the fetching behind an API and keep your job focused on the digest. Here’s how to do that with Fetchproof, first with curl and then from Claude Code over MCP.
Step 1: list the channel’s videos
One call returns a page of a channel’s uploads, newest first, 30 per page. Pass the handle with or without the @, or a channelId:
export FETCHPROOF_API_KEY=fp_your_key
CHANNEL='your_channel_handle'
curl -s "https://api.fetchproof.com/v1/youtube/channel-videos?handle=${CHANNEL}&sort=latest" \
--header "x-api-key: $FETCHPROOF_API_KEY"
The response has this shape (values trimmed; the field names and types are from a real response):
{
"success": true,
"credits_remaining": 99,
"credits_charged": 1,
"videos": [
{
"type": "video",
"id": "<video id>",
"url": "https://www.youtube.com/watch?v=<video id>",
"title": "<video title>",
"description": null,
"thumbnail": "https://i.ytimg.com/vi/<video id>/hq720.jpg?...",
"channel": null,
"viewCountText": "80K",
"viewCountInt": 80000,
"publishedTimeText": "7d ago",
"publishedTime": null,
"lengthText": "1:27",
"lengthSeconds": 87
}
],
"continuationToken": "4qmFsgLZCRIYVUNM..."
}
For 50 videos you need two pages. Send the same handle plus the continuationToken from the first response. The token is long and already contains percent-escapes, so let curl encode it rather than pasting it into the URL:
curl -s -G "https://api.fetchproof.com/v1/youtube/channel-videos?handle=${CHANNEL}" \
--data-urlencode "continuationToken=$TOKEN" \
--header "x-api-key: $FETCHPROOF_API_KEY"
Two things in that listing trip people up. publishedTime is often null on the listing and you get publishedTimeText (“7d ago”) instead, which is relative to when you fetched it. If your digest needs exact dates, look the video up with /v1/youtube/video, which returns publishDate. And description is null on the listing; the listing is for ids, titles, views and length.
Step 2: pull each transcript
The transcript call takes the video URL:
curl -s "https://api.fetchproof.com/v1/youtube/video/transcript?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D${VIDEO_ID}&language=en" \
--header "x-api-key: $FETCHPROOF_API_KEY"
{
"success": true,
"credits_remaining": 98,
"credits_charged": 1,
"videoId": "<video id>",
"type": "manual",
"url": "https://www.youtube.com/watch?v=<video id>",
"transcript": [
{ "text": "<caption line>", "startMs": "18640", "endMs": "21880", "startTimeText": "0:18" },
{ "text": "<caption line>", "startMs": "22640", "endMs": "26960", "startTimeText": "0:22" }
],
"transcript_only_text": "<every caption line joined with spaces>",
"language": "en"
}
Notes from running this in a loop:
typeismanualfor creator-uploaded captions andauto-generatedfor YouTube’s speech recognition. Auto captions have no punctuation to speak of, so tell the model that in your digest prompt.startMsandendMsare strings, not numbers. Parse them before you do arithmetic.transcript_only_textis what you feed a model. Keeptranscriptif you want to cite timestamps in the digest (“at 4:12 they cover…”).- Leave
languageoff to get YouTube’s default track. Setoriginal_audio=trueif you want the video’s original-language captions and nothing else.
The whole job in one script
This is the 50-video digest loop: list two pages, then fetch transcripts one at a time and skip anything without captions.
#!/usr/bin/env bash
set -euo pipefail
API=https://api.fetchproof.com
H="x-api-key: $FETCHPROOF_API_KEY"
CHANNEL='your_channel_handle'
mkdir -p out
page1=$(curl -sf "$API/v1/youtube/channel-videos?handle=${CHANNEL}&sort=latest" -H "$H")
token=$(jq -r '.continuationToken // empty' <<<"$page1")
page2=$(curl -sf -G "$API/v1/youtube/channel-videos?handle=${CHANNEL}" \
--data-urlencode "continuationToken=$token" -H "$H")
jq -r '.videos[].url' <<<"$page1" > urls.txt
jq -r '.videos[].url' <<<"$page2" >> urls.txt
head -n 50 urls.txt > batch.txt
while read -r url; do
id=${url##*v=}
curl -s -G "$API/v1/youtube/video/transcript" -H "$H" \
--data-urlencode "url=$url" -o "out/$id.json" -w "%{http_code} $id\n"
done < batch.txt
The loop is sequential on purpose. You don’t need parallelism to finish 50 videos, and it keeps your own retries simple: if a line prints anything other than 200, run that id again later.
Same thing from Claude Code over MCP
If the digest is written by an agent, skip the script and give the agent the tools. The @fetchproof/mcp package is a stdio MCP server with one tool per API operation. Add it to Claude Code with your key in the environment:
claude mcp add --transport stdio --env FETCHPROOF_API_KEY=fp_your_key fetchproof -- npx -y @fetchproof/mcp
Run /mcp inside Claude Code to check it connected. The two tools this job uses are youtube_channel_videos and youtube_video_transcript. Then ask for the work in plain terms:
Use youtube_channel_videos to list the latest 50 uploads from the channel
your_channel_handle (follow continuationToken for the second page). For each
video, call youtube_video_transcript with its url. Skip videos where the
transcript is null. Then write a digest: one paragraph per video with the
main claim and a timestamp from the transcript.
Each tool call is a normal API request with the same cost as the curl version. Every tool description includes that operation’s credit cost, so the agent can see that a missing transcript costs nothing before it decides to retry.
What it costs, and what still fails
Each call costs 1 credit by default. The 50-video digest above is 2 listing calls plus up to 50 transcript calls, so at most 52 credits. A video with no captions in the language you asked for returns "transcript": null and costs 0 credits; that’s this operation’s published cost. More generally: Errors, blocked or timed-out requests, invalid requests and cache hits cost nothing. A not-found or empty result is charged only where that operation’s published cost says so.
New accounts get 100 free credits, which covers one full 50-video run with room to test. Pack sizes and prices are on the pricing page.
Be honest with yourself about what this doesn’t fix:
- YouTube still says no sometimes. Moving the fetch behind an API means you’re not burning your own IP, but a request can still be refused upstream. When YouTube withholds a caption body you get a 502 and no charge. Retry that video later instead of hammering it.
- No captions means no transcript. This reads the captions YouTube publishes, manual or auto-generated. It doesn’t run speech-to-text on the audio. Music videos, some Shorts and brand-new uploads often have nothing yet.
- Age-restricted and private videos return an error (403 for an upstream denial). There’s no logged-in path here.
- Re-runs can be free. If your digest job re-reads videos it already fetched this week, add
cache_max_age=7dto the transcript call. A cached response within that window costs 0 credits. Leave it off when you need a fresh read.
Trying it before writing code
The free YouTube transcript tool runs the same endpoint in the browser on one URL, which is a quick way to check whether a given video has captions at all. If you’d rather not run a script anywhere, the YouTube Transcript Actor on Apify takes a list of up to 50 URLs per run and calls the same endpoint.
For the full parameter list, see the transcript endpoint reference and the MCP setup docs.
Related guides and endpoints
- Guide How to get YouTube transcripts with an API Get captions from any public YouTube video or Short as timed segments and plain text, with no YouTube API key or OAuth. 1 credit, 0 if none exists.
- Endpoint YouTube Channel Videos GET /v1/youtube/channel-videos
- Endpoint YouTube Transcript GET /v1/youtube/video/transcript
- API YouTube API All 18 YouTube endpoints, with costs and sample responses.
Try it with 100 free credits
Sign up with an email address, no card. Credits never expire. Errors, invalid requests and cache hits cost 0 credits, and each endpoint page lists exactly what it charges.