YouTube Transcript API: How to Get YouTube Captions Programmatically (and the No-Code Alternative)
Learn how to access YouTube transcripts via API or the unofficial Python library — and discover the free no-code alternative that works in seconds.
Get any YouTube transcript instantly — free
No signup · No extension · Copy or download as TXT, DOCX, PDF
Getting a YouTube transcript programmatically comes up in a lot of workflows: building a content pipeline, training an AI model on video data, automating note-taking, or extracting captions for accessibility. This guide covers all your options — from the official API to unofficial libraries to a completely no-code alternative.
The Three Ways to Get YouTube Transcripts
- Official YouTube Data API v3 — requires OAuth, works for your own videos
- youtube-transcript-api (Python) — unofficial, no API key, works on public videos with captions
- YTTranscript — no-code web tool, paste URL, get transcript instantly
Let's go through each.
Option 1: The Official YouTube Data API v3
Google's YouTube Data API v3 includes caption endpoints — captions.list and captions.download — but there's an important limitation: they require OAuth 2.0 authentication, which means the request must be authorized by the video owner.
This makes the official API suitable for accessing captions on your own channel's videos, but not for fetching auto-generated captions on arbitrary public videos.
Setup
- Go to Google Cloud Console
- Create a project and enable the YouTube Data API v3
- Generate OAuth 2.0 credentials (not just an API key)
- Use the credentials to authenticate your app
List captions for a video
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
SCOPES = ['https://www.googleapis.com/auth/youtube.force-ssl']
flow = InstalledAppFlow.from_client_secrets_file('client_secrets.json', SCOPES)
credentials = flow.run_local_server()
youtube = build('youtube', 'v3', credentials=credentials)
captions = youtube.captions().list(
part='snippet',
videoId='dQw4w9WgXcQ'
).execute()
for item in captions['items']:
print(item['id'], item['snippet']['language'])
Download a caption track
caption_id = captions['items'][0]['id']
subtitle = youtube.captions().download(
id=caption_id,
tfmt='srt' # or 'vtt'
).execute()
print(subtitle.decode('utf-8'))
Bottom line: great for your own videos, complex OAuth setup required, won't work on arbitrary public videos.
YTTranscript extracts captions from any public YouTube video instantly — no API key, no account, works in your browser right now.
Option 2: youtube-transcript-api (Python — Recommended for Most Use Cases)
The youtube-transcript-api library is an unofficial but widely used Python package that fetches publicly available captions from YouTube — including auto-generated captions — without requiring any API key or OAuth setup.
Installation
pip install youtube-transcript-api
Basic usage
from youtube_transcript_api import YouTubeTranscriptApi
video_id = 'dQw4w9WgXcQ' # just the ID, not the full URL
transcript = YouTubeTranscriptApi.get_transcript(video_id)
for segment in transcript:
print(f"{segment['start']:.1f}s: {segment['text']}")
Output:
0.0s: Never gonna give you up
3.6s: Never gonna let you down
7.2s: Never gonna run around and desert you
Get a plain text transcript (no timestamps)
text = ' '.join([seg['text'] for seg in transcript])
print(text)
Fetch in a specific language
transcript = YouTubeTranscriptApi.get_transcript(video_id, languages=['es', 'en'])
List available languages
transcript_list = YouTubeTranscriptApi.list_transcripts(video_id)
for t in transcript_list:
print(t.language, t.language_code, 'auto' if t.is_generated else 'manual')
Batch multiple videos
video_ids = ['VIDEO_ID_1', 'VIDEO_ID_2', 'VIDEO_ID_3']
for vid in video_ids:
try:
t = YouTubeTranscriptApi.get_transcript(vid)
full_text = ' '.join([s['text'] for s in t])
print(f"{vid}: {full_text[:100]}...")
except Exception as e:
print(f"{vid}: failed — {e}")
Limitations to know
- Only works on videos with captions enabled (auto-generated or manual)
- YouTube may block requests if you're making too many in a short time
- The library may break if YouTube changes its internal endpoints (it has good community maintenance though)
- Won't work on private or age-restricted videos
Option 3: YTTranscript — No Code Required
If you don't need to process transcripts programmatically and just want the text, YTTranscript is the fastest path:
- Go to yttranscript.app
- Paste any YouTube URL
- Copy the transcript or download as TXT, DOCX, or PDF
No API key, no pip install, no OAuth, no account. Works in any browser.
This is ideal for one-off tasks: summarizing a video with ChatGPT, pasting a lecture into your notes app, extracting a quote, or checking a video's content before committing to watch it.
Try YTTranscript free — paste any YouTube URL and get the full text in seconds. No code, no account, no extension.
Comparison: Which Approach Should You Use?
| | Official API | youtube-transcript-api | YTTranscript | |---|---|---|---| | Setup time | 30–60 min | 2 min | 0 min | | API key required | Yes (OAuth) | No | No | | Works on any public video | No | Yes | Yes | | Language selection | Yes | Yes | Auto-detected | | Timestamps | Yes | Yes | Optional | | Batch processing | Yes | Yes | No | | File download | No | Manual | TXT, DOCX, PDF | | Cost | Free quota | Free | Free | | Best for | Your own channel | Developers / automation | One-off tasks |
Common Use Cases
Building a content pipeline? Use youtube-transcript-api to batch-fetch transcripts and feed them into a database or text processing pipeline.
Training an LLM or fine-tuning a model? Use the Python library to pull transcripts at scale from YouTube playlists or search results.
Summarizing a single video with ChatGPT? Use YTTranscript — copy the transcript, paste into ChatGPT, ask for a summary. Done in 30 seconds.
Making your own videos searchable? Use the official API with OAuth — you're the owner, so authentication is straightforward.
Related Guides
Ready to get your YouTube transcript?
YTTranscript is completely free — paste any YouTube URL and get the full text in seconds. No account, no extension, no limits.
Get YouTube Transcript Free →