A FastAPI-based wrapper for the ytdlp.online service that provides a clean REST API interface for downloading videos using yt-dlp.
-
π Three API Approaches:
- Generic Endpoint - User-friendly query parameters for common use cases
- Custom Endpoint - Full control with raw yt-dlp parameters
- Synchronous Endpoint - Wait for completion and get download URL directly
-
π‘ Real-time Progress - Server-Sent Events (SSE) streaming for live download progress
-
π΅ Audio Extraction - Download audio-only with format conversion
-
πΊ Playlist Support - Download entire playlists or specific items
-
π CORS Enabled - Ready for web application integration
-
π Auto Documentation - Interactive API docs with Swagger UI
- Clone the repository:
git clone <repository-url>
cd ytdlp-online- Create virtual environment (recommended):
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Configure environment (optional):
cp .env.example .env
# Edit .env with your preferred settings# Development mode with auto-reload
uvicorn main:app --reload
# Production mode
uvicorn main:app --host 0.0.0.0 --port 8000Or run directly:
python main.pyThe API will be available at http://localhost:8000
Visit http://localhost:8000/docs for interactive Swagger UI documentation.
Endpoint: POST /api/download
Download videos with user-friendly query parameters and real-time progress streaming.
Example:
curl -N "http://localhost:8000/api/download?url=https://www.youtube.com/watch?v=dQw4w9WgXcQ&quality=720p&format=mp4"Query Parameters:
url(required) - Video URL to downloadformat- Video format (best, worst, mp4, webm)quality- Quality selection (best, 1080p, 720p, 480p)audio_only- Extract audio only (boolean)audio_format- Audio format (mp3, aac, m4a)playlist- Download entire playlist (boolean)playlist_items- Specific playlist items (e.g., "1-5,8,10-12")subtitles- Download subtitles (boolean)subtitle_lang- Subtitle language code (e.g., "en", "es")
Endpoint: POST /api/download/custom
Full control with raw yt-dlp parameters.
Example:
curl -X POST "http://localhost:8000/api/download/custom" \
-H "Content-Type: application/json" \
-d '{
"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"params": ["-f", "bestvideo+bestaudio", "--merge-output-format", "mp4"]
}'Endpoint: POST /api/download/sync
Wait for download completion and get the download URL directly.
Example:
curl -X POST "http://localhost:8000/api/download/sync?url=https://www.youtube.com/watch?v=dQw4w9WgXcQ&quality=720p"Response:
{
"status": "completed",
"download_url": "https://ytdlp.online/download/video.mp4",
"filename": "video.mp4",
"message": "Download completed successfully",
"progress": {
"status": "completed",
"message": "100% of 4.24MiB",
"percent": 100.0
}
}Endpoint: GET /api/help
Retrieve yt-dlp help information to discover available options.
Example:
curl "http://localhost:8000/api/help"Endpoint: GET /api/health
Check API health status.
Example:
curl "http://localhost:8000/api/health"Environment variables (.env file):
# ytdlp.online API Configuration
YTDLP_ONLINE_URL=https://ytdlp.online
# Download timeout in seconds (for synchronous endpoint)
DOWNLOAD_TIMEOUT=300
# API Configuration
API_TITLE=ytdlp.online API Wrapper
API_VERSION=1.0.0
API_DESCRIPTION=FastAPI wrapper for ytdlp.online service
# CORS Configuration (comma-separated origins)
CORS_ORIGINS=*
# Server Configuration
HOST=0.0.0.0
PORT=8000ytdlp-online/
βββ main.py # FastAPI application entry point
βββ config.py # Configuration management
βββ requirements.txt # Python dependencies
βββ .env.example # Environment variables template
βββ models/
β βββ __init__.py
β βββ schemas.py # Pydantic models
βββ services/
β βββ __init__.py
β βββ ytdlp_client.py # ytdlp.online client
βββ routers/
β βββ __init__.py
β βββ download.py # Download endpoints
βββ reference/ # Reference files
βββ ytdlp_online._help.txt
βββ ytdlp_vido download.txt
curl -N "http://localhost:8000/api/download?url=https://www.youtube.com/watch?v=dQw4w9WgXcQ&audio_only=true&audio_format=mp3"curl -N "http://localhost:8000/api/download?url=https://www.youtube.com/playlist?list=PLxxx&playlist=true&playlist_items=1-5"curl -N "http://localhost:8000/api/download?url=https://www.youtube.com/watch?v=dQw4w9WgXcQ&subtitles=true&subtitle_lang=en"curl -X POST "http://localhost:8000/api/download/sync?url=https://www.youtube.com/watch?v=dQw4w9WgXcQ&quality=best"# Install test dependencies
pip install pytest pytest-asyncio httpx
# Run tests
pytestThis project follows PEP 8 guidelines. Format code with:
pip install black
black .MIT License - See LICENSE file for details
Contributions are welcome! Please feel free to submit a Pull Request.
- yt-dlp - The amazing video downloader
- ytdlp.online - Online yt-dlp service
- FastAPI - Modern web framework
