Skip to content

🎧 A lightweight Flask API that converts YouTube videos to high-quality MP3 audio β€” with secure, token-based download access. Powered by yt-dlp & FFmpeg.

License

Notifications You must be signed in to change notification settings

alperensumeroglu/yt-audio-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎧 YouTube Audio Converter API

Developed with precision by Alperen SΓΌmeroğlu β€” turning YouTube audio into clean, downloadable MP3s with elegance.

A high-performance Flask API that transforms any public YouTube video into a high-quality MP3 audio file β€” instantly, securely, and reliably. Powered by yt-dlp and FFmpeg, this API handles downloading, conversion, and secure delivery through expiring token-based access. Designed for developers, content tools, automation pipelines, and all who need clean audio from video sources β€” fast.


πŸ“š Table of Contents

  1. Features
  2. Installation
  3. Example Usage
  4. API Endpoints
  5. Internals (How It Works)
  6. Tech Stack
  7. Ideal For
  8. Author
  9. Weekly Rewind
  10. License

🌟 Features

  • πŸ”— Accepts any public YouTube URL
  • 🎡 Downloads best audio using yt-dlp
  • ✨ Converts audio to high-quality .mp3 via FFmpeg
  • πŸ” Returns a one-time secure token to download the file
  • ⏱️ Tokens expire automatically (default: 5 mins)
  • 🧹 Expired files are auto-deleted (clean disk usage)
  • πŸš€ Built for fast local or cloud deployment

πŸ“¦ Installation

Requirements & Launch

Required packages are listed in requirements.txt. To install all of them simply run:

pip install -r requirements.txt

Make sure FFmpeg is installed on your system:

# macOS
brew install ffmpeg

# Ubuntu/Debian
sudo apt install ffmpeg

Clone and run the project:

git clone https://github.com/alperensumeroglu/yt-audio-api.git
cd yt-audio-api
python3 main.py

πŸ“— Example Usage

Step 1: Request Token

GET /?url=https://www.youtube.com/watch?v=dQw4w9WgXcQ

Response:

{
  "token": "CGIroH6G-8JDL3DllsUhM6_CfYc"
}

Step 2: Download Audio

GET /download?token=CGIroH6G-8JDL3DllsUhM6_CfYc

Result: yourfile.mp3 will download automatically 🎢


πŸ”„ API Endpoints

Method Route Description
GET / Accepts ?url=<video_url>, returns token
GET /download Accepts ?token=<token>, returns audio file

βš–οΈ Internals (How It Works)

  • Downloads audio using yt-dlp
  • Converts it to .mp3 using FFmpeg (192kbps)
  • Stores audio in /downloads directory
  • Generates expiring token for each file
  • A background daemon removes expired tokens/files

πŸ“Š Tech Stack

  • Python 3.8+
  • Flask 2.x
  • yt-dlp
  • FFmpeg

🀝 Ideal For

  • Developers building podcast/audio tools
  • Automation pipelines for archiving
  • Students & hobbyists learning API development

πŸ‘€ Author

Alperen Sümeroğlu
Computer Engineer β€’ Entrepreneur β€’ Global Explorer 🌍
15+ European countries explored ✈️

β€œLet your code be as clean as the audio you deliver.”


πŸ—“ Weekly Rewind: Tech, AI & Entrepreneurship

πŸš€ What does it take to grow as a Computer Engineering student, build projects, and explore global innovation?

This API is part of a bigger journey I share in Weekly Rewind β€” my real-time documentary podcast series, where I reflect weekly on coding breakthroughs, innovation insights, startup stories, and lessons from around the world.

πŸ’‘ What is Weekly Rewind?

A behind-the-scenes look at real-world experiences, global insights, and hands-on learning. Each episode includes:

  • πŸ”Ή Inside My Coding & Engineering Projects
  • πŸ”Ή Startup Ideas & Entrepreneurial Lessons
  • πŸ”Ή Trends in Tech & AI
  • πŸ”Ή Innovation from 15+ Countries
  • πŸ”Ή Guest Conversations with Builders & Engineers
  • πŸ”Ή Productivity, Learning & Growth Strategies

🌍 Redefining Learning

β€œTrue learning isn’t confined to tutorials β€” it comes from building real projects, exploring the world, and sharing the story.”

🎧 Listen Now:

This is not just a podcast β€” it’s a journey of building, sharing, and scaling real-world impact.


πŸ“† License

MIT License β€” free for personal and commercial use.