API Reference¶
Downtify exposes a JSON REST API used by the web UI. All endpoints are served on the same port as the web UI (default: 8000).
General¶
GET /api/version¶
Returns the current Downtify version as a plain string.
Response: "2.6.0"
Search & resolve¶
GET /api/songs/search¶
Search YouTube Music by free text.
| Parameter | Type | Required | Description |
|---|---|---|---|
query |
string | yes | Search query |
Response: Array of song objects (up to 20 results).
GET /api/song/url¶
Resolve a Spotify URL to metadata.
| Parameter | Type | Required | Description |
|---|---|---|---|
url |
string | yes | Spotify track, album or playlist URL |
Response:
- Track URL → single song object
- Album URL → array of song objects
- Playlist URL → array of song objects
GET /api/url is an alias for this endpoint.
Downloads¶
POST /api/download/url¶
Download a single track. Blocks until complete.
| Parameter | Type | Required | Description |
|---|---|---|---|
url |
string | yes | Spotify track URL or YouTube URL |
client_id |
string | no | WebSocket client ID for progress events |
Response: Filename string of the downloaded file.
POST /api/download/batch¶
Download multiple tracks concurrently (up to 4 at a time). Returns immediately; progress is broadcast over WebSocket.
Request body:
{
"songs": [ /* array of song objects */ ],
"playlist_url": "https://open.spotify.com/playlist/…",
"generate_m3u": true
}
| Field | Type | Description |
|---|---|---|
songs |
array | Song objects to download |
playlist_url |
string | Optional. Used to determine the playlist subfolder and M3U name. |
generate_m3u |
boolean | Whether to write an M3U after the batch finishes. Default: true. |
Response:
Queue¶
GET /api/queue¶
List all download jobs (queued, in progress, done, error).
Response: Array of job objects.
DELETE /api/queue¶
Clear the entire download queue/history.
Response: { "cleared": true }
DELETE /api/queue/item¶
Remove a single job from the queue.
| Parameter | Type | Required | Description |
|---|---|---|---|
song_id |
string | yes | Job ID |
Response: { "removed": true } or { "removed": false }
Settings¶
GET /api/settings¶
Return the current settings.
Response:
{
"audio_providers": ["youtube-music"],
"lyrics_providers": ["lrclib"],
"download_lyrics": true,
"format": "mp3",
"bitrate": "320",
"output": "{artists} - {title}.{output-ext}",
"generate_m3u": true,
"organize_by_artist": false
}
POST /api/settings/update¶
Update one or more settings. Takes effect immediately and is persisted to disk.
Request body: Partial settings object with any subset of the fields above.
Response: Full settings object after the update.
File management¶
GET /list¶
List all audio files in the downloads directory (recursive).
Response: Sorted array of relative paths (e.g. ["My Playlist/Song.mp3", "Artist - Track.mp3"]).
DELETE /delete¶
Delete a downloaded file.
| Parameter | Type | Required | Description |
|---|---|---|---|
file |
string | yes | Relative path to the file (as returned by /list) |
Response: { "deleted": true } or { "deleted": false, "error": "…" }
GET /cover¶
Return the embedded cover art for a file.
| Parameter | Type | Required | Description |
|---|---|---|---|
file |
string | yes | Relative path to the file |
Response: Image bytes (image/jpeg or image/png). Returns 404 if no embedded cover is found.
Playlist M3U¶
POST /api/playlist/m3u¶
Write an M3U file for a playlist after per-track downloads are complete.
Request body:
{
"playlist_url": "https://open.spotify.com/playlist/…",
"tracks": [
{
"filename": "My Playlist/Artist - Title.mp3",
"title": "Title",
"artist": "Artist",
"duration": 210
}
]
}
Response: { "path": "/downloads/…/playlist.m3u", "count": 12 }
Playlist Monitor¶
GET /api/monitor/playlists¶
List all monitored playlists.
Response: Array of playlist monitor objects.
POST /api/monitor/playlists¶
Add a playlist to the monitor. Triggers an immediate initial download.
Request body:
Response: Playlist monitor object.
PATCH /api/monitor/playlists/{playlist_id}¶
Update a monitored playlist (interval, enabled state).
Request body: Partial object with interval_minutes and/or enabled.
Response: Updated playlist monitor object.
DELETE /api/monitor/playlists/{playlist_id}¶
Stop monitoring a playlist.
Response: { "deleted": true } or { "deleted": false }
POST /api/monitor/playlists/{playlist_id}/check¶
Trigger an immediate check for a specific playlist outside the normal schedule.
Response: { "downloaded": 3 }
WebSocket¶
WS /api/ws¶
Real-time download progress events.
| Query parameter | Required | Description |
|---|---|---|
client_id |
yes | Unique client identifier (UUID recommended) |
Events received from the server:
{
"song": { /* song metadata object */ },
"progress": 42.5,
"message": "Downloading…",
"status": "downloading",
"filename": null
}
status is one of: queued · downloading · done · error.
filename is set (non-null) on the final done event.