YouTube Download API Error Codes, and How to Handle Each One

7 min read Summarize with Claude ChatGPT Gemini Perplexity
YouTube Download API Error Codes and How to Handle Them

Where errors show up

There are two places. Request errors come straight back from POST /api/start-download with an HTTP error status, before any job exists. Video errors come later, from GET /api/download-status, as "status": "error" once the job has tried and failed. Both use the same shape:

JSON
{
  "error": "Video is private",
  "error_code": 3,
  "error_label": "VIDEO_PRIVATE",
  "error_type": "video_unavailable"
}

Request errors can also include field, hint, plan_limit or retry_after. Messages may be reworded over time. Codes won't, so build your logic on error_code.

Video errors: skip the video

These describe the video itself. Retrying won't change anything.

CodeLabelMeaning
1VIDEO_DELETEDThe video has been removed
2VIDEO_UNAVAILABLEThe video is unavailable
3VIDEO_PRIVATEThe video is private
4VIDEO_GEO_RESTRICTEDBlocked in the regions we download from
5VIDEO_LIVECurrently live. Try again after the stream ends
6VIDEO_AGE_RESTRICTEDAge-restricted
7VIDEO_MEMBER_ONLYFor channel members only
8VIDEO_PREMIUM_ONLYRequires YouTube Premium
9VIDEO_UPCOMINGA scheduled stream that hasn't started
10VIDEO_TOO_LONGToo long to download
11VIDEO_SIGN_INYouTube requires sign-in for this video
12VIDEO_EMBED_DISABLEDPlayback on other websites is disabled
13VIDEO_LIVE_ENDEDThis live event has ended
31ERR_DURATION_EXCEEDEDLonger than your plan's duration limit
52ERR_FORMAT_UNAVAILABLENo stream matches your resolution, codec, container or size settings
60ERR_NO_REGIONGeo-blocked everywhere we can download from

Code 52 is the one you can often fix: loosen the request. For example, add "any" to the end of video_codec, or raise the size limit.

Slow down: wait and retry

CodeHTTPMeaningDo this
55429Too many requests for your planWait retry_after seconds, then retry
56job statusService busy, no download server freeRequest the video again in a few seconds
57503API temporarily on holdRetry later

Codes 20 (download server blocked) and 23 (retries exhausted) are related. When a download server is blocked, the job moves to another server automatically, up to 3 attempts. You only see 23 if all attempts failed.

Stop: fix the account or the request

CodeHTTPMeaning
40401Missing API key. Send it in X-API-Key
41403Invalid API key
51429Monthly video quota used
54429Monthly bandwidth used
53400Not a YouTube video URL. Playlists, channels and /live/ links are rejected
58403Feature not on your plan, such as captions, 4K or a custom format
59403Account suspended
64403Plan expired
65400Invalid parameter. The response names the field and lists the accepted ones
66403Above your plan's limits, for example file size or duration
67404Job not found, or older than the retention period
69410Download link expired. Request the video again

Partial results

Extras like captions and comments don't fail the whole job. If one fails, you still get the video, with "partial": true and a warning:

CodeMeaning
70Caption requests were rate-limited
71Captions not available in a language you asked for
72Comments unavailable
73Live chat unavailable
74Another extra failed

The exception is skip_download: when the extras are all you asked for, a failed extra fails the job.

Handling it in code

This function downloads one video and sorts every outcome into one of the three groups. We tested each branch against a mock of the API: rate limits wait and retry, private videos and bad URLs are skipped, missing captions come back as partial, and an exhausted quota stops the batch.

Python
import time

import requests

API = "https://api.videodl.app"

SKIP_VIDEO = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 30, 31, 52, 53, 60}
WAIT_AND_RETRY = {55, 56}
STOP_ALL = {40, 41, 51, 54, 57, 58, 59, 64, 66}


def download(url, api_key, **options):
    headers = {"X-API-Key": api_key}
    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:
            break
        code = body.get("error_code")
        if code in WAIT_AND_RETRY:
            time.sleep(body.get("retry_after", 10))
            continue
        if code in STOP_ALL:
            raise RuntimeError(f"Stop the batch: {code} {body.get('error')}")
        return {"url": url, "skipped": True, "error_code": code, "error": body.get("error")}

    worker_id = body["worker_id"]
    while True:
        job = requests.get(f"{API}/api/download-status", headers=headers,
                           params={"worker_id": worker_id}, timeout=30).json()
        if job["status"] == "downloaded":
            return {"url": url, "download_url": job["download_url"],
                    "partial": job.get("partial", False), "warnings": job.get("warnings", [])}
        if job["status"] == "error":
            if job.get("error_code") in SKIP_VIDEO:
                return {"url": url, "skipped": True, "error_code": job["error_code"],
                        "error": job.get("error_label")}
            raise RuntimeError(f"Failed after retries: {job.get('error_code')} {job.get('error')}")
        time.sleep(job.get("retry_after", 3))

In a batch, catch the RuntimeError to stop cleanly, and log the skipped videos with their codes so you can report why each one was missed.

FAQ

What does error code 55 mean in the VideoDL API?

Too many requests for your plan's rate limit. The response includes retry_after, the number of seconds to wait. Wait that long and send the request again.

Should I retry a VIDEO_PRIVATE or VIDEO_DELETED error?

No. Codes 1 to 13 describe the video itself, so retrying won't help. Skip the video and log the code.

What does ERR_FORMAT_UNAVAILABLE (52) mean?

No stream matched your resolution, codec, container or size settings. Loosen the request, for example by adding "any" to the end of video_codec or raising the size limit.

Why is my download marked partial?

An extra, such as captions in one language, failed while the main file succeeded. The warning gives a code from 70 to 74 explaining which extra failed.

Do I need to retry failed downloads myself?

Not for temporary failures. Jobs are retried automatically on other download servers, up to 3 attempts. You only need to handle rate limits on new requests and the final error codes.

Downloads that tell you what went wrong

Numbered errors, automatic retries on other servers, and partial results instead of failed jobs. From $12/month.