YouTube Transcript API: Working Python, JavaScript & HTTP Code (Tested on Live Captions)
The shortest working YouTube transcript API path in 2026 is Python youtube-transcript-api v1.2.5: install via pip install youtube-transcript-api, then run YouTubeTranscriptApi().fetch('VIDEO_ID').to_raw_data() (the legacy static get_transcript() method was removed in v1.x). Do not use Google's official YouTube Data API v3 captions.download for third-party videos—it costs 200 quota units per call and returns 403 Forbidden unless you own the channel with OAuth 2.0 edit rights. Page scope: stay on this guide for runnable code, official API limits, and error debugging; if you do not want to write code or maintain residential proxies, connect directly to our hosted /mcp endpoint instead.
Tutorial vs. Hosted Product Scope: this guide walks through how YouTube transcript APIs work under the hood, gives you three runnable code snippets verified on live YouTube captions, and explains official quota limits and real runtime errors. If you just want a ready-to-use endpoint for Claude, Cursor, ChatGPT, or an HTTP client without maintaining libraries or proxy pools, head straight to our Hosted CleanTranscript MCP Server (/mcp).
Live-Tested Comparison: 3 Working Methods vs. Official API
Every open-source snippet below was installed and executed directly against a live public YouTube video on December 2, 2026. Notice that the two most popular libraries do not even agree on key names or timestamp units:
| Method | Verified Version | Auth / API Key | Returned Field Keys | Time Unit | Production Bottleneck |
|---|---|---|---|---|---|
Python youtube-transcript-api |
1.2.5 (Python 3.9+) |
None | text, start, duration |
Seconds (float) | Cloud datacenter IPs hit RequestBlocked / IpBlocked |
Node.js youtube-transcript |
1.3.1 (Node 22.22.2) |
None | text, offset, duration, lang |
Milliseconds (int) | Same IP rate limits; different schema from Python |
Hosted HTTP JSON-RPC (/mcp) |
Streamable HTTP (JSON-RPC 2.0) | None (public tier) | result.content[0].text |
Formatted [MM:SS] or plain |
Daily free miss cap (cached videos unlimited) |
| Official YouTube Data API v3 | REST v3 (captions.*) |
OAuth 2.0 (youtube.force-ssl) |
Metadata (list) / raw track (download) |
Track-dependent | 403 Forbidden on any channel you do not own; 200 units/download |
Method 1: youtube transcript api python (v1.2.5 Tested)
Most tutorials on Google still show the pre-1.0 static call YouTubeTranscriptApi.get_transcript(video_id). When tested on youtube-transcript-api==1.2.5, that legacy method no longer exists and immediately raises AttributeError: type object 'YouTubeTranscriptApi' has no attribute 'get_transcript'. In v1.x, you must instantiate YouTubeTranscriptApi() and call .fetch().
pip install youtube-transcript-api==1.2.5
from youtube_transcript_api import YouTubeTranscriptApi
api = YouTubeTranscriptApi()
fetched = api.fetch("VIDEO_ID", languages=["en"])
# fetched.snippets contains FetchedTranscriptSnippet objects
# Call .to_raw_data() for plain JSON-serializable dicts
rows = fetched.to_raw_data()
print(f"lang={fetched.language_code} generated={fetched.is_generated} rows={len(rows)}")
print(rows[0]) # {'text': '...', 'start': 1.36, 'duration': 1.68}
Verified local run output (v1.2.5): returned 61 FetchedTranscriptSnippet items with language_code='en', is_generated=False, and to_raw_data() keys ['text', 'start', 'duration'] in floating-point seconds. If you deploy this to AWS, GCP, or Vercel, pass proxy_config=WebshareProxyConfig(...) or GenericProxyConfig(...) to avoid cloud IP blocks—or skip writing code and maintaining proxies altogether by connecting to our ready-made CleanTranscript MCP endpoint (/mcp).
Method 2: youtube transcript api javascript (Node.js v22 + v1.3.1 Tested)
If your stack is Node.js or TypeScript, the youtube-transcript npm package (tested on v1.3.1 with Node v22.22.2) fetches public captions without an API key. Watch out for the schema mismatch if you port code from Python: Node returns offset instead of start, and both offset and duration are integers in milliseconds (1000x larger than Python's float seconds).
npm install youtube-transcript@1.3.1
const { YoutubeTranscript } = require("youtube-transcript");
async function main() {
const rows = await YoutubeTranscript.fetchTranscript("VIDEO_ID");
console.log("rows:", rows.length, "keys:", Object.keys(rows[0]));
// Example shape: { text: '...', duration: 1680, offset: 1360, lang: 'en' }
const plainText = rows.map((r) => r.text).join(" ");
console.log(plainText.slice(0, 200));
}
main().catch(console.error);
Verified local run output (Node v22.22.2 + v1.3.1): returned 61 objects with keys ['text', 'duration', 'offset', 'lang'], where the first cue's timing was offset: 1360, duration: 1680 (matching Python's 1.36s and 1.68s exactly once divided by 1000). Do not want to maintain a Node scraper or proxy rotation in production? Connect directly to our hosted CleanTranscript MCP API (/mcp).
Method 3: Hosted HTTP JSON-RPC 2.0 via curl (Zero Packages, Zero Proxies)
When running inside serverless functions, AI agents, or cloud containers where YouTube blocks datacenter IPs, calling a hosted Streamable HTTP endpoint avoids installing Python/Node dependencies and eliminates residential proxy maintenance. You can test CleanTranscript's JSON-RPC 2.0 endpoint directly with a single curl command:
curl -sS -X POST https://cleantranscript.com/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"get_youtube_transcript","arguments":{"url":"https://www.youtube.com/watch?v=VIDEO_ID","format":"plain","timestamps":true}}}'
Verified local run output: returned HTTP 200 JSON-RPC 2.0 payload with result.content[0].text containing clean header metadata, segment count, Cache: HIT edge caching status, and formatted [MM:SS] transcript lines ready for LLMs. Don't want to build or host your own extraction service? Copy the plug-and-play client config on our CleanTranscript MCP Server page (/mcp).
What the Official YouTube Data API v3 Can and Cannot Return
Developers routinely spend hours creating a Google Cloud project only to discover that the official YouTube Data API v3 cannot download transcripts from arbitrary public videos. According to Google's official YouTube Data API v3 documentation:
- What you CAN fetch (
captions.list— 50 quota units): Lists available caption track metadata (trackid,language,trackKind, andstatus) for a givenvideoId. It does not return the spoken transcript text itself. - What you CANNOT fetch for third-party videos (
captions.download— 200 quota units): Downloading the actual subtitle track requires OAuth 2.0 authorization (https://www.googleapis.com/auth/youtube.force-ssloryoutubepartner) and edit permission on the target video. Callingcaptions.downloadon someone else's public video returns403 Forbiddeneven with a valid OAuth token and unused quota. - Default daily quota math: Every Google Cloud project starts with 10,000 units per day. Even on your own channel, listing (50 units) plus downloading (200 units) burns 250 units per video—capping you at 40 videos/day before requesting a quota extension.
Common YouTube Transcript API Errors & Verified Root Causes
Every exception class below was verified against either our live local runs on youtube-transcript-api v1.2.5 or Google's official YouTube Data API v3 error specification:
| Exact Error / Status | Where It Happens | Root Cause | Concrete Fix |
|---|---|---|---|
AttributeError: ... no attribute 'get_transcript' |
Python v1.x (live-tested on v1.2.5) |
Running legacy pre-1.0 static snippet from outdated blog posts | Instantiate api = YouTubeTranscriptApi() and call api.fetch(video_id). |
RequestBlocked / IpBlocked |
Python v1.x / Node scrapers on cloud VMs |
YouTube blocks AWS, GCP, Azure, and DigitalOcean datacenter IP ranges | Route through rotating residential proxies or call our hosted /mcp endpoint. |
NoTranscriptFound |
Python v1.2.5 (live-tested with languages=['zz']) |
Requested language code does not exist in manual or auto-generated tracks | Call api.list(video_id) first to inspect available language codes before fetching. |
VideoUnavailable |
Python v1.2.5 (live-tested on invalid ID) |
Malformed 11-character ID, deleted video, private video, or region lock | Validate the 11-char ID regex and confirm the video opens in an incognito browser. |
TranscriptsDisabled |
Python / Node libraries | Creator disabled captions and no auto-caption track exists | No caption endpoint can read it; fall back to audio transcription or skip the video. |
403 Forbidden (captions.download) |
Official YouTube Data API v3 | Authenticated OAuth user does not own/manage the video, or missing youtube.force-ssl scope |
Use Data API v3 only for your own channels; use open-source or /mcp for public videos. |
Frequently Asked Questions
Why does youtube_transcript_api raise AttributeError for get_transcript()?
In youtube-transcript-api v1.0+ (verified on v1.2.5), the legacy static method YouTubeTranscriptApi.get_transcript() was removed. Instantiate YouTubeTranscriptApi() and call api.fetch(video_id) instead, then call .to_raw_data() if you need plain Python dictionaries.
Can the official youtube api transcript endpoint download captions for any public video?
No. In Google's YouTube Data API v3, captions.download costs 200 quota units and requires OAuth 2.0 edit permissions on the target video. Calling it on a third-party public video returns 403 Forbidden.
What is the shortest working youtube transcript api python snippet in 2026?
Install youtube-transcript-api==1.2.5, instantiate api = YouTubeTranscriptApi(), and run rows = api.fetch('VIDEO_ID').to_raw_data(). Each item contains text, start (seconds), and duration (seconds).
How does youtube api get transcript quota work compared to open-source libraries?
Google's official YouTube Data API v3 allocates 10,000 default quota units per day (50 units for captions.list, 200 units for captions.download) and only works on your own videos. Open-source libraries do not use Google API quotas, but they are subject to YouTube IP rate limits on cloud servers.
Where is the official youtube transcript api github repository and how do you avoid outdated forks?
The maintained Python package on PyPI is youtube-transcript-api (v1.2.5 at testing), which uses instance-based YouTubeTranscriptApi().fetch(). Always check that your installed version is >= 1.0 and avoid stale GitHub forks that still document the removed get_transcript() method.
How do you get youtube transcript api access without managing residential proxies on AWS or GCP?
Because YouTube blocks datacenter IPs with RequestBlocked and IpBlocked, serverless apps either pay for rotating residential proxies or call a hosted extraction API. You can call CleanTranscript's hosted JSON-RPC 2.0 endpoint at cleantranscript.com/mcp with zero proxy setup.
Can you use youtube api get video transcript calls on Shorts, live replays, or private videos?
Public YouTube Shorts and archived live replays work once YouTube finishes generating their caption track, using their standard 11-character video ID. Private, members-only, and caption-disabled videos cannot be read by public transcript endpoints.
How does youtube transcript api javascript output differ from Python?
In our live test, Node.js youtube-transcript v1.3.1 returned keys [text, duration, offset, lang] in integer milliseconds, whereas Python youtube-transcript-api v1.2.5 returned [text, start, duration] in floating-point seconds—a 1000x unit difference.
More CleanTranscript Guides
How to Turn a YouTube Lecture into Study Notes & Flashcards (Zero-Login Workflow)
Convert any YouTube university lecture into structured study notes, active-recall quizzes, and atomic Anki CSV flashcards with zero login. Includes our 4-step retention workflow, card audit table, and copy-paste CSV prompt.
Transcription & WorkflowsHow to Get a Transcription of a YouTube Video: Instant Caption Extraction vs. Speech-to-Text
Learn how to get a transcription of a YouTube video in seconds without re-transcribing audio, where YouTube hides the transcript button, how manual vs. auto tracks behave in live tests, and when you actually need audio speech-to-text.
Research & WorkflowsHow to Search Inside a Long YouTube Video Using Transcripts (Find Exact Quotes in Seconds)
Search inside any 1-to-4-hour YouTube video for an exact word or quote in seconds. Learn why Ctrl+F fails in YouTube's sidebar, how to filter full transcripts on desktop and mobile, and how to cite exact ?t= timestamps in APA and MLA.