Search, read, and manage YouTube videos, playlists, channels, subscriptions, and comments via managed OAuth.
Coding
youtube-apify-transcript
Try itFetch YouTube transcripts from cloud IPs without getting blocked by bot detection.
What it does
Fetches YouTube video transcripts through the Apify API, routing requests via residential proxies so cloud-hosted environments (AWS, GCP, Hetzner, etc.) can retrieve transcripts that YouTube's bot detection would otherwise block. Local caching makes repeat requests free, and a batch mode processes a list of URLs in one run. Supports plain-text and JSON output (with timestamps), a language preference flag, and an Apify free tier of $5/month (~714 videos) at $0.007 per uncached video.
When to use it
- Pulling transcripts from cloud or serverless environments
- Batch-fetching transcripts for a list of videos
- Avoiding repeat Apify charges via local cache
- Extracting timestamped JSON transcripts for downstream processing
The skill document
youtube-apify-transcript
Fetch YouTube transcripts via APIFY API (works from cloud IPs, bypasses YouTube bot detection).
Why APIFY?
YouTube blocks transcript requests from cloud IPs (AWS, GCP, etc.). APIFY runs the request through residential proxies, bypassing bot detection reliably.
Free Tier
- $5/month free credits (~714 videos)
- No credit card required
- Perfect for personal use
Cost
- $0.007 per video (less than 1 cent!)
- Track usage at: https://console.apify.com/billing
Links
Setup
- Create free APIFY account: https://apify.com/
- Get your API token: https://console.apify.com/account/integrations
- Set environment variable:
# Add to ~/.bashrc or ~/.zshrc
export APIFY_API_TOKEN="apify_api_YOUR_TOKEN_HERE"
# Install Python dependency
pip install requests
# Or use .env file (never commit this!)
echo 'APIFY_API_TOKEN=apify_api_YOUR_TOKEN_HERE' >> .env
Usage
Basic Usage
# Get transcript as text (uses cache by default)
python3 scripts/fetch_transcript.py "https://www.youtube.com/watch?v=VIDEO_ID"
# Short URL also works
python3 scripts/fetch_transcript.py "https://youtu.be/VIDEO_ID"
Options
# Output to file
python3 scripts/fetch_transcript.py "URL" --output transcript.txt
# JSON format (includes timestamps)
python3 scripts/fetch_transcript.py "URL" --json
# Both: JSON to file
python3 scripts/fetch_transcript.py "URL" --json --output transcript.json
# Specify language preference
python3 scripts/fetch_transcript.py "URL" --lang de
Caching (saves money!)
Transcripts are cached locally by default. Repeat requests for the same video cost $0.
# First request: fetches from APIFY ($0.007)
python3 scripts/fetch_transcript.py "URL"
# Second request: uses cache (FREE!)
python3 scripts/fetch_transcript.py "URL"
# Output: [cached] Transcript for: VIDEO_ID
# Bypass cache (force fresh fetch)
python3 scripts/fetch_transcript.py "URL" --no-cache
# View cache stats
python3 scripts/fetch_transcript.py --cache-stats
# Clear all cached transcripts
python3 scripts/fetch_transcript.py --clear-cache
Cache location: .cache/ in skill directory (override with YT_TRANSCRIPT_CACHE_DIR env var)
Batch Mode
Process multiple videos at once:
# Create a file with URLs (one per line)
cat > urls.txt << EOF
https://youtube.com/watch?v=VIDEO1
https://youtu.be/VIDEO2
https://youtube.com/watch?v=VIDEO3
EOF
# Process all URLs
python3 scripts/fetch_transcript.py --batch urls.txt
# Output:
# [1/3] Fetching VIDEO1...
# [2/3] [cached] VIDEO2
# [3/3] Fetching VIDEO3...
# Batch complete: 2 fetched, 1 cached, 0 failed
# [Cost: ~$0.014 for 2 API call(s)]
# Batch with JSON output to file
python3 scripts/fetch_transcript.py --batch urls.txt --json --output all_transcripts.json
Output Formats
Text (default):
Hello and welcome to this video.
Today we're going to talk about...
JSON (--json):
{
"video_id": "dQw4w9WgXcQ",
"title": "Video Title",
"transcript": [
{"start": 0.0, "duration": 2.5, "text": "Hello and welcome"},
{"start": 2.5, "duration": 3.0, "text": "to this video"}
],
"full_text": "Hello and welcome to this video..."
}
Agent Instructions
When the user asks to summarize a YouTube video, first fetch the transcript using the script, then summarize the transcript text directly using your own model capabilities. Do NOT use --summarize flag.
Error Handling
The script handles common errors:
- Invalid YouTube URL
- Video has no transcript
- API quota exceeded
- Network errors
Metadata
metadata:
clawdbot:
emoji: "📹"
requires:
env: ["APIFY_API_TOKEN"]
bins: ["python3"]
python:
packages: ["requests"]
Questions people ask
- Why route through Apify instead of calling YouTube directly?
- YouTube blocks transcript requests from cloud IPs. Apify runs the request through residential proxies, which bypasses that bot detection reliably from AWS, GCP, and similar providers.
- What does it cost to run?
- $0.007 per uncached video. New Apify accounts include $5/month in free credits, roughly 714 videos. Repeat requests for the same video are served from a local cache at no cost.
- What does it require to use?
- An Apify account with an API token exported as APIFY_API_TOKEN, Python 3 on the PATH, and the `requests` package. The script calls the topaz_sharingan/Youtube-Transcript-Scraper-1 Apify actor.
Related skills
Adaptive web scraping in Python that bypasses anti-bot systems and scales from single requests to concurrent crawls.
Join a video meeting as an AI bot with voice, avatar, and screenshare across four operating modes.
Post videos, photos, text, and documents to 10 social platforms through a single REST API call.
Query and manage Linear issues, projects, teams, cycles, labels, and comments through a managed OAuth GraphQL endpoint.
Stores durable facts in a categorized, plain-markdown vault on disk, alongside your agent's built-in memory.
More from robbyczgw-cla
Browse all skillsGenerate reflective AI diary entries with pattern tracking, quote logs, and weekly digests.
Continuously monitor topics across web search, RSS/Atom feeds, and GitHub releases, alerting only when relevant.
Synthesize speech in 18 voices across 32 languages, generate sound effects, and design custom voices via ElevenLabs.
Three specialized agents tackle your question in parallel and optionally cross-examine each other before synthesis.
Get three context-aware follow-up questions after any AI response, grouped into quick, deep-dive, and related.
Activate one of 20 built-in AI personas for coding, writing, fitness, and more.