📄 Documentation

Overview

YT Downloader is a single-file, stateless YouTube downloader. No database, no authentication, no sessions. Paste a URL, choose quality, and download. Everything runs from one FastAPI app.

Usage

  1. Open the home page
  2. Paste a YouTube URL into the input field
  3. Click Fetch Info — thumbnail, title, and duration appear
  4. Select your preferred quality from the dropdown
  5. Click Download Video or Download Audio

API Reference

All endpoints return JSON (except download endpoints which stream files).

Get Video Info

GET /yt/info?url=<youtube_url>

Returns video metadata — title, thumbnail, duration, available formats.

{
  "title": "Example Video",
  "thumbnail": "https://i.ytimg.com/vi/.../maxresdefault.jpg",
  "duration": "4:32",
  "duration_seconds": 272,
  "channel": "Channel Name",
  "formats": [
    {"format_id": "137", "ext": "mp4", "height": 1080, "label": "1080p", "filesize": 12345678},
    {"format_id": "136", "ext": "mp4", "height": 720,  "label": "720p",  "filesize": 6543210}
  ]
}

Download Video

GET /yt/video?url=<youtube_url>&quality=<best|720|480|360>

Streams the video file as an MP4 attachment. Quality defaults to best.

Download Audio

GET /yt/audio?url=<youtube_url>

Extracts audio and streams as an MP3 attachment (192 kbps).

Quick Examples

# Get info
curl "https://your-app.com/yt/info?url=https://youtube.com/watch?v=dQw4w9WgXcQ"

# Download best video
curl -o video.mp4 "https://your-app.com/yt/video?url=https://youtube.com/watch?v=dQw4w9WgXcQ"

# Download 720p video
curl -o video.mp4 "https://your-app.com/yt/video?url=https://youtube.com/watch?v=dQw4w9WgXcQ&quality=720"

# Download audio
curl -o audio.mp3 "https://your-app.com/yt/audio?url=https://youtube.com/watch?v=dQw4w9WgXcQ"

Deployment

Local

pip install -r requirements.txt
uvicorn main:app --reload --port 8000

Docker

docker build -t yt-downloader .
docker run -p 8000:8000 yt-downloader

Railway / Render

Push to GitHub → create new service → select your repo. Railway auto-detects the Dockerfile. Render users should use the Docker deploy method.

Tech Stack

ComponentVersion
Python3.11+
FastAPIlatest
yt-dlplatest (auto-upgraded)
ffmpegsystem package
Jinja2latest
uvicornlatest