PYTHON API EXAMPLE

YouTube Transcript API Python

Use Python requests to extract YouTube transcripts as JSON with timestamps, caption source metadata, and stable transcript page URLs.

QUICK ANSWERS

Direct answer

The real endpoint is https://tubescript.cc/v1/transcript. API access is included with the Team plan.

01

YouTube Transcript API Python

TubeScript's Python API path is a POST request to https://tubescript.cc/v1/transcript with a Team API key. The response includes video metadata, transcript source, word count, read time, and timestamped segments.

Python
import requests

response = requests.post(
    "https://tubescript.cc/v1/transcript",
    headers={
        "Authorization": "Bearer YOUR_API_KEY",
        "Content-Type": "application/json",
    },
    json={
        "url": "https://youtube.com/watch?v=dQw4w9WgXcQ",
        "language": "en",
        "stream": False,
    },
    timeout=120,
)

payload = response.json()
if payload["success"]:
    for segment in payload["data"]["segments"]:
        print(segment["start"], segment["text"])
else:
    print(payload["error"]["code"], payload["error"]["message"])

Use JSON mode first

Set stream to false while prototyping. It returns one JSON object that is easier to inspect in scripts, notebooks, and server jobs.

Handle caption source

Read transcript_source to distinguish manual captions, YouTube auto captions, and AI fallback transcripts.

Build on the transcript engine

Team includes API keys, JSON transcript access, cache-backed reads, and 100 API requests per day.

View Pricing