Official SDKs
Type-safe clients for Python and TypeScript. Zero boilerplate, built-in error handling, and full API coverage.
Installation
Python
pip install fetchtranscriptTypeScript
npm install fetchtranscriptQuick Start
from fetchtranscript import FetchTranscriptClient
client = FetchTranscriptClient(api_key="yt_your_api_key")
# Get transcript
transcript = client.transcripts.get("dQw4w9WgXcQ")
print(transcript["text"])
# Get as plain text
text = client.transcripts.get_text("dQw4w9WgXcQ")
# Get as SRT subtitles
srt = client.transcripts.get_srt("dQw4w9WgXcQ")
# List available languages
languages = client.transcripts.list_languages("dQw4w9WgXcQ")
for lang in languages["languages"]:
print(f"{lang['language']} ({lang['language_code']})")Videos & Channels
# Video metadata
metadata = client.videos.get_metadata("dQw4w9WgXcQ")
print(f"{metadata['title']} - {metadata['view_count']:,} views")
# Chapters & comments
chapters = client.videos.get_chapters("dQw4w9WgXcQ")
comments = client.videos.get_comments("dQw4w9WgXcQ", limit=50)
# Channel info & videos
channel = client.channels.get_info("@mkbhd")
videos = client.channels.get_videos("@mkbhd", limit=20)
all_videos = client.channels.get_all_videos("@mkbhd")
# Search
results = client.search.videos("python tutorial", limit=10)Async Support (Python)
import asyncio
from fetchtranscript import AsyncFetchTranscriptClient
async def main():
async with AsyncFetchTranscriptClient(api_key="yt_your_api_key") as client:
transcript = await client.transcripts.get("dQw4w9WgXcQ")
print(transcript["text"])
asyncio.run(main())Error Handling
from fetchtranscript import (
FetchTranscriptClient,
VideoNotFoundError,
InsufficientCreditsError,
AuthenticationError,
)
client = FetchTranscriptClient(api_key="yt_your_api_key")
try:
transcript = client.transcripts.get("invalid_id")
except VideoNotFoundError as e:
print(f"Video not found: {e.message}")
except InsufficientCreditsError:
print("Not enough credits")
except AuthenticationError:
print("Invalid API key")Response Metadata
After any API call, check remaining credits and processing time via client properties.
client.transcripts.get("dQw4w9WgXcQ")
print(client.credits_remaining)
print(client.processing_time_ms)Configuration
| Option | Default | Description |
|---|---|---|
api_key | - | Your API key (starts with yt_) |
base_url | https://api.fetchtranscript.com | API base URL (override for self-hosting) |
You can also set FETCHTRANSCRIPT_API_KEY and FETCHTRANSCRIPT_BASE_URL as environment variables.