Blog / Tutorials / Scriptube API Guide: Automate YouTube Transcript Downloads
Tutorials 10 min read • January 12, 2026

Scriptube API Guide: Automate YouTube Transcript Downloads

Founder

To automate YouTube transcript downloads, you need three things: a script that submits a batch to the API, a way to know when it's done (polling or a webhook), and an export step that saves the result as a file. This walks through building that as a script you can run on a schedule, with working Python.

Prerequisites

  • The API is available on Pro and above. Check your plan at /ui/pricing if you're not sure.
  • An API key, created from your dashboard or via POST /api/v1/keys. Keep it out of source control — treat it like a password.
  • Python 3 with the requests library (pip install requests).

Every request authenticates with an X-API-Key header against https://scriptube.me. For the full endpoint reference beyond what's used here, see the complete API guide or /docs.

Step 1: submit a batch

POST /api/v1/transcripts takes a list of URLs (videos, playlists, channels, or any mix) and returns a batch_id right away. If every video in the request was already stored, the batch can come back already completed — no waiting needed.

import requests, time, os
from datetime import date

API_KEY = os.environ["SCRIPTUBE_API_KEY"]
BASE_URL = "https://scriptube.me"
HEADERS = {"X-API-Key": API_KEY, "Content-Type": "application/json"}

VIDEO_URLS = [
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
]

def submit_batch(urls):
    resp = requests.post(
        f"{BASE_URL}/api/v1/transcripts",
        headers=HEADERS,
        json={"urls": urls, "language": "en"},
    )
    resp.raise_for_status()
    return resp.json()["batch_id"]

Step 2: wait for it to finish

Poll GET /api/v1/transcripts/{batch_id} until the status is completed (or failed). For a small daily batch, a simple sleep loop is enough:

def wait_for_batch(batch_id, poll_seconds=10, timeout_seconds=600):
    waited = 0
    while waited <= timeout_seconds:
        resp = requests.get(
            f"{BASE_URL}/api/v1/transcripts/{batch_id}",
            headers=HEADERS,
        )
        resp.raise_for_status()
        status = resp.json()["status"]
        if status in ("completed", "failed"):
            return status
        time.sleep(poll_seconds)
        waited += poll_seconds
    raise TimeoutError(f"Batch {batch_id} did not finish within {timeout_seconds}s")

Polling is fine for a small, occasional job like this. If you're running this at higher volume or need near-instant notification, a webhook or callback_url is the better fit — see webhooks vs. polling for when to switch.

Step 3: export and save the result

GET /api/v1/transcripts/{batch_id}/export takes a format parameter (json, csv, txt, jsonl, srt, or vtt). For a daily automated pull, JSONL is usually the easiest to append to a dataset or pipe into another script:

def export_batch(batch_id, fmt="jsonl"):
    resp = requests.get(
        f"{BASE_URL}/api/v1/transcripts/{batch_id}/export",
        headers=HEADERS,
        params={"format": fmt},
    )
    resp.raise_for_status()
    filename = f"transcripts-{date.today().isoformat()}.{fmt}"
    with open(filename, "wb") as f:
        f.write(resp.content)
    return filename

Putting it together

if __name__ == "__main__":
    batch_id = submit_batch(VIDEO_URLS)
    status = wait_for_batch(batch_id)
    if status == "completed":
        path = export_batch(batch_id)
        print(f"Saved {path}")
    else:
        print(f"Batch {batch_id} finished with status: {status}")

Save this as fetch_transcripts.py, set your SCRIPTUBE_API_KEY environment variable, and run it:

export SCRIPTUBE_API_KEY=sk_live_your_key_here
python3 fetch_transcripts.py

Running it on a schedule

To run this daily, add it to cron (on Linux/macOS):

0 6 * * * SCRIPTUBE_API_KEY=sk_live_your_key_here /usr/bin/python3 /path/to/fetch_transcripts.py

This runs the script at 6 AM every day. If your video list changes daily — for example, pulling a channel's latest uploads — swap VIDEO_URLS for a channel URL or @handle instead of a fixed list:

VIDEO_URLS = ["https://www.youtube.com/@somechannel"]

Channel batches are available on every plan and billed per video, so check the cost with POST /api/v1/transcripts/estimate before pointing this at a high-upload-volume channel — see channel batch costs.

Logging instead of just printing

A script that only runs on a schedule and prints to a terminal nobody's watching won't tell you much when it fails at 6 AM. Swap the print() calls for Python's logging module writing to a file, so you have a record to check when a cron run doesn't produce the file you expected:

import logging

logging.basicConfig(
    filename="fetch_transcripts.log",
    level=logging.INFO,
    format="%(asctime)s %(levelname)s %(message)s",
)

Handling errors

Errors come back as {code, message, detail}. The ones worth handling explicitly in a scheduled script:

  • 402 — insufficient credits. Top up a credit pack or check your plan before the next run.
  • 429 — rate limited; the response includes a Retry-After header telling you how long to wait.
  • 409 (elevenlabs_disabled) — only relevant if you're requesting AI transcription for caption-less videos, which is not available yet.

A production version of this script should catch these and retry or alert instead of failing silently — for example, wrapping the submit/export calls and checking the error code field before deciding whether to retry.

Retrying failed items instead of the whole batch

If a batch finishes with some items failed and others succeeded, you don't need to resubmit the whole thing — POST /api/v1/transcripts/{batch_id}/retry-failed requeues just the failed items. See retrying failed transcripts for the full options.

Avoiding duplicate submissions

If your scheduled script might run twice for the same window (a retry, an overlapping cron job), use POST /api/v1/transcripts/resolve with an Idempotency-Key header instead of the plain submit endpoint — it returns the same result for a repeated request instead of creating a second batch. See idempotency keys for safe retries.

Isolating dependencies

For a script that runs unattended on a schedule, keep its dependencies isolated rather than relying on whatever happens to be installed globally on the machine:

python3 -m venv venv
source venv/bin/activate
pip install requests
pip freeze > requirements.txt

Point your cron job at the virtual environment's Python interpreter (venv/bin/python3) instead of the system one, so a later global package change doesn't silently break the scheduled job.

Next step

This script covers the minimum automation loop: submit, wait, export. From here, swap polling for a webhook, add retry handling, or point it at a channel instead of a fixed list. Full reference for every endpoint used here (and the ones not covered) is at /docs, including the Postman collection if you'd rather explore interactively before scripting it.

Try Scriptube Free

Extract YouTube transcripts instantly. No credit card required.

Get Started

Related Articles

Tutorials

Your YouTube Transcript Library: Find Everything You've Already Processed

Every video you've ever submitted to Scriptube stays in your library — browsable by channel and playlist, searchable when you need to find something you...

Tutorials

Paginating Large YouTube Transcript Batches

A batch with hundreds of videos doesn't come back in one response. GET /api/v1/transcripts/{batch_id} pages its items with skip/limit, and tells you when...

Tutorials

How to Retry Failed YouTube Transcripts Without Resubmitting the Batch

A batch of 50 videos rarely comes back 50 for 50 — a couple of videos might have no captions, one might hit a rate limit, another might just need a second...