This project provides an integrated FastAPI backend and Typer CLI tool to download songs from Spotify links (track, album, or playlist) by searching for the corresponding YouTube audio and saving it locally as .mp3.
Apart from the above methods the whole application can be run as a scalable backend using Worker Queue (in our case RabbitMQ) . NodeJS server produces messages which is consumed by our python worker to download songs .
A deployed instance should be available on https://song-snatch.vercel.app/ , The frontend is deployed on vercel and backend is deployed locally on my laptop exposed with tunneling to a static domain .
/v1/spotify/findβ Accepts Spotify URL, fetches metadata, downloads from YouTube./v1/song/listβ Lists downloaded songs./v1/song/download/{song_name}β Serves MP3 file for download or playback.
spotify-find <url>β Downloads from Spotify track/album/playlist link.list-songsβ Lists locally saved MP3s.download-song <name>β Prints absolute path to downloaded MP3.install-completionβ Enables shell autocomplete for CLI.
- Python 3.9+
ffmpeginstalled and in PATH- YouTube-dl / yt-dlp compatible backend for downloading
- Optional:
.envfile for environment variables like port
pip install -r requirements.txtpython main.pyDefault: http://localhost:8000
| Method | Endpoint | Description |
|---|---|---|
| POST | /v1/spotify/find?url=... |
Download audio from Spotify URL |
| GET | /v1/song/list |
List all downloaded songs |
| GET | /v1/song/download/{song_name} |
Stream or download specific MP3 |
| GET | / |
Root health check |
pip install typer[all]python cli.py spotify-find "<spotify-url>"
python cli.py list-songs
python cli.py download-song "song1.mp3"Set the port in .env:
Enter the spotify dev account credentials
WORKER_PORT=8000
SPOTIFY_CLIENT_ID=clientid_here
SPOTIFY_CLIENT_SECRET=secret_here
python cli.py spotify-find "https://open.spotify.com/track/xyz"Or via API:
curl -X POST "http://localhost:8000/v1/spotify/find?url=https://open.spotify.com/track/xyz"This project allows users to download songs from Spotify (track, album, or playlist) using a background worker architecture with:
- β Node.js (API producer)
- β Python (worker/consumer)
- β Redis (job tracking)
- β RabbitMQ (task queue)
Ensure the following are installed:
- Node.js
- Python 3.8+
- Docker
pip3(Python package installer)
docker run -it --rm -d \
--name rabbitmq \
-p 5672:5672 \
-p 15672:15672 \
rabbitmq:3-management- UI: http://localhost:15672
- Username:
guest| Password:guest
docker run -d \
--name redis \
-p 6379:6379 \
redis:latestcd producer
npm install
npm startcd worker
pip3 install -r requirements.txt
python3 consumer.py| Method | Route | Description |
|---|---|---|
GET |
/v1/find?url=<spotify_url> |
Queue a Spotify download job |
GET |
/v1/status?jobId=<job_id> |
Check job status in Redis |
GET |
/v1/download/:song_name |
Download a completed MP3 file |
GET http://localhost:8000/v1/find?url=https://open.spotify.com/album/6AyUVv7MnxxTuijp4WmrhOGET http://localhost:8000/v1/status?jobId=0197fe57-6334-767e-aae2-0dd415799d46Response from Redis (example):
{
"jobId": "0197fe57-6334-767e-aae2-0dd415799d46",
"status": "completed",
"songs": ["Muse - Unintended.mp3"]
}GET http://localhost:8000/v1/download/Muse%20-%20Unintended.mp3