How to Run Bulk YouTube Downloads Through an API Without Hitting Rate Limits

7 min read Summarize with Claude ChatGPT Gemini Perplexity
Bulk YouTube Downloads by API: Rate Limits and Queueing

Rate limit, running jobs and finish time are different things

MeasureWhat it limitsVideoDL
Start rateNew jobs you can submit per minuteStarter 1/min, Growth 3/min, custom on request
Status checksHow often you can ask about jobs300 per minute
Running jobsJobs in progress at onceNot capped per plan. Jobs wait in a queue when download servers are busy
Finish timeWhen each file is readyDepends on length, resolution and size

The start rate decides how long a batch takes to submit. 200 videos at 1 per minute takes about 3 hours and 20 minutes. At 3 per minute, 500 videos take about 2 hours and 47 minutes. Jobs finish while you're still submitting, so the last file is usually ready a few minutes after the last submission.

What happens if you go too fast

The API answers with HTTP 429 and error code 55, plus retry_after: the seconds until you can submit again. Nothing is lost, but sending faster doesn't help. Pace your requests instead, and treat a 429 as "wait, then retry the same video".

Sending all requests at once triggers HTTP 429 errors, while paced requests all succeed
Sent all at once, the extra requests get a 429. Paced, every one goes through.

Two other 429 responses look similar but mean stop: code 51 (monthly video quota used) and code 54 (monthly bandwidth used). Retrying those won't work until the quota resets or you upgrade. Check your remaining quota first with GET /api/usage.

The script

Put one YouTube URL per line in urls.txt, set VIDEODL_API_KEY, and set VIDEODL_RPM to your plan's rate (1 for Starter, 3 for Growth). Then run python3 batch_download.py urls.txt results.csv.

Python
import csv
import os
import sys
import time

import requests

API = "https://api.videodl.app"
HEADERS = {"X-API-Key": os.environ["VIDEODL_API_KEY"]}
REQUESTS_PER_MINUTE = float(os.environ.get("VIDEODL_RPM", "1"))
OPTIONS = {"resolution": "1080"}
STOP = {40, 41, 51, 54, 58, 59, 64, 66}


def submit(url):
    while True:
        r = requests.post(f"{API}/api/start-download", headers=HEADERS,
                          json={"url": url, **OPTIONS}, timeout=30)
        body = r.json()
        if r.status_code == 202:
            return body["worker_id"], None
        if body.get("error_code") == 55:
            time.sleep(body.get("retry_after", 60))
            continue
        if body.get("error_code") in STOP:
            sys.exit(f"Stopping: {body.get('error_code')} {body.get('error')}")
        return None, body


def check(jobs, results):
    for worker_id, url in list(jobs.items()):
        job = requests.get(f"{API}/api/download-status", headers=HEADERS,
                           params={"worker_id": worker_id}, timeout=30).json()
        time.sleep(0.25)
        if job.get("status") == "downloaded":
            results.append({"url": url, "status": "downloaded", "error_code": "",
                            "detail": job.get("size_human", ""), "download_url": job["download_url"]})
            del jobs[worker_id]
        elif job.get("status") == "error":
            results.append({"url": url, "status": "failed", "error_code": job.get("error_code"),
                            "detail": job.get("error_label") or job.get("error"), "download_url": ""})
            del jobs[worker_id]


def main(infile, outfile):
    urls = [line.strip() for line in open(infile) if line.strip()]
    gap = 60 / REQUESTS_PER_MINUTE
    jobs, results = {}, []
    for i, url in enumerate(urls):
        started = time.time()
        worker_id, error = submit(url)
        if worker_id:
            jobs[worker_id] = url
        else:
            results.append({"url": url, "status": "rejected", "error_code": error.get("error_code"),
                            "detail": error.get("error"), "download_url": ""})
        check(jobs, results)
        print(f"{i + 1}/{len(urls)} submitted, {len(jobs)} running, {len(results)} finished")
        if i < len(urls) - 1:
            time.sleep(max(0, gap - (time.time() - started)))
    while jobs:
        time.sleep(3)
        check(jobs, results)

    with open(outfile, "w", newline="", encoding="utf-8") as f:
        writer = csv.DictWriter(f, fieldnames=["url", "status", "error_code", "detail", "download_url"])
        writer.writeheader()
        writer.writerows(results)
    done = sum(r["status"] == "downloaded" for r in results)
    print(f"Done: {done} downloaded, {len(results) - done} not downloaded. See {outfile}")


if __name__ == "__main__":
    main(sys.argv[1], sys.argv[2])

What it does:

  • Paces submissions to your plan's rate, and waits retry_after if it's ever told to slow down.
  • Checks running jobs between submissions, with a short pause between status calls so a long list stays well under 300 checks a minute.
  • Stops the whole batch on account-level errors (bad key, quota used, plan limit), so you don't burn through a list that can't succeed.
  • Records every video in results.csv: downloaded with its link, failed with its error code, or rejected before it started.

We tested it against a mock of the API with good videos, a private video, an invalid URL and a forced rate limit. It finished all six and logged each outcome correctly.

Change what you download

Edit OPTIONS to change every job in the batch. For example:

  • {"audio_only": True, "audio_format": "mp3"} for audio only. See YouTube to MP3 by API.
  • {"resolution": "1080", "video_codec": ["avc1", "any"]} for H.264 where available. See H.264-only downloads.
  • {"skip_download": True, "captions": True} for subtitles and metadata only. See subtitles by API.

Anything you leave out uses the defaults saved in your dashboard's Download Settings.

Hosted download links expire after about an hour, and a big batch takes longer than that. Either download each file as soon as its row is written, or connect your own storage in the dashboard. Then every file lands in your S3, GCS, R2 or Google Drive and stays there. Setup is in delivering downloads to your cloud.

Retrying the failures

Filter results.csv by error_code. Codes 1 to 13 are about the video itself (private, deleted, geo-blocked), so leave those out. Code 52 means no stream matched your settings, so loosen OPTIONS and run just those URLs again. The full list is in YouTube download API error codes. Temporary download problems are retried for you on other servers, so you won't see them here.

When the rate limit is the bottleneck

If you regularly need thousands of videos, an API plan's start rate makes batches slow. Two better fits: a bulk download job, where you hand over the whole list and we run it, or a custom API plan with a higher rate. Per-video vs per-GB pricing shows how the costs compare.

FAQ

What's the VideoDL API rate limit?

Starter allows 1 new download a minute and Growth allows 3. The status endpoint allows 300 checks a minute. Custom plans have higher rates.

What does a 429 error with code 55 mean?

You started jobs faster than your plan allows. The response includes retry_after, the seconds to wait. Wait, then resend the same request.

How long does it take to download 500 YouTube videos by API?

On a 3-per-minute plan, submitting 500 videos takes about 2 hours 47 minutes. Jobs finish while you submit, so the last file is ready shortly after the last submission.

How many downloads can run at the same time?

The plan limits how fast you start jobs, not how many run. Jobs started earlier keep running while you submit new ones.

How do I avoid download links expiring during a big batch?

Download each file as soon as it's ready, or connect S3, GCS, R2 or Google Drive in your dashboard so files are delivered to your storage and don't expire.

Thousands of videos? Hand us the list

Bulk jobs run without rate limits on your side, delivered to your cloud, from $9.99 per 1,000 videos.