🐍 PYTHON SDK

YouTube Transcript Python SDKOfficial 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

Terminal
pip install youtubetranscriptdevapi

QUICK START

Python
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

Python — Translation, Source, Format
# 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})
Python — Batch Processing (up to 100 videos)
batch = yt.batch(["video1", "video2", "video3"])
for t in batch.completed:
    print(f"{t.video_id}: {t.word_count} words")
Python — ASR Audio Transcription
job = yt.transcribe_asr("video_without_captions")
result = yt.wait_for_job(job.job_id)  # polls until complete
print(result.text)
Python — Export Formats
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
Python — Search & Account
# 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

Python — asyncio
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

Python
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

Method
transcribe(video, *, language, source, format)
transcribe_asr(video, *, language, webhook_url)
get_job(job_id)
wait_for_job(job_id, *, poll_interval, timeout)
batch(video_ids, *, language)
get_batch(batch_id)
list_transcripts(*, search, language, status, limit, page)
get_transcript(video_id, *, language, source)
stats()
delete_transcript(*, video_id, ids)

TRANSCRIPT OBJECT

Property / Method
segments
text
video_id
language
word_count
duration
to_srt()
to_vtt()
to_plain_text()
to_timestamped_text()
search(query)

SEGMENT OBJECT

PropertyDescription
textSegment text
startStart time (seconds)
endEnd time (seconds)
durationDuration (seconds)
start_formatted"MM:SS" format
start_hms"HH:MM:SS" format

CREDIT COSTS

OperationCost
Captions extraction1 credit
Translation1 credit per 2,500 chars
ASR audio transcription1 credit per 90 seconds
Re-fetch owned transcriptFree

VS YOUTUBE-TRANSCRIPT-API (OPEN SOURCE)

You may have seen the popular open-source youtube-transcript-api package. Here is how ours differs:

FeatureYouTubeTranscript.dev SDKyoutube-transcript-api
AI transcription fallbackYes — handles videos without captionsNo — fails if no captions exist
Maintained & supportedActively maintained with SLACommunity maintained, sporadic updates
Rate limit handlingBuilt-in with automatic retryManual — you handle rate limits
Playlist / bulk supportBuilt-in batch processingManual iteration required
YouTube blockingServer-side — no IP blocking riskClient-side — your IP can get blocked

OTHER SDKs & TOOLS

LanguagePackage
JavaScript / Nodeyoutube-transcript-api on npm
Dart / Flutteryoutubetranscript on pub.dev
MCP Servermcp.youtubetranscript.dev

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 →

立即开始免费提取文本

数秒でYouTubeの動画をテキストに変換します。クレジットカードは必要ありません。

YOUTUBETRANSCRIPT.DEVをお試しください →
    YouTube Transcript Python SDK | YouTubeTranscript.dev