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

StatusWhereMeaningWhat to do
200 + error/playerYouTube 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, /dashmissing_parameter (no id) or invalid_id.Fix the request.
400/dl, /streamThe s token is missing or damaged.Use the link from /player unchanged.
401allMissing or wrong API key.Check the key.
403/dl, /streamYouTube refused to serve the file.Retry after a moment. If it keeps failing, tell us the video ID.
404/playernot_found: there is no video with this ID.Check the ID.
404/dl, /stream, /dashThe video or this format is no longer available.Call /player again.
410/streamYouTube re-encoded the file since you got the link, and you asked for a range.Call /player again.
416/streamThe range starts past the end of the file or is malformed.Check the Range header against contentLength.
429allToo many requests from your IP. Checked before the key.Wait for the seconds in Retry-After.
502allYouTube’s side failed or sent a broken answer. On /player the body says extraction_failed or no_streams.Retry after a moment.
503/dl, /streamThe 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.