YouTube Transcript Python SDK β Official PyPI Package
Extract YouTube transcripts in your Python applications. Install from PyPI, authenticate with your API key, and integrate transcript extraction into your data pipelines, research tools, and automation scripts.
INSTALLATION
pip install youtubetranscriptdevapi
QUICK START
from youtubetranscript import YouTubeTranscript
yt = YouTubeTranscript("your_api_key")
result = yt.transcribe("dQw4w9WgXcQ")
print(f"Segments: {len(result.segments)}")
print(f"Duration: {result.duration:.0f}s")
print(f"Words: {result.word_count}")
for seg in result.segments[:5]:
print(f"[{seg.start_formatted}] {seg.text}")FEATURES
# Translate to any language
result = yt.transcribe("dQw4w9WgXcQ", language="es")
# Choose caption source
result = yt.transcribe("dQw4w9WgXcQ", source="manual")
# Format options
result = yt.transcribe("dQw4w9WgXcQ", format={"timestamp": True, "words": True})batch = yt.batch(["video1", "video2", "video3"])
for t in batch.completed:
print(f"{t.video_id}: {t.word_count} words")job = yt.transcribe_asr("video_without_captions")
result = yt.wait_for_job(job.job_id) # polls until complete
print(result.text)print(result.to_srt()) # SRT subtitles print(result.to_vtt()) # WebVTT subtitles print(result.to_plain_text()) # Plain text print(result.to_timestamped_text()) # Text with timestamps
# Search within transcript
matches = result.search("keyword")
# Account stats
stats = yt.stats()
print(f"Credits: {stats.credits_remaining}")
# History
history = yt.list_transcripts(search="python tutorial", limit=5)ASYNC CLIENT
import asyncio
from youtubetranscript import AsyncYouTubeTranscript
async def main():
async with AsyncYouTubeTranscript("your_api_key") as yt:
# Single
result = await yt.transcribe("dQw4w9WgXcQ")
# Concurrent
results = await asyncio.gather(
yt.transcribe("video1"),
yt.transcribe("video2"),
yt.transcribe("video3"),
)
asyncio.run(main())ERROR HANDLING
from youtubetranscript import YouTubeTranscript
from youtubetranscript.exceptions import (
NoCaptionsError,
AuthenticationError,
InsufficientCreditsError,
RateLimitError,
)
yt = YouTubeTranscript("your_api_key")
try:
result = yt.transcribe("some_video")
except NoCaptionsError:
job = yt.transcribe_asr("some_video")
result = yt.wait_for_job(job.job_id)
except AuthenticationError:
print("Check your API key")
except InsufficientCreditsError:
print("Top up at youtubetranscript.dev/pricing")
except RateLimitError as e:
print(f"Rate limited β retry after {e.retry_after}s")API REFERENCE
TRANSCRIPT OBJECT
SEGMENT OBJECT
CREDIT COSTS
VS YOUTUBE-TRANSCRIPT-API (OPEN SOURCE)
You may have seen the popular open-source youtube-transcript-api package. Here is how ours differs:
OTHER SDKs & TOOLS
FREQUENTLY ASKED QUESTIONS
What Python versions are supported?+
Python 3.8 and above. We recommend Python 3.10+ for the best experience with type hints.
How is this different from youtube-transcript-api?+
Our SDK is the official package for YouTubeTranscript.dev. It includes AI-powered transcription for videos without captions, server-side extraction to avoid IP blocking, built-in rate limiting, and professional support. The open-source alternative only extracts existing captions and runs client-side.
Can I use it in Jupyter notebooks?+
Yes. The synchronous API works perfectly in Jupyter notebooks and Google Colab. Use the async API for concurrent processing in notebook environments.
Does it work with Django and Flask?+
Yes. The SDK is framework-agnostic and works with any Python web framework. Use the async interface with async frameworks like FastAPI.
Start Building with the Python SDK
pip install, authenticate, and extract transcripts in minutes.
VIEW ON PYPI β