FetchTranscript Python SDK
Official Python SDK for the FetchTranscript API — fetch YouTube transcripts, video metadata, channel info, and more.
Installation
pip install fetchtranscript
Quick Start
from fetchtranscript import FetchTranscriptClient
client = FetchTranscriptClient(api_key="yt_your_api_key")
# Get a transcript
transcript = client.transcripts.get("dQw4w9WgXcQ")
for segment in transcript["segments"]:
print(f"[{segment['start']:.1f}s] {segment['text']}")
# Get video metadata
video = client.videos.get_metadata("dQw4w9WgXcQ")
print(video["title"])
Async Usage
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["language"])
asyncio.run(main())
API Reference
Transcripts
# Get transcript (JSON format with segments)
transcript = client.transcripts.get("VIDEO_ID")
# Get transcript in a specific language
transcript = client.transcripts.get("VIDEO_ID", lang="es")
# Get as plain text
text = client.transcripts.get_text("VIDEO_ID")
# Get as SRT subtitles
srt = client.transcripts.get_srt("VIDEO_ID")
# List available languages
languages = client.transcripts.list_languages("VIDEO_ID")
Videos
# Get video metadata
metadata = client.videos.get_metadata("VIDEO_ID")
# Get video chapters
chapters = client.videos.get_chapters("VIDEO_ID")
# Get video comments
comments = client.videos.get_comments("VIDEO_ID", limit=50)
Channels
# Get channel info
channel = client.channels.get_info("CHANNEL_ID")
# Get channel videos
videos = client.channels.get_videos("CHANNEL_ID", limit=20)
# Get all videos with auto-pagination
all_videos = client.channels.get_all_videos("CHANNEL_ID")
Search
# Search videos
results = client.search.videos("python tutorial", limit=10)
# Search and check transcript availability
results = client.search.find_videos_with_transcripts("python tutorial")
Error Handling
The SDK raises domain-specific exceptions instead of raw HTTP errors:
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")
Exception Hierarchy
| Exception | HTTP Status | Description |
|---|---|---|
FetchTranscriptError |
— | Base exception |
VideoNotFoundError |
404 | Video not found or transcripts disabled |
ChannelNotFoundError |
404 | Channel not found |
InvalidVideoIdError |
400 | Invalid video/channel ID format |
InsufficientCreditsError |
402 | Not enough credits |
AuthenticationError |
401 | Missing or invalid API key |
ServiceUnavailableError |
503 | Upstream service unavailable |
Response Headers
After each request, you can check:
client.transcripts.get("dQw4w9WgXcQ")
print(client.credits_remaining) # Remaining API credits
print(client.processing_time_ms) # Processing time in ms
License
MIT
Metadata
Release files for fetchtranscript 0.1.2
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 |
|---|---|---|---|---|
| fetchtranscript-0.1.2.tar.gz | 10.5 kB | Without provenance | Details for fetchtranscript-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fetchtranscript-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for fetchtranscript-0.1.2-py3-none-any.whl |
Total release size: 21.8 kB
Release files / fetchtranscript-0.1.2.tar.gz
| Download URL | fetchtranscript-0.1.2.tar.gz |
|---|---|
| Size | 10.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c82c5d2d8a69179b4ee126641112ab30b16935185ed1e7c88ccf3105ac10145d
|
|
BLAKE2b-256 checksum How to use checksums |
e429e23e9c67f0f53a70071b3f9748d48e81c7623757f244ec5393e03e00837e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / fetchtranscript-0.1.2-py3-none-any.whl
| Download URL | fetchtranscript-0.1.2-py3-none-any.whl |
|---|---|
| Size | 11.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
445ac20c3efa7af136c80df50d465a5addb8e43afd0fc7c2553e9608a8f19f57
|
|
BLAKE2b-256 checksum How to use checksums |
bc7fcb16014ba47d393ee9931669461c4bf6847fe71b392dc8c72e87f4dd4196
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for fetchtranscript 0.1.2
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.