Endpoints
/player
Looks up a video and returns its details and every format YouTube offers. Each format comes
with a downloadUrl for /dl and a streamUrl for /stream.
Calls to /player are free under fair use: it is there to find the file you then fetch with
/dl or /stream, not to be used as a metadata API on its own.
Parameters
| Parameter | Required | Description |
|---|---|---|
id | yes | YouTube video ID, for example aqz-KE-bpKQ. Letters, digits, _ and -, up to 20 characters. |
webm | no | true adds the WebM formats (VP9 video, Opus audio). Without it, only MP4 and M4A are listed. |
key | no | Your API key, if you do not send the X-API-Key header. |
Request
curl -H "X-API-Key: $YTBRO_KEY" "https://api.ytbro.net/player?id=aqz-KE-bpKQ&webm=true"const url = new URL('/player', 'https://api.ytbro.net');
url.searchParams.set('id', 'aqz-KE-bpKQ');
url.searchParams.set('webm', 'true');
const player = await fetch(url, { headers: { 'X-API-Key': process.env.YTBRO_KEY } }).then((r) => r.json());
if (player.error) throw new Error(`${player.error}: ${player.message}`);
console.log(player.title, player.adaptiveFormats.length, 'formats');player = requests.get(
"https://api.ytbro.net/player",
params={"id": "aqz-KE-bpKQ", "webm": "true"},
headers={"X-API-Key": os.environ["YTBRO_KEY"]},
timeout=30,
).json()
if "error" in player:
raise RuntimeError(f'{player["error"]}: {player["message"]}')
print(player["title"], len(player["adaptiveFormats"]), "formats")let player: serde_json::Value = reqwest::Client::new()
.get("https://api.ytbro.net/player?id=aqz-KE-bpKQ&webm=true")
.header("X-API-Key", std::env::var("YTBRO_KEY")?)
.send()
.await?
.json()
.await?;
if let Some(err) = player["error"].as_str() {
return Err(format!("{err}: {}", player["message"]).into());
}
println!("{} {} formats", player["title"], player["adaptiveFormats"].as_array().map_or(0, Vec::len));Response
{
"videoId": "aqz-KE-bpKQ",
"title": "Big Buck Bunny 60fps 4K - Official Blender Foundation Short Film",
"lengthSeconds": "635",
"duration": "10:35",
"expiresInSeconds": "21540",
"dashUrl": "https://api.ytbro.net/dash/aqz-KE-bpKQ.mpd?key=YOUR_KEY",
"formats": [],
"adaptiveFormats": [
{
"itag": 137,
"mimeType": "video/mp4; codecs=\"avc1.640028\"",
"bitrate": 4372515,
"width": 1920,
"height": 1080,
"contentLength": "158614275",
"quality": "hd1080",
"qualityLabel": "1080p60",
"fps": 60,
"audioQuality": null,
"audioSampleRate": null,
"audioChannels": null,
"averageBitrate": 1998361,
"lastModified": "1704823194503522",
"approxDurationMs": "634566",
"initRange": {
"start": "0",
"end": "741"
},
"indexRange": {
"start": "742",
"end": "2297"
},
"colorInfo": null,
"projectionType": "RECTANGULAR",
"signatureCipher": null,
"xtags": null,
"streamUrl": "https://api.ytbro.net/stream?s=AWf3k9QmZ0xV1c8pNbH2rT6uYs4LgEoJ_aKdW7iCqXnRvBy5Mz-tPhSjUeOlFwDGA0b9N1cxk2mQ4rT8vYz3sLpHjEoWnBgKdCuIfRaVqXy7Zt-M_e5&key=YOUR_KEY&vid=aqz-KE-bpKQ",
"downloadUrl": "https://api.ytbro.net/dl?s=AWf3k9QmZ0xV1c8pNbH2rT6uYs4LgEoJ_aKdW7iCqXnRvBy5Mz-tPhSjUeOlFwDGA0b9N1cxk2mQ4rT8vYz3sLpHjEoWnBgKdCuIfRaVqXy7Zt-M_e5&key=YOUR_KEY&vid=aqz-KE-bpKQ&name=Big+Buck+Bunny+60fps+4K+-+Official+Blender+Foundation+Short+Film.mp4"
},
{
"itag": 251,
"mimeType": "audio/webm; codecs=\"opus\"",
"bitrate": 147815,
"width": null,
"height": null,
"contentLength": "10417652",
"quality": "tiny",
"qualityLabel": null,
"fps": null,
"audioQuality": "AUDIO_QUALITY_MEDIUM",
"audioSampleRate": "48000",
"audioChannels": 2,
"averageBitrate": 131337,
"lastModified": "1704822981164910",
"approxDurationMs": "634581",
"initRange": {
"start": "0",
"end": "258"
},
"indexRange": {
"start": "259",
"end": "1352"
},
"colorInfo": null,
"projectionType": null,
"signatureCipher": null,
"xtags": null,
"streamUrl": "https://api.ytbro.net/stream?s=AXc2pR8tLk4mNq7Vb1sY0wHgE3uJfZ9oKd6aCiTxWnBy5Pv-rMhSjQeUlGzDFA4b2N8cyk1mR3qT7vXz6sLpHjDoWnBgKeCuIfRaVqXy9Zt_M-e4&key=YOUR_KEY&vid=aqz-KE-bpKQ",
"downloadUrl": "https://api.ytbro.net/dl?s=AXc2pR8tLk4mNq7Vb1sY0wHgE3uJfZ9oKd6aCiTxWnBy5Pv-rMhSjQeUlGzDFA4b2N8cyk1mR3qT7vXz6sLpHjDoWnBgKeCuIfRaVqXy9Zt_M-e4&key=YOUR_KEY&vid=aqz-KE-bpKQ&name=Big+Buck+Bunny+60fps+4K+-+Official+Blender+Foundation+Short+Film.weba"
},
{
"itag": 140,
"mimeType": "audio/mp4; codecs=\"mp4a.40.2\"",
"bitrate": 130472,
"width": null,
"height": null,
"contentLength": "10271433",
"quality": "tiny",
"qualityLabel": null,
"fps": null,
"audioQuality": "AUDIO_QUALITY_MEDIUM",
"audioSampleRate": "44100",
"audioChannels": 2,
"averageBitrate": 129472,
"lastModified": "1704822977813452",
"approxDurationMs": "634623",
"initRange": {
"start": "0",
"end": "631"
},
"indexRange": {
"start": "632",
"end": "1435"
},
"colorInfo": null,
"projectionType": null,
"signatureCipher": null,
"xtags": null,
"streamUrl": "https://api.ytbro.net/stream?s=AQm8sV3nKj2pLc9Xb7tR4wHgF1uYeZ0oJd5aCiNxWqBy6Pv_rThSkMeUlGzDEA2b7N3cxk9mR1qT4vYz8sLpHjCoWnBgKfDuIeRaVqXz5Yt-M_e1&key=YOUR_KEY&vid=aqz-KE-bpKQ",
"downloadUrl": "https://api.ytbro.net/dl?s=AQm8sV3nKj2pLc9Xb7tR4wHgF1uYeZ0oJd5aCiNxWqBy6Pv_rThSkMeUlGzDEA2b7N3cxk9mR1qT4vYz8sLpHjCoWnBgKfDuIeRaVqXz5Yt-M_e1&key=YOUR_KEY&vid=aqz-KE-bpKQ&name=Big+Buck+Bunny+60fps+4K+-+Official+Blender+Foundation+Short+Film.m4a"
}
]
}Top level
| Field | Type | Description |
|---|---|---|
videoId | string | The ID you asked for. |
title | string | Video title. |
lengthSeconds | string | Duration in seconds. |
duration | string | The same duration as M:SS or H:MM:SS. |
expiresInSeconds | string | How long the links in this response stay valid, as YouTube sets it. Usually about 6 hours. Call /player again after that. |
dashUrl | string | MPEG-DASH manifest that combines video and audio for browser players. See /dash. |
formats | array | Formats with video and sound in one file. YouTube no longer serves these, so this is normally empty. |
adaptiveFormats | array | Every video track and every audio track, one object each. |
Format object
Fields that do not apply to a format are null, for example width on an audio track.
| Field | Type | Description |
|---|---|---|
itag | number | YouTube’s format ID. See Formats. |
mimeType | string | Container and codec, for example video/mp4; codecs="avc1.640028". |
contentLength | string | File size in bytes. |
bitrate, averageBitrate | number | Peak and average bitrate in bits per second. |
width, height | number | Video resolution. |
qualityLabel | string | Readable quality, for example 1080p60. |
quality | string | YouTube’s quality name, for example hd1080. |
fps | number | Frames per second. |
audioQuality | string | For audio, as YouTube names it, for example AUDIO_QUALITY_MEDIUM. |
audioSampleRate | string | Sample rate in Hz. |
audioChannels | number | Number of audio channels. |
approxDurationMs | string | Track duration in milliseconds. |
lastModified | string | Version of the file on YouTube’s side. |
initRange, indexRange | object | Byte ranges of the init segment and the segment index, { "start", "end" }. Players use them for seeking. |
audioTrack | object | Only on videos with several audio languages. See below. |
isDrc | boolean | Only on videos that offer it: a version of the same audio track with compressed dynamic range. |
downloadUrl | string | Link for /dl. Saves the file. Billed. |
streamUrl | string | Link for /stream. For players. Billed. |
A format that YouTube serves without a usable link has no downloadUrl and no streamUrl.
Skip it. The response may contain further fields that YouTube sends. Ignore the ones you do
not need.
Videos with several audio languages
Some videos carry dubbed audio tracks. YouTube lists them all under the same itag, so
itag 140 can appear twenty times, once per language. Each one carries an audioTrack block:
"audioTrack": {
"displayName": "English (US) original",
"id": "en-US.4",
"audioIsDefault": true
}
A dubbed track has audioIsDefault: false, and an automatic dub also has
isAutoDubbed: true.
Within one itag the original language comes first. If you search by itag and take the first
match, you get the original. Look at audioTrack.id to pick another language.
When a video has no streams
Age restricted, private, removed or still processing videos have no streams. That is a
verdict about the video, not an error on our side, so the answer is 200 with an error
field. Always check for it.
{
"error": "no_streams",
"message": "no streams (LOGIN_REQUIRED: Sign in to confirm your age)",
"status": "LOGIN_REQUIRED",
"reason": "Sign in to confirm your age"
}
error | Meaning | What to do |
|---|---|---|
no_streams | YouTube does not serve this video. status and reason say why. | Do not retry. |
bot_check | YouTube asked for a bot check on this request. | Retry. The next attempt usually works. |
Other failures use HTTP status codes and the same JSON shape, for example not_found with
404 or extraction_failed with the status YouTube answered. See Errors.
Every downloadUrl, streamUrl and dashUrl carries the key you called /player with.
See Authentication.