YouTube to MP4 API
A YouTube to MP4 API turns a video link into a direct MP4 download URL your app can use right away — up to 4K resolution. This guide shows how to pick a resolution and get a ready-to-use MP4 link in one request with the Tunelio API.
How the YouTube to MP4 API works
You send a YouTube URL plus the resolution you want, and the API returns a signed CDN URL for a muxed MP4 (video and audio combined). There is no rendering queue and no polling — the download link comes back in the same response.
List resolutions, then download
Call GET /info to see which resolutions exist for a video and how large each MP4 is, then call GET /create with your chosen quality. The example below requests 1080p:
# See available MP4 resolutions and sizes (6 credits)
curl "https://tunelio.dev/info?url=https://youtu.be/dQw4w9WgXcQ" \
-H "Authorization: Bearer tnl_your_api_key"
# Get a direct 1080p MP4 URL (10 credits)
curl "https://tunelio.dev/create?url=https://youtu.be/dQw4w9WgXcQ&quality=1080p" \
-H "Authorization: Bearer tnl_your_api_key"The create response returns the MP4 url, a suggested filename, the final file_size in bytes, and an expires timestamp telling you how long the signed link stays valid.
Available MP4 resolutions
- 144p, 240p, 360p, 480p — small files for previews and low-bandwidth users.
- 720p and 1080p — the common "HD" downloads for most apps.
- 2160p (4K) — available on the Mega plan for high-resolution sources.
Node.js example
const res = await fetch(
"https://tunelio.dev/create?" + new URLSearchParams({
url: "https://youtu.be/dQw4w9WgXcQ",
quality: "1080p",
}),
{ headers: { Authorization: "Bearer " + process.env.TUNELIO_KEY } }
);
const { url, filename, file_size_str } = await res.json();
console.log(filename, file_size_str, url);Save the MP4 to your own storage
Because /create returns a plain HTTPS URL, you can stream the MP4 straight to disk or object storage without buffering the whole file in memory. Once you have the url from the /create response, it is an ordinary GET:
import requests
with requests.get(download_url, stream=True) as r:
r.raise_for_status()
with open("video.mp4", "wb") as f:
for chunk in r.iter_content(1 << 20):
f.write(chunk)If a link has passed its expires timestamp, call GET /create again for a fresh one — the metadata from GET /info has not changed, so you only repeat the final step rather than re-inspecting the video.
Next steps
See the full API documentation for the complete response schema, error codes, and rate limits, or claim 100 free credits and request your first MP4 URL.
Frequently asked questions
Can the API download 4K MP4 from YouTube?
Yes. Request quality=2160p on the Mega plan to get a 4K MP4 URL, when the source video has a 4K rendition.
Is the MP4 a single file with audio?
Yes. /create returns a muxed MP4 with video and audio combined, so the downloaded file plays directly with no extra merge step.
How long does the download URL stay valid?
The signed url includes an expires timestamp — typically a few hours — after which you simply request a fresh one.