Extract YouTube Transcripts via API in 10 Lines (No yt-dlp Proxy Headaches)

extract-youtube-transcripts-via-api-in-10-lines-(no-yt-dlp-proxy-headaches)

If you have ever tried to pull YouTube transcripts from a cloud server, you know the loop:

  • youtube-transcript-api works on your laptop.
  • You deploy to AWS, Hetzner, Railway, or run it inside n8n Cloud.
  • Requests start failing with 429, “Sign in to confirm you’re not a bot”, or empty caption tracks.
  • You add rotating residential proxies, then spend your weekends maintaining them.

This post shows a smaller alternative: a hosted REST API for YouTube transcripts, with idempotency keys and polling, so your code stays around ten lines.

The API in one paragraph

POST /api/v1/transcripts with 1–50 YouTube video IDs. It returns a requestId and a statusUrl. Poll the status URL until the job is completed, then read JSON transcripts with clean text and timestamped segments. No yt-dlp, no proxy pool, no datacenter IP blocks.

Authentication is Authorization: Basic ytt_live_. Send an Idempotency-Key header on POST so retries never double-bill.

curl

curl -X POST "https://yttotext.com/api/v1/transcripts" 
  -H "Authorization: Basic ytt_live_YOUR_API_TOKEN" 
  -H "Content-Type: application/json" 
  -H "Idempotency-Key: req-2026-11-23-001" 
  -d '{"ids":["dQw4w9WgXcQ"],"language":"en"}'

The response contains requestId and statusUrl.

Python

import os, time, requests

headers = {
    "Authorization": f"Basic {os.environ['YTT_API_KEY']}",
    "Content-Type": "application/json",
    "Idempotency-Key": f"demo-{time.time()}",
}

job = requests.post(
    "https://yttotext.com/api/v1/transcripts",
    headers=headers,
    json={"ids": ["dQw4w9WgXcQ"], "language": "en"},
    timeout=30,
).json()

for _ in range(60):
    result = requests.get(
        f"https://yttotext.com{job['statusUrl']}",
        headers=headers,
        timeout=30,
    ).json()
    if result["status"] in {"completed", "partial", "failed"}:
        break
    time.sleep(5)

print(result)

Node.js

const headers = {
  Authorization: `Basic ${process.env.YTT_API_KEY}`,
  "Content-Type": "application/json",
  "Idempotency-Key": `demo-${Date.now()}`,
};

const job = await fetch("https://yttotext.com/api/v1/transcripts", {
  method: "POST",
  headers,
  body: JSON.stringify({ ids: ["dQw4w9WgXcQ"], language: "en" }),
}).then((r) => r.json());

let result;
for (let i = 0; i < 60; i += 1) {
  result = await fetch(`https://yttotext.com${job.statusUrl}`, { headers }).then((r) => r.json());
  if (["completed", "partial", "failed"].includes(result.status)) break;
  await new Promise((r) => setTimeout(r, 5000));
}

console.log(result);

n8n

There is a ready-to-import workflow in the examples repo: set the video ID and API key, create the request, wait 5 seconds, poll until complete, then split one item per video for OpenAI, Claude, Supabase Vector Store, or Notion.

Repository: https://github.com/Nuco1231231321/yt-to-text-api-examples

Things worth knowing

  • Captions are required. The API reads caption tracks that already exist on YouTube. A video with no captions needs audio upload / ASR instead.
  • Batch size. Up to 50 video IDs per request; results paginate 10 transcripts per page via nextStatusUrl.
  • Idempotency. Reusing the same Idempotency-Key on a retry returns the original job instead of charging again.
  • Channels. POST /api/v1/channels resolves a public @handle or channel URL into video IDs, which is handy for watchlist-style automations.

If you are maintaining a proxy pool just to read captions, this is the part you can delete.

Total
0
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post
background-job-queue:-malformed-payload,-256kb-json-parse-and-schema-validation

Background Job Queue: Malformed Payload, 256KB JSON Parse and Schema Validation

Related Posts