youtubetranscript-net (Python)
Python client for the YouTubeTranscript.net API: get YouTube transcripts with timestamps, download them as TXT, SRT or VTT, and transcribe whole playlists and channels. Standard library only, Python 3.9+, fully typed.
Install
pip install youtubetranscript-net
Quick start
Create an API key at https://youtubetranscript.net/account/api-keys and set it as YTT_API_KEY.
from youtubetranscript_net import YouTubeTranscript
client = YouTubeTranscript() # reads YTT_API_KEY
result = client.transcripts.get("https://www.youtube.com/watch?v=jNQXAC9IVRw")
for segment in result.transcript.segments:
print(segment.start, segment.text)
get waits for the transcript: it asks for a fast answer, and when the video needs more time (speech-to-text, long videos) it polls the job until it is done.
Client options
YouTubeTranscript(
api_key="ytt_...", # default YTT_API_KEY
base_url="https://api.youtubetranscript.net", # default YTT_BASE_URL, then this
timeout=60.0, # seconds per HTTP request
max_retries=2, # automatic retries, see below
)
Methods
video is a YouTube link (watch, youtu.be, Shorts) or an 11-character video id.
Transcripts
| Method | Returns |
|---|---|
transcripts.get(video, language=, format=, include_timestamp=, send_metadata=, confirm_credits=, timeout=300, poll_interval=2) |
TranscriptResult once ready |
transcripts.submit(video, ..., wait_ms=) |
the first answer: TranscriptResult or TranscriptJob |
transcripts.job(job_id) |
TranscriptResult or TranscriptJob |
transcripts.info(video) |
video details and caption languages (free) |
transcripts.list(q=, lang=, sort=, page=, page_size=) |
{"transcripts", "total", "page", "pageSize", "langs"} |
transcripts.download(video_id, "srt", language=) |
the file as str (txt, srt, vtt, json, md) |
transcripts.delete(video_id, language=) |
{"removed": True} |
language is a priority list such as "en", "pt-BR,pt", "auto" (the video's own captions) or "asr" (speech-to-text when there are no captions). format="text" returns plain text in result.text.
TranscriptResult has status, job_id, language, format, cached, length_seconds, length_text, transcript (platform, external_id, lang, origin, title, channel, duration_sec, segments), text, metadata and raw (the full JSON).
Batches
batch = client.batches.create(playlist="https://www.youtube.com/playlist?list=...")
done = client.batches.wait(batch["id"])
with open("transcripts.zip", "wb") as f:
f.write(client.batches.export(batch["id"], format="zip", files="srt"))
| Method | Returns |
|---|---|
batches.create(items=[...] | playlist= | channel=, language=, limit=, name=) |
the batch |
batches.get(batch_id, max_results=, page_token=) |
{"batch", "items", "nextPageToken"} |
batches.wait(batch_id, timeout=1800, poll_interval=3) |
the last get once completed or failed |
batches.export(batch_id, format="zip", files=, timestamps=) |
file bytes (zip, csv, txt, json, srt, vtt) |
batches.retry(batch_id) |
{"batch", "retried", "credits"} |
batches.delete(batch_id) |
{"removed": True} |
Batches are available once your account has bought a credit pack.
Account
client.account.usage() returns your credits (balance, freeToday, available) and limits.
Errors
Every failure raises YouTubeTranscriptError:
from youtubetranscript_net import YouTubeTranscriptError
try:
client.transcripts.get(video, language="de")
except YouTubeTranscriptError as e:
e.code # "LANGUAGE_NOT_AVAILABLE", "INSUFFICIENT_CREDITS", "RATE_LIMITED", ...
e.status # HTTP status, 0 for local errors
e.message
e.request_id # X-Request-Id, include it when you contact support
e.retry_after # seconds, on 429
e.details # the server's error object, e.g. e.details["availableLanguages"]
e.retryable # True for 429, 5xx and network errors
A video that costs more than 10 credits raises CREDITS_CONFIRMATION_REQUIRED first; call again with confirm_credits=True to accept the cost.
Retries
GET and DELETE requests, and transcripts.get / submit (sent with an Idempotency-Key, so the server never runs or charges them twice), are retried up to max_retries times on 429, 5xx and network errors, waiting for Retry-After when the server sends it. batches.create and batches.retry are never retried automatically.
Development
python3 -m unittest discover -s tests # unit tests, no network
YTT_API_KEY=ytt_... PYTHONPATH=src python3 examples/e2e.py # end-to-end against the API
Metadata
Release files for youtubetranscript-net 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| youtubetranscript_net-0.1.0.tar.gz | 19.8 kB | With provenance | Details for youtubetranscript_net-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| youtubetranscript_net-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for youtubetranscript_net-0.1.0-py3-none-any.whl |
Total release size: 33.1 kB
Release files / youtubetranscript_net-0.1.0.tar.gz
| Download URL | youtubetranscript_net-0.1.0.tar.gz |
|---|---|
| Size | 19.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f4a6d04d152b00d94a3716bec8d47502da08d149d0c6e644b61274e0dd2f254c
|
|
BLAKE2b-256 checksum How to use checksums |
0058f969b74cdcfeda141879464410641634fc587d72f7a0a3dcbc4cc134916c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Dec 2, 2026.
Transparency logRelease files / youtubetranscript_net-0.1.0-py3-none-any.whl
| Download URL | youtubetranscript_net-0.1.0-py3-none-any.whl |
|---|---|
| Size | 13.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
32b0ece8d8b967f4904b44b92f4fe372fc123c638b500af0ebfd6132d0900a05
|
|
BLAKE2b-256 checksum How to use checksums |
61a3434e88276e160cfc5a6fe7cbe92d0db3fdbe035044337f41233dbb51545c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Dec 2, 2026.
Transparency logSecurity for youtubetranscript-net 0.1.0
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for youtubetranscript_net-0.1.0.tar.gz
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 Dec 2, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.