Reference
Errors
Error bodies
/player answers errors as JSON:
{
"error": "invalid_id",
"message": "invalid video id"
}
/dl, /stream and authentication errors answer with a short plain text body.
Status codes
| Status | Where | Meaning | What to do |
|---|---|---|---|
200 + error | /player | YouTube does not serve this video (no_streams) or asked for a bot check (bot_check). | no_streams: do not retry. bot_check: retry. See /player. |
400 | /player, /dash | missing_parameter (no id) or invalid_id. | Fix the request. |
400 | /dl, /stream | The s token is missing or damaged. | Use the link from /player unchanged. |
401 | all | Missing or wrong API key. | Check the key. |
403 | /dl, /stream | YouTube refused to serve the file. | Retry after a moment. If it keeps failing, tell us the video ID. |
404 | /player | not_found: there is no video with this ID. | Check the ID. |
404 | /dl, /stream, /dash | The video or this format is no longer available. | Call /player again. |
410 | /stream | YouTube re-encoded the file since you got the link, and you asked for a range. | Call /player again. |
416 | /stream | The range starts past the end of the file or is malformed. | Check the Range header against contentLength. |
429 | all | Too many requests from your IP. Checked before the key. | Wait for the seconds in Retry-After. |
502 | all | YouTube’s side failed or sent a broken answer. On /player the body says extraction_failed or no_streams. | Retry after a moment. |
503 | /dl, /stream | The server is at capacity. | Wait for the seconds in Retry-After (5), then retry. |
When YouTube itself answers a lookup with an error status, /player passes that status on
with extraction_failed, so other codes are possible there.
Retrying
Rule of thumb
Retry 403, 429, 502, 503 and bot_check, with the wait from Retry-After where
there is one. On 404 from /dl or /stream and on 410, call /player again first. Do
not retry 400, 401, 416 or no_streams.