Official Python SDK for the TranscriptFetch API: fetch YouTube transcripts, channels, playlists, and search as clean, typed data.
Project description
TranscriptFetch Python SDK
Official, typed Python client for the TranscriptFetch API: fetch YouTube transcripts, channels, playlists, and search results as clean, structured data. Sync + async, fully type-hinted.
pip install transcriptfetch-sdk
Quickstart
from transcriptfetch import TranscriptFetch
# api_key falls back to the TRANSCRIPTFETCH_API_KEY env var
tf = TranscriptFetch(api_key="tf_live_...")
t = tf.transcripts.video("https://youtu.be/aircAruvnKk")
print(t.title)
print(t.text)
for seg in t.segments:
print(f"[{seg.start:.1f}] {seg.text}")
print("credits left:", t.usage.balance)
Get an API key (100 free credits) at https://transcriptfetch.com/app. One credit per successful fetch; failed/blocked/no-transcript requests are free.
Endpoints
tf.transcripts.video(video) # single transcript (text + segments)
tf.transcripts.channel(channel, limit=, cursor=) # a channel's videos (metadata)
tf.transcripts.playlist(playlist, limit=, cursor=) # a playlist's videos
tf.transcripts.search(query, limit=, cursor=) # search YouTube
tf.transcripts.batch(video_ids) # up to 50 transcripts in one call
tf.health() # unauthenticated liveness probe
video/channel/playlist accept URLs or raw IDs (normalized automatically).
Pagination
List endpoints are cursor-paginated. Iterate every result without managing cursors:
for video in tf.transcripts.iter_channel("@lexfridman", limit=10):
print(video.video_id, video.title)
Or page manually via page.next_cursor and the cursor= argument.
Async
import asyncio
from transcriptfetch import AsyncTranscriptFetch
async def main():
async with AsyncTranscriptFetch() as tf:
t = await tf.transcripts.video("aircAruvnKk")
print(t.text)
async for v in tf.transcripts.iter_search("how transformers work", limit=10):
print(v.title)
asyncio.run(main())
Errors
All errors subclass TranscriptFetchError. API errors carry .status, .code, .message, and .request_id:
from transcriptfetch import (
AuthenticationError, InsufficientCreditsError, InvalidRequestError,
RateLimitError, IdempotencyConflictError, UpstreamUnavailableError,
InternalServerError, APIError, APIConnectionError, APITimeoutError,
)
try:
tf.transcripts.video("bad")
except InsufficientCreditsError:
... # 402: top up at /pricing
except RateLimitError as e:
print(e.retry_after) # 429
except APIError as e:
print(e.status, e.code, e.request_id)
Reliability
- Automatic retries on
429(honoringRetry-After) and5xx, with exponential backoff + jitter (max_retries=2by default). - Idempotency: every write auto-sends an
Idempotency-Keyso a retried request is never double-charged. Override per call withidempotency_key=.... - Configurable:
TranscriptFetch(api_key=..., base_url=..., timeout=30, max_retries=2). Both clients are context managers and accept a customhttp_client=(httpx).
Development
pip install -e ".[dev]"
ruff check . && mypy src && pytest
Tests are fully mocked (no network). MIT licensed.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file transcriptfetch_sdk-0.1.0.tar.gz.
File metadata
- Download URL: transcriptfetch_sdk-0.1.0.tar.gz
- Upload date:
- Size: 12.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f4c5e8621e548e339a16a9680fe7a39f5c210fd1fd08c6abdd0db61caf0e7a2
|
|
| MD5 |
9446b3c067f7b646bdad70c69c247c2f
|
|
| BLAKE2b-256 |
337ccf8103921a9227a62757300874f68ee6c04b0196973a3ee9dcb98c165bcd
|
Provenance
The following attestation bundles were made for transcriptfetch_sdk-0.1.0.tar.gz:
Publisher:
release.yml on TranscriptFetch/python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
transcriptfetch_sdk-0.1.0.tar.gz -
Subject digest:
8f4c5e8621e548e339a16a9680fe7a39f5c210fd1fd08c6abdd0db61caf0e7a2 - Sigstore transparency entry: 2164516435
- Sigstore integration time:
-
Permalink:
TranscriptFetch/python-sdk@4e9905d50a1021014a0ae953e2eafa9f6bd3ee8e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/TranscriptFetch
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4e9905d50a1021014a0ae953e2eafa9f6bd3ee8e -
Trigger Event:
push
-
Statement type:
File details
Details for the file transcriptfetch_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: transcriptfetch_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c40a559e1514e01dd94444a375a33f96a9340c7556bb02a5fdf5322efbd75783
|
|
| MD5 |
09b632685b9428c41bcd667724cf7ab5
|
|
| BLAKE2b-256 |
1ee1d48846ce9f9b75d983769444fb80fc4e545427c7ff88b9e32f69cbf72977
|
Provenance
The following attestation bundles were made for transcriptfetch_sdk-0.1.0-py3-none-any.whl:
Publisher:
release.yml on TranscriptFetch/python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
transcriptfetch_sdk-0.1.0-py3-none-any.whl -
Subject digest:
c40a559e1514e01dd94444a375a33f96a9340c7556bb02a5fdf5322efbd75783 - Sigstore transparency entry: 2164516453
- Sigstore integration time:
-
Permalink:
TranscriptFetch/python-sdk@4e9905d50a1021014a0ae953e2eafa9f6bd3ee8e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/TranscriptFetch
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4e9905d50a1021014a0ae953e2eafa9f6bd3ee8e -
Trigger Event:
push
-
Statement type: