A local API that allows you to search and download music from multiple platforms (Deezer, YouTube, SoundCloud, Spotify) for use with DJ software like Mixxx.
DJ API is a local REST API that allows DJs to:
- π Search for tracks across multiple platforms simultaneously
- π₯ Download tracks automatically in MP3 320kbps
- π΅ Retrieve BPM to make mixing easier
- ποΈ Integrate with Mixxx or other DJ software
| Platform | Search | Download | BPM |
|---|---|---|---|
| Deezer | β | β (via YouTube) | β |
| YouTube | β | β | β |
| SoundCloud | β | β | β |
| Spotify | β | β (via YouTube) | β |
βββββββββββββββ βββββββββββββββ βββββββββββββββββββ
β Mixxx ββββββΆβ DJ API ββββββΆβ Deezer/YouTube β
β (or other) βββββββ (localhost) βββββββ SoundCloud/... β
βββββββββββββββ βββββββββββββββ βββββββββββββββββββ
β
βΌ
βββββββββββββββ
β downloads/ β
β (MP3 320k) β
βββββββββββββββ
- Python 3.10 or higher
- FFmpeg (for audio conversion)
git clone https://github.com/your-username/dj-api.git
cd dj-api# Windows
python -m venv venv
venv\Scripts\activate
# Linux/Mac
python -m venv venv
source venv/bin/activatepip install -r requirements.txt# With Chocolatey
choco install ffmpeg
# Or download from https://ffmpeg.org/download.htmlsudo apt update
sudo apt install ffmpegbrew install ffmpegCreate a .env file at the project root:
# SoundCloud (optional)
SOUNDCLOUD_CLIENT_ID=your_soundcloud_client_id
# Spotify (optional - for search and BPM)
SPOTIFY_CLIENT_ID=your_spotify_client_id
SPOTIFY_CLIENT_SECRET=your_spotify_client_secret
# YouTube (optional)
YOUTUBE_API_KEY=your_youtube_api_key
# Configuration
DOWNLOAD_PATH=./downloads
MAX_RESULTS=20π‘ Note: Deezer and YouTube work without an API key for basic search.
python run.pyuvicorn app.main:app --reload --host 0.0.0.0 --port 8000python -m uvicorn app.main:app --reload --port 8000The API will be accessible at: http://localhost:8000
Once the API is running, access the interactive documentation:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
| Method | Route | Description |
|---|---|---|
GET |
/ |
API information |
GET |
/platforms |
List of available platforms |
| Method | Route | Description |
|---|---|---|
GET |
/search?q={query} |
Search across all platforms |
GET |
/search/{platform}?q={query} |
Search on a specific platform |
| Method | Route | Description |
|---|---|---|
GET |
/track/{source}/{track_id} |
Get track information |
| Method | Route | Description |
|---|---|---|
GET |
/download/{source}/{track_id} |
Download a track |
POST |
/download |
Download a track (with JSON body) |
curl "http://localhost:8000/search?q=daft%20punk&limit=5"Response:
{
"query": "daft punk",
"total_results": 10,
"results": [
{
"id": "dz_3135556",
"title": "One More Time",
"artist": "Daft Punk",
"source": "deezer",
"url": "https://www.deezer.com/track/3135556",
"bpm": 122.0,
"duration": 320,
"artwork_url": "https://e-cdns-images.dzcdn.net/images/cover/...",
"genre": null
}
]
}curl "http://localhost:8000/search/deezer?q=daft%20punk&limit=10"curl "http://localhost:8000/search/youtube?q=daft%20punk%20one%20more%20time"curl "http://localhost:8000/search?q=daft%20punk&platforms=deezer,youtube&limit=5"curl "http://localhost:8000/track/deezer/dz_3135556"curl "http://localhost:8000/download/deezer/dz_3135556"Response:
{
"status": "ready",
"filepath": "./downloads/Daft Punk - One More Time.mp3",
"track": {
"id": "dz_3135556",
"title": "One More Time",
"artist": "Daft Punk",
"source": "deezer",
"bpm": 122.0
}
}curl -X POST "http://localhost:8000/download" \
-H "Content-Type: application/json" \
-d '{
"url": "https://www.deezer.com/track/3135556",
"source": "deezer",
"track_id": "dz_3135556"
}'dj-api/
βββ app/
β βββ __init__.py
β βββ main.py # FastAPI entry point
β βββ config.py # Configuration (.env)
β βββ interfaces/
β β βββ __init__.py
β β βββ download_interface.py # Abstract interface
β βββ platforms/
β β βββ __init__.py
β β βββ soundcloud.py # SoundCloud implementation
β β βββ spotify.py # Spotify implementation
β β βββ deezer.py # Deezer implementation
β β βββ youtube.py # YouTube implementation
β βββ services/
β β βββ __init__.py
β β βββ search_service.py # Search service
β β βββ download_service.py # Download service
β βββ models/
β βββ __init__.py
β βββ track.py # Pydantic models
βββ downloads/ # Downloads folder
βββ requirements.txt
βββ run.py # Launch script
βββ .env # Environment variables
βββ README.md
In .env:
DOWNLOAD_PATH=D:/My Music/DJIn .env:
MAX_RESULTS=50- Go to https://developer.spotify.com/dashboard
- Create an application
- Copy the Client ID and Client Secret
- Go to https://developers.soundcloud.com/
- Create an application
- Copy the Client ID
Mixxx is an open source DJ software, which is why it's easy to integrate my API with this software.
- Configure
DOWNLOAD_PATHto your Mixxx folder - In Mixxx, add this folder to your library
- New downloads will appear automatically
See the Mixxx documentation to create controller scripts: https://github.com/mixxxdj/mixxx/wiki/Midi-Scripting
This API is intended for personal use only.
- β Do not use for public broadcasting
- β Do not redistribute downloaded files
- β Use for preparing personal DJ sets
- β Respect copyright laws
# Run from the project root
cd dj-api
python -m uvicorn app.main:app --reloadInstall FFmpeg and add it to your PATH.
# Update yt-dlp
pip install --upgrade yt-dlp- Deezer: BPM is available
- Spotify: Requires API keys
- YouTube/SoundCloud: BPM not available via API
Contributions are welcome!
- Fork the project
- Create a branch (
git checkout -b feature/new-feature) - Commit (
git commit -m 'Add new feature') - Push (
git push origin feature/new-feature) - Open a Pull Request
MIT License - See the LICENSE file for more details.