Skip to main content

YouTubeTranscript.dev

YouTubeTranscript Python SDK

Official Python client for the YouTubeTranscript.dev API
Extract, transcribe, and translate YouTube video transcripts.

PyPI version Python versions License


Installation

pip install youtubetranscriptdevapi

Quick Start

from youtubetranscript import YouTubeTranscript

yt = YouTubeTranscript("your_api_key")

# Extract transcript
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}")

Get your free API key at youtubetranscript.dev/dashboard

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 — up to 100 videos at once
batch = yt.batch(["video1", "video2", "video3"])
for t in batch.completed:
    print(f"{t.video_id}: {t.word_count} words")

# ASR audio transcription (for videos without captions)
job = yt.transcribe_asr("video_without_captions")
result = yt.wait_for_job(job.job_id)  # polls until complete
print(result.text)

# 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

# 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:
    # No captions — try ASR
    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

YouTubeTranscript(api_key, *, base_url, timeout, max_retries)

Method Description
transcribe(video, *, language, source, format) Extract transcript
transcribe_asr(video, *, language, webhook_url) ASR audio transcription
get_job(job_id) Check ASR job status
wait_for_job(job_id, *, poll_interval, timeout) Poll until ASR completes
batch(video_ids, *, language) Batch extract (up to 100)
get_batch(batch_id) Check batch status
list_transcripts(*, search, language, status, limit, page) Browse history
get_transcript(video_id, *, language, source) Get saved transcript
stats() Account credits & usage
delete_transcript(*, video_id, ids) Delete transcripts

Transcript object

Property/Method Description
segments List of Segment objects
text Full transcript as string
video_id YouTube video ID
language Transcript language
word_count Total word count
duration Total duration in seconds
to_srt() Export as SRT
to_vtt() Export as WebVTT
to_plain_text() Plain text export
to_timestamped_text() Text with [MM:SS] timestamps
search(query) Find segments by text

Segment object

Property Description
text Segment text
start Start time (seconds)
end End time (seconds)
duration Duration (seconds)
start_formatted "MM:SS" format
start_hms "HH:MM:SS" format

Credit Costs

Operation Cost
Captions extraction 1 credit
Translation 1 credit per 2,500 chars
ASR audio transcription 1 credit per 90 seconds
Re-fetch owned transcript Free

License

MIT — see LICENSE

Links

Metadata

Release files for youtubetranscriptdevapi 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for youtubetranscriptdevapi 0.1.1
File Size Uploaded
youtubetranscriptdevapi-0.1.1.tar.gz 11.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for youtubetranscriptdevapi 0.1.1
File Interpreter ABI Platform
youtubetranscriptdevapi-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 25.8 kB

Release files / youtubetranscriptdevapi-0.1.1.tar.gz

Download URL youtubetranscriptdevapi-0.1.1.tar.gz
Size 11.7 kB
Tags Source
SHA-256 checksum
How to use checksums
abd86a7c52db2ad56b96409ca0e4437fa7b7ad2ebe314bfd68f4da3cf7b20bdb
BLAKE2b-256 checksum
How to use checksums
8aeb21102a542c0031903fba198a2bb5795b7134a52d4a1d77a07b218aaa4217
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 17, 2026.

Transparency log

Release files / youtubetranscriptdevapi-0.1.1-py3-none-any.whl

Download URL youtubetranscriptdevapi-0.1.1-py3-none-any.whl
Size 14.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
46743494a02f602c08e175f691462bd493d16becea058543a671132b241ac6f7
BLAKE2b-256 checksum
How to use checksums
64a764acca52788627c414b7ed99509b34c786fd08076b53c9ddf9e736dfa035
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 17, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page