Getting the transcript of a YouTube video sounds like one function call. In practice the right tool depends on where your code runs, whether the video has captions at all, and whether a person or an AI agent is asking. This is a short guide to the options, with commands you can run today.
It is a companion to awesome-youtube-transcripts, a list we maintain of libraries, hosted APIs, MCP servers, agent skills and speech-to-text tools for YouTube transcripts.
Quick answer
| You want to | Start with |
|---|---|
| Fetch captions from a script on your own machine | youtube-transcript-api (Python) or YouTube.js (JavaScript) |
| Download subtitle files from the command line | yt-dlp |
| Transcribe a video that has no captions | faster-whisper or whisper.cpp on the audio |
| Fetch transcripts from a server or cloud function | A hosted API, or a library behind your own proxies |
| Let an AI assistant read YouTube videos | An MCP server or an agent skill |
1. A library, on your own machine
If you run code on a laptop or home connection, an open-source library is the simplest route.
Python: youtube-transcript-api. It reads manual and auto-generated captions, lists the languages a video offers, and can translate. Version 1.x uses an instance:
from youtube_transcript_api import YouTubeTranscriptApi
transcript = YouTubeTranscriptApi().fetch("dQw4w9WgXcQ", languages=["en"])
text = " ".join(snippet.text for snippet in transcript)
print(text[:200])
Each snippet also has start and duration in seconds if you need timestamps.
JavaScript: YouTube.js. A client for YouTube's internal InnerTube API; getTranscript() returns timed segments. There is a transcript example in the repo. If you want one function and nothing else, the youtube-transcript npm package has a single fetchTranscript() call, but it uses an unofficial endpoint and can break when YouTube changes.
2. yt-dlp, for subtitle files
yt-dlp can save captions without downloading the video:
yt-dlp --write-subs --write-auto-subs --sub-langs en --sub-format vtt \
--skip-download -o "%(id)s" "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
That writes dQw4w9WgXcQ.en.vtt. --write-subs takes uploaded captions, --write-auto-subs falls back to auto-generated ones, and the subtitle options section lists every format and language flag. It also handles whole playlists and channels.
3. Videos with no captions: speech-to-text
Some videos have captions turned off, or none were ever generated. Then you need the audio and a speech model:
- faster-whisper: Whisper on CTranslate2, several times faster than the original with lower memory use.
- whisper.cpp: Whisper in C/C++, runs on CPU and Apple Silicon.
- WhisperX: adds word-level timestamps and speaker diarization.
Download the audio with yt-dlp -x --audio-format m4a <url> and pass the file to the model. Expect this to take far longer than reading captions, and to cost GPU time at scale.
4. The cloud problem
Everything above works well from a home connection. Run the same code on AWS, GCP, Azure or most VPS providers and requests often fail with RequestBlocked or IpBlocked, because YouTube blocks many cloud IP ranges. The youtube-transcript-api README has a good explanation and proxy setup.
You have two choices:
- Keep the library and route it through residential or rotating proxies you manage.
- Use a hosted API that handles it for you.
Hosted options (all commercial; check each site for current pricing and limits):
- GetYouTubeTranscript: REST API and remote MCP server for transcripts, YouTube search, channels and playlists, with Python and Node SDKs. (Ours; see the disclosure below.)
- SearchAPI: a transcripts endpoint inside a general search API.
- Supadata: transcripts and metadata for YouTube, TikTok, Instagram, X and web pages.
- TranscriptAPI: YouTube transcripts, search, channels and playlists, with an MCP server.
- TranscriptOut: transcript API with agent skills and an MCP server.
- youtube-transcript.io: web tool and API.
A hosted call is one HTTP request. With ours, for example:
curl "https://getyoutubetranscript.com/api/v1/transcript?v=dQw4w9WgXcQ" \
-H "Authorization: Bearer $YOUTUBE_TRANSCRIPT_API_KEY"
When comparing services, test with your own videos: success rate on long videos, videos with only auto-generated captions, and non-English videos matters more than the headline price. We publish an open benchmark you can fork and point at any provider.
5. For AI assistants: MCP servers and agent skills
If the goal is "let Claude, Cursor or ChatGPT read this video", you don't need to write code at all.
MCP servers (Model Context Protocol) give an assistant a transcript tool:
- jkawamoto/mcp-youtube-transcript: runs locally, paginates long videos, supports proxy settings.
- anaisbetts/mcp-youtube: uses a local yt-dlp install.
- tubeagentkit/youtube-mcp: our hosted server (transcripts, search, channels, playlists), remote HTTP with OAuth sign-in or local stdio.
Local servers inherit the cloud problem only if your machine is in a data centre; on a laptop they work fine.
Agent skills are instruction folders that Claude Code, Cursor and Codex load when a task matches. tapestry-skills pulls transcripts as research sources, and youtube-to-ebook turns a channel's videos into an EPUB. The full list has more.
6. Framework integrations
If you already use a framework, there is probably a loader:
- LlamaIndex has a built-in YoutubeTranscriptReader.
- n8n, Haystack and Dify have community nodes and components, listed in the Framework integrations section.
Common errors
- Transcripts disabled: the uploader turned captions off. Only speech-to-text will help.
- No transcript in that language: ask for the languages the video offers first, then pick one.
- RequestBlocked / IpBlocked: you are on a cloud IP; see section 4.
- Works locally, fails in CI: same cause. CI runners are cloud machines.
We keep a longer error reference with what triggers each one.
Disclosure
We build GetYouTubeTranscript, so some tools above are ours. Competing tools are listed on the same terms, and if one is missing or described unfairly, open a PR on awesome-youtube-transcripts.
Top comments (0)