Skip to main content

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 (honoring Retry-After) and 5xx, with exponential backoff + jitter (max_retries=2 by default).
  • Idempotency: every write auto-sends an Idempotency-Key so a retried request is never double-charged. Override per call with idempotency_key=....
  • Configurable: TranscriptFetch(api_key=..., base_url=..., timeout=30, max_retries=2). Both clients are context managers and accept a custom http_client= (httpx).

Development

pip install -e ".[dev]"
ruff check . && mypy src && pytest

Tests are fully mocked (no network). MIT licensed.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

transcriptfetch_sdk-0.1.0.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

transcriptfetch_sdk-0.1.0-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

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

Hashes for transcriptfetch_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8f4c5e8621e548e339a16a9680fe7a39f5c210fd1fd08c6abdd0db61caf0e7a2
MD5 9446b3c067f7b646bdad70c69c247c2f
BLAKE2b-256 337ccf8103921a9227a62757300874f68ee6c04b0196973a3ee9dcb98c165bcd

See more details on using hashes here.

Provenance

The following attestation bundles were made for transcriptfetch_sdk-0.1.0.tar.gz:

Publisher: release.yml on TranscriptFetch/python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file transcriptfetch_sdk-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for transcriptfetch_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c40a559e1514e01dd94444a375a33f96a9340c7556bb02a5fdf5322efbd75783
MD5 09b632685b9428c41bcd667724cf7ab5
BLAKE2b-256 1ee1d48846ce9f9b75d983769444fb80fc4e545427c7ff88b9e32f69cbf72977

See more details on using hashes here.

Provenance

The following attestation bundles were made for transcriptfetch_sdk-0.1.0-py3-none-any.whl:

Publisher: release.yml on TranscriptFetch/python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page