Start
Quickstart
ytbro.net is an HTTP API for YouTube downloads. You send a video ID, you get every format YouTube offers, and each format comes with a ready link for downloading and one for streaming.
All endpoints are GET and live under one base URL:
https://api.ytbro.net
1. Get a key
There is no signup. Write to or to on Discord, tell us what you are building and roughly how many requests you expect, and we send you a key.
Send the key with every request, either as a header or as a query parameter. See Authentication.
2. Look up the video
Call /player with the YouTube video ID. That is the part after v= in a
YouTube link: for youtube.com/watch?v=aqz-KE-bpKQ it is aqz-KE-bpKQ.
curl -H "X-API-Key: $YTBRO_KEY" "https://api.ytbro.net/player?id=aqz-KE-bpKQ"const res = await fetch('https://api.ytbro.net/player?id=aqz-KE-bpKQ', {
headers: { 'X-API-Key': process.env.YTBRO_KEY },
});
const player = await res.json();import os, requests
player = requests.get(
"https://api.ytbro.net/player",
params={"id": "aqz-KE-bpKQ"},
headers={"X-API-Key": os.environ["YTBRO_KEY"]},
timeout=30,
).json()let player: serde_json::Value = reqwest::Client::new()
.get("https://api.ytbro.net/player?id=aqz-KE-bpKQ")
.header("X-API-Key", std::env::var("YTBRO_KEY")?)
.send()
.await?
.json()
.await?;The response lists every format under adaptiveFormats. Each one has an itag (YouTube’s
format ID), a mimeType, a size in contentLength, and two links:
{
"itag": 140,
"mimeType": "audio/mp4; codecs=\"mp4a.40.2\"",
"contentLength": "10271433",
"downloadUrl": "https://api.ytbro.net/dl?s=AQm8sV3n…&key=YOUR_KEY&vid=aqz-KE-bpKQ&name=…",
"streamUrl": "https://api.ytbro.net/stream?s=AQm8sV3n…&key=YOUR_KEY&vid=aqz-KE-bpKQ"
}
3. Use the link
Pick a format and request its downloadUrl to save the file, or use its streamUrl as the
source of a video player. Do not build these links yourself. Take them from the response as
they are.
curl -o bunny.m4a "$DOWNLOAD_URL"import { createWriteStream } from 'node:fs';
import { Readable } from 'node:stream';
import { pipeline } from 'node:stream/promises';
const audio = player.adaptiveFormats.find((f) => f.itag === 140);
const file = await fetch(audio.downloadUrl);
await pipeline(Readable.fromWeb(file.body), createWriteStream('bunny.m4a'));audio = next(f for f in player["adaptiveFormats"] if f["itag"] == 140)
with requests.get(audio["downloadUrl"], stream=True, timeout=30) as r:
r.raise_for_status()
with open("bunny.m4a", "wb") as out:
for chunk in r.iter_content(chunk_size=1 << 20):
out.write(chunk)let url = player["adaptiveFormats"]
.as_array()
.and_then(|formats| formats.iter().find(|f| f["itag"] == 140))
.and_then(|f| f["downloadUrl"].as_str())
.ok_or("itag 140 not in response")?;
let bytes = reqwest::get(url).await?.error_for_status()?.bytes().await?;
tokio::fs::write("bunny.m4a", &bytes).await?;The Rust snippet above loads the file into memory for brevity. For video files, stream the body to disk instead. The /dl reference has a streaming version for every language.
What you pay for
| Endpoint | Billed |
|---|---|
/player | No, free under fair use |
/dl | PRICE per request |
/stream | PRICE per request |
/dash | No. The segments a player loads through /stream are billed. |
/player is free under fair use: it is there to find the file you then fetch with /dl or
/stream. Lookups that never lead to a download or a stream are not what it is for.