API Hop

Guides

YouTube Transcript API: Captions + LLM Summary

Avoid cloud IP blocks and OAuth limits with YouTube Transcript API: extract captions at $0.008/job (free polling) and summarize via DeepSeek.

Reviewed:

The open-source Python youtube-transcript-api package works on a laptop, yet breaks on AWS, GCP, or Vercel cloud IPs with RequestBlocked, while the official YouTube Data API v3 captions.download requires OAuth 2.0 and works only on videos your own channel owns. Through POST /v1/youtube/web-v2/videos/captions on the API Hop YouTube Data API ($0.008/job with free result polling) paired with deepseek-v4-flash under the same API key, extracting and summarizing a 30-minute video costs roughly $0.0108 end to end.

Key Takeaways

  • Open-source libraries and official APIs hit opposite walls in production: youtube-transcript-api gets blocked on datacenter IPs unless you pay for and rotate residential proxies, while YouTube Data API v3 grants free daily quota (200 units per caption download) but restricts access via OAuth to channels you own.
  • Async caption jobs at $0.008 with $0 polling: POST /v1/youtube/web-v2/videos/captions returns HTTP 202 and a job ID, while polling GET /v1/youtube/web-v2/videos/captions/result every 2–5 seconds is completely free. Output formats include srt, xml, json3, and txt.
  • Pre-check video metadata for $0.001 before extracting: For batch jobs, call GET /v1/youtube/web-v2/videos/info ($0.001/request) first to skip music videos, Shorts, or livestreams before spending $0.008 on captions.
  • Extracts existing captions, not Whisper speech-to-text: The endpoint retrieves manual or auto-generated captions already hosted on YouTube. Videos with no captions at all still complete as a billable response.
  • One key powers captions plus DeepSeek summarization: Fund a single balance on the API Hop Pricing page starting at $10 (no monthly lock-in, USDT/USDC and local wallets supported) and run both extraction and LLM summarization from one script.

Four Ways to Get YouTube Transcripts in 2026

Before building an AI video summarizer or RAG pipeline, compare cloud reliability, access barriers, and per-1,000-video costs (verified 2026-11-27):

Access RouteCloud Stability & Auth BarrierPricing ModelEst. Cost for 1,000 TranscriptsMain Limitation
Open-source youtube-transcript-api (Python)Works locally; AWS/GCP/Vercel datacenter IPs trigger IpBlockedFree library + paid residential proxies$0 (+ $5–$30+ for proxies)Requires proxy pool rotation and anti-bot maintenance
YouTube Data API v3 (Official)Requires OAuth 2.0; restricted to your own owned channels10,000 free quota units/day (captions.download = 200 units)$0 (~50/day cap)Cannot extract captions from arbitrary public videos
Supadata / Apify ActorsManaged proxy infrastructureSupadata from $5–$17/mo; Apify ~$0.70–$10/1K results + platform plan~$5–$17 (tier/plan bound)Monthly subscription commitments or container startup lag
API Hop YouTube Data APIManaged gateway, zero datacenter IP blocks, no OAuthPay-as-you-go $0.008 / caption job (free polling)$8.00 (no monthly fee)Retrieves existing YouTube captions only; no Whisper ASR fallback

Prerequisites

Prepare three items to run the full caption extraction and LLM summary workflow:

  1. API Hop Key: Register and create a key on the API Hop Pricing page. Billing is prepaid pay-as-you-go ($10 minimum top-up, non-expiring credits) with no overseas credit card or corporate KYC needed, supporting USDT/USDC crypto plus regional wallets like Brazil PIX and Indonesia QRIS/GoPay/DANA.
  2. Local Runtime: Python 3.9+ with requests (for YouTube endpoints) and openai (for calling DeepSeek with the same API key).
  3. Contract Reference: Bookmark the YouTube Data API Overview and YouTube Endpoint Reference for all 34 YouTube endpoints.
pip install -U requests openai
export APIHOP_API_KEY="sk-your-apihop-key"

Quickstart: Submit a Caption Job and Poll Results in 2 Minutes

Caption extraction runs asynchronously in two steps: job submission (POST, billed $0.008) and result polling (GET, free $0). Submit a txt caption job with curl:

curl -sS -X POST "https://api.apihop.ai/v1/youtube/web-v2/videos/captions" \
  -H "Authorization: Bearer $APIHOP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"video_id":"dQw4w9WgXcQ","format":"txt"}'

The gateway returns HTTP 202 with Location: /v1/jobs/{id}. Always store data.id as a string because job IDs exceed JavaScript’s Number.MAX_SAFE_INTEGER:

{
  "success": true,
  "data": {
    "id": "9007199254740993001",
    "status": "PROCESSING",
    "result": null
  },
  "requestId": "req_01j9yt..."
}

Minimal Python Polling Example

Poll /captions/result every 2–5 seconds at $0 until status reaches COMPLETED or FAILED:

import os, time, requests

headers = {"Authorization": f"Bearer {os.environ['APIHOP_API_KEY']}"}
job = requests.post("https://api.apihop.ai/v1/youtube/web-v2/videos/captions",
    headers=headers, json={"video_id": "dQw4w9WgXcQ", "format": "txt"}, timeout=60).json()
job_id = str(job["data"]["id"])
for _ in range(15):
    res = requests.get("https://api.apihop.ai/v1/youtube/web-v2/videos/captions/result",
        headers=headers, params={"job_id": job_id, "format": "txt"}, timeout=60).json()
    if res["data"]["status"] in ("COMPLETED", "FAILED"):
        print(res["data"]["status"], str(res["data"]["result"])[:120]); break
    time.sleep(3)

Expected output: COMPLETED ... (plain-text transcript, or timestamped text when using srt).

Step-by-Step Guide: Video Filtering, Format Control, and DeepSeek Summaries

Follow these three steps to build a cost-controlled transcript-to-summary pipeline.

Step 1: Submit Captions with Explicit Language and Format

POST /v1/youtube/web-v2/videos/captions requires at least video_id or video_url in the JSON body, with optional language_code (such as "en" or "zh-Hans") and format (srt, xml, json3, or txt, defaulting to "srt"). If you pass format during polling, it must match the format locked at creation—otherwise the gateway returns HTTP 400.

import os
import requests

resp = requests.post(
    "https://api.apihop.ai/v1/youtube/web-v2/videos/captions",
    headers={"Authorization": f"Bearer {os.environ['APIHOP_API_KEY']}"},
    json={
        "video_url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
        "language_code": "en",
        "format": "txt",
    },
    timeout=60,
)
print("HTTP:", resp.status_code, "Location:", resp.headers.get("Location"))
print("Job:", resp.json())

Expected output: HTTP: 202 Location: /v1/jobs/... with status: PROCESSING.

Step 2: Pre-Check Video Metadata for $0.001 Before Extracting

When monitoring whole channels, skip music videos, short clips, or off-topic uploads before paying $0.008 for captions. Call GET /v1/youtube/web-v2/videos/info ($0.001) or GET /v1/youtube/web-v2/search ($0.001) to filter candidates by duration first.

import os
import requests

r = requests.get(
    "https://api.apihop.ai/v1/youtube/web-v2/videos/info",
    headers={"Authorization": f"Bearer {os.environ['APIHOP_API_KEY']}"},
    params={"video_id": "dQw4w9WgXcQ", "need_format": "true"},
    timeout=60,
)
r.raise_for_status()
print("X-Request-Id:", r.headers.get("X-Request-Id"), "Data keys:", list(r.json().keys()))

Expected output: X-Request-Id: ... Data keys: [...]. Altogether, the API Hop YouTube Data API exposes 34 endpoints (32 GET and 2 POST) across videos, Shorts, comments, and channels.

Step 3: Summarize Transcripts via deepseek-v4-flash Using the Same Key

Skip managing a separate LLM vendor account. Point the official openai SDK’s base_url to https://api.apihop.ai/v1 with the same APIHOP_API_KEY to summarize transcripts using deepseek-v4-flash ($0.3429/1M input tokens, $1.0286/1M output tokens):

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["APIHOP_API_KEY"],
    base_url="https://api.apihop.ai/v1",
)

def summarize_transcript(transcript_text: str) -> str:
    completion = client.chat.completions.create(
        model="deepseek-v4-flash",
        messages=[
            {"role": "system", "content": "Summarize this YouTube transcript into: 1) One-sentence takeaway 2) 5 key points 3) Actionable next steps."},
            {"role": "user", "content": transcript_text[:40000]},
        ],
        temperature=0.2,
    )
    return completion.choices[0].message.content or ""

Running both Data API extraction and LLM inference from one prepaid balance keeps serverless deployments simple.

Complete Working Example: Extract Captions, Poll with Backoff, and Summarize

This complete script submits a caption job, polls freely until COMPLETED, summarizes the text via deepseek-v4-flash, writes {video_id}_summary.md, and prints exact job + token costs.

import os
import time
import requests
from openai import OpenAI

API_KEY = os.environ["APIHOP_API_KEY"]
DATA_BASE = "https://api.apihop.ai/v1/youtube/web-v2"
HEADERS = {"Authorization": f"Bearer {API_KEY}"}


def request_with_retry(method: str, url: str, max_retries: int = 3, **kwargs) -> requests.Response:
    for attempt in range(max_retries):
        resp = requests.request(method, url, headers=HEADERS, timeout=60, **kwargs)
        if resp.status_code in (200, 202):
            return resp
        if resp.status_code in (429, 500, 502, 503, 504) and attempt < max_retries - 1:
            wait = 2 ** (attempt + 1)
            print(f"[Retry {attempt + 1}] HTTP {resp.status_code}, sleep {wait}s (req={resp.headers.get('X-Request-Id')})")
            time.sleep(wait)
            continue
        resp.raise_for_status()
    raise RuntimeError("Max retries exceeded")


def fetch_captions(video_id: str, lang: str = "en", fmt: str = "txt") -> str:
    submit = request_with_retry(
        "POST",
        f"{DATA_BASE}/videos/captions",
        json={"video_id": video_id, "language_code": lang, "format": fmt},
    ).json()
    if not submit.get("success"):
        raise RuntimeError(f"Submit failed: {submit}")

    job_id = str(submit["data"]["id"])
    for poll in range(30):
        result_resp = request_with_retry(
            "GET",
            f"{DATA_BASE}/videos/captions/result",
            params={"job_id": job_id, "format": fmt},
        ).json()
        data = result_resp.get("data") or {}
        status = data.get("status")
        if status == "COMPLETED":
            raw = data.get("result")
            return raw if isinstance(raw, str) else str(raw or "")
        if status == "FAILED":
            raise RuntimeError(f"Caption job {job_id} failed: {result_resp}")
        time.sleep(3)
    raise TimeoutError(f"Caption job {job_id} did not complete in 90s")


def summarize_video(video_id: str, lang: str = "en") -> None:
    transcript = fetch_captions(video_id=video_id, lang=lang, fmt="txt")
    if not transcript.strip():
        print(f"Video {video_id} returned empty captions (billable caption call: $0.0080)")
        return

    llm = OpenAI(api_key=API_KEY, base_url="https://api.apihop.ai/v1")
    resp = llm.chat.completions.create(
        model="deepseek-v4-flash",
        messages=[
            {"role": "system", "content": "Extract core conclusions, timeline highlights, and key quotes in clean Markdown."},
            {"role": "user", "content": transcript[:40000]},
        ],
        temperature=0.2,
    )
    usage = resp.usage
    llm_cost = (usage.prompt_tokens * 0.3429 + usage.completion_tokens * 1.0286) / 1_000_000
    total_cost = 0.008 + llm_cost

    out_file = f"{video_id}_summary.md"
    with open(out_file, "w", encoding="utf-8") as f:
        f.write(resp.choices[0].message.content or "")

    print(f"Saved {out_file} | Caption: $0.0080 | DeepSeek: ${llm_cost:.5f} | Total: ${total_cost:.4f}")


if __name__ == "__main__":
    summarize_video("dQw4w9WgXcQ", lang="en")

Expected output: Saved dQw4w9WgXcQ_summary.md | Caption: $0.0080 | DeepSeek: $0.0028 | Total: $0.0108 (LLM cost scales with transcript length).

Error Handling

Record both X-Request-Id and the string job_id in logs for fast troubleshooting:

HTTP StatusMeaning and Common CausesRecommended Action
202POST /captions accepted for async processingSave data.id as a string and poll /captions/result every 2–5s
400Invalid parameters (non-numeric job_id, mismatched format, missing both video_id and video_url)Verify fields against the YouTube Endpoint Reference
401Missing or invalid Authorization: Bearer keyCheck APIHOP_API_KEY
402Insufficient prepaid creditsTop up on the API Hop Pricing page
403Gateway denied or job_id belongs to another tenantPoll only with the same tenant key that submitted the job
429Concurrency or rate limit exceededPace job submissions and apply exponential backoff
5xx / transient poll errorsTemporary upstream/network issue (uncertain submissions do not replay; transient poll errors are non-terminal)Keep polling up to the 30-minute job deadline

Common Issues and Gotchas

  1. Parsing job_id or channel IDs with JavaScript Number(): IDs like 9007199254740993001 exceed Number.MAX_SAFE_INTEGER (2^53 - 1). Always treat job_id and pagination cursors as strings, or trailing digits will silently round and break polling.
  2. Submitting with default srt and polling with format=txt: Output format is fixed at creation time. Passing a mismatched format on GET /captions/result returns HTTP 400. Pass one shared format variable to both calls.
  3. Expecting Whisper audio transcription on uncaptioned videos: These endpoints retrieve existing YouTube captions (manual or auto-generated), not AI speech-to-text. Uncaptioned videos can still complete as billable $0.008 jobs with empty output.
  4. Treating data.result: null as an error: While status is PROCESSING, data.result is always null. Branch strictly on data.status (COMPLETED vs FAILED).

Cost Estimation and Workload Bills

Using a 30-minute English tutorial as a baseline (~5,000 transcript words ≈ 6,500 input tokens + 600 summary output tokens), combine POST /captions ($0.008) + /captions/result ($0) + deepseek-v4-flash ($0.3429/M input, $1.0286/M output):

Workload ScenarioCost FormulaAPI Hop CostManaged Alternatives (Ref.)
Single 30-min video (Captions + AI Summary)$0.008 + (6.5K×$0.3429 + 0.6K×$1.0286)/1K ≈ $0.008 + $0.0028$0.0108 / videoSupadata starts at $5/mo (captions only)
Weekly digest of 25 podcasts/videos (100/mo)100 × $0.0108$1.08 / monthSupadata $5/mo tier + separate LLM bill
RAG knowledge base import of 1,000 lectures (txt only)1,000 × $0.008$8.00 (one-off)Apify ~$5–$10 + $19+/mo platform fee
10-channel monitor with metadata pre-filter (400 info + 150 summaries/mo)400×$0.001 + 150×$0.0108$2.02 / monthSelf-managed residential proxies ~$15–$50/mo

A $10 minimum prepaid top-up covers roughly 925 end-to-end 30-minute video summaries, or 1,250 standalone caption extractions. The same balance also works across all 34 endpoints in the API Hop YouTube Data API plus Claude, GPT, and DeepSeek models.

What to Watch Next

  • Audio fallback for uncaptioned videos: When result is empty on niche-language uploads, pair POST /v1/youtube/web-v2/videos/streams-v3 ($0.003/call with your sticky HTTP proxy) with an ASR model as a fallback path.
  • Prefix caching on follow-up Q&A: Repeatedly querying the same cached transcript on deepseek-v4-flash drops input cost from $0.3429/M to $0.0114/M.

FAQ

Is youtube-transcript-api free, and why does it fail on cloud servers?

The open-source Python youtube-transcript-api library is free and needs no API key on a home connection. When deployed to AWS EC2, Lambda, GCP, or Vercel, YouTube flags datacenter IP blocks and throws RequestBlocked or IpBlocked. To skip buying and rotating residential proxies, fund an account on the API Hop Pricing page starting at $10 pay-as-you-go for managed caption extraction at $0.008/job with free polling.

Why not use the official YouTube Data API v3 captions.download endpoint?

YouTube Data API v3’s captions.download requires OAuth 2.0 and only works for videos owned by the authenticated channel, while consuming 200 units per call out of a 10,000-unit daily quota. For public third-party videos—research, RAG ingestion, or competitive analysis—developers rely on public data endpoints like the API Hop YouTube Data API.

Does polling /captions/result cost extra on youtube captions api jobs?

No. Submitting POST /v1/youtube/web-v2/videos/captions costs $0.008 (8,000 credits), while polling GET /v1/youtube/web-v2/videos/captions/result is $0 (0 credits). Polling every 2–5 seconds adds zero extra cost.

Are uncaptioned videos or wrong language codes billed?

Any completed execution—including an empty result because a video has no captions—bills $0.008. To avoid paying for music or uncaptioned clips in batch jobs, call GET /v1/youtube/web-v2/videos/info ($0.001) to filter videos first.

Can I pay without an overseas credit card?

Yes. API Hop accepts self-serve prepaid top-ups globally with no foreign credit card or business verification required, supporting USDT/USDC crypto plus local wallets such as Brazil PIX and Indonesia QRIS/GoPay/DANA on the API Hop Pricing page. Credits never expire.

Verification note: Endpoint paths, async billing rules, $0.008/caption-job pricing, and DeepSeek V4 Flash rates ($0.3429/$1.0286) were verified on 2026-11-27 against live API Hop docs and public market pricing (account-specific pricing applies where set).