Endpoints

/dl

GET/dl?s=TOKENBilled per request

Downloads one format as a file. The server fetches it from YouTube piece by piece and sends it to you as one continuous response, so a long download does not slow down the way a single long connection to YouTube does.

You do not build this URL. Take the downloadUrl of a format from the /player response and request it as it is.

Parameters

All of them are already in downloadUrl.

ParameterDescription
sOpaque token for this video and format. Do not decode or change it.
vidThe video ID.
keyYour API key.
nameFile name for the Content-Disposition header. Set by /player from the title; you can replace it. Quotes, slashes and control characters are removed, and an extension is added if missing.

Response

HTTP/2 200
content-type: audio/mp4; codecs="mp4a.40.2"
content-length: 10271433
accept-ranges: none
content-disposition: attachment; filename="Big Buck Bunny 60fps 4K - Official Blender Foundation Short Film.m4a"
  • 200 with the whole file, every time.
  • Content-Length is the full file size, so progress bars work from the first byte.
  • Content-Type is the format’s full mimeType, codecs included.
  • Content-Disposition: attachment tells browsers to save the file.

No ranges, no resume

/dl drops a Range (and If-Range) header and always sends the complete file. The response says so with Accept-Ranges: none. Many HTTP clients add a Range header on their own; a partial answer would look like a finished download that is silently cut short.

If a download breaks off, start it again from the beginning. For partial content, use /stream, which supports ranges.

Examples

All examples write the body to disk as it arrives, without holding the file in memory.

# -o picks the file name. Use -OJ to take the name from Content-Disposition.
curl --fail -o bunny.m4a "$DOWNLOAD_URL"
import { createWriteStream } from 'node:fs';
import { Readable } from 'node:stream';
import { pipeline } from 'node:stream/promises';

const res = await fetch(format.downloadUrl);
if (!res.ok) throw new Error(`download failed: ${res.status} ${await res.text()}`);

const total = Number(res.headers.get('content-length'));
console.log(`downloading ${total} bytes`);
await pipeline(Readable.fromWeb(res.body), createWriteStream('bunny.m4a'));
import requests

with requests.get(fmt["downloadUrl"], stream=True, timeout=30) as r:
    r.raise_for_status()
    total = int(r.headers["Content-Length"])
    print(f"downloading {total} bytes")
    with open("bunny.m4a", "wb") as out:
        for chunk in r.iter_content(chunk_size=1 << 20):
            out.write(chunk)
// reqwest = { version = "0.13", features = ["stream"] }, futures-util = "0.3"
use futures_util::StreamExt;
use tokio::io::AsyncWriteExt;

let res = reqwest::get(download_url).await?.error_for_status()?;
println!("downloading {:?} bytes", res.content_length());

let mut file = tokio::fs::File::create("bunny.m4a").await?;
let mut body = res.bytes_stream();
while let Some(chunk) = body.next().await {
    file.write_all(&chunk?).await?;
}
file.flush().await?;
Video and audio are separate

A video format has no sound and an audio format has no picture. Download one of each and merge them on your side, for example with ffmpeg -i video.mp4 -i audio.m4a -c copy out.mp4. See Formats.

Billing

Each request to /dl is billed at PRICE, whatever the file size.