Spotifm serves the same API over HTTP on port 3333 and HTTPS on port 3443 by
default. The automatically generated certificate is self-signed, so clients
must trust it explicitly or use a certificate supplied with
tls_cert/tls_key.
All browser origins are allowed by default. Set cors_origins in the config
file or pass --cors-origins to restrict them; see
CORS configuration.
Examples marked as live were fetched from https://radio.etalon.cc on May 31, 2026. Values will vary on your own instance.
Most error responses use:
{ "error": "..." }Playlist names accepted by the mutating playlist endpoints must be ASCII alphanumeric.
This is the canonical track shape used for playlist entries and queue entries.
{
"track_id": "1GbtB4zTqAsyfZEsm1RZfx",
"track_name": "Blinding Lights",
"artists": ["The Weeknd"],
"queue_idx": 0,
"artist_ids": ["1XyoAE8jLE1Z1eUzyUsj7C"],
"album_id": "4yP0hdKOZPNshxUOjY0cZj",
"album_name": "After Hours",
"cover_url": "https://i.scdn.co/image/ab67616d0000b2730d...",
"playlist_id": "37i9dQZF1DXcBWIGoYBM5M",
"playlist_name": "Today's Top Hits"
}Notes:
queue_idxisnullfor normal playlist entries and an integer for transient queued items.cover_url,album_id, andalbum_nameare present when Spotify provided them.playlist_idandplaylist_nameare present for tracks resolved from a Spotify playlist.
This is the canonical playback snapshot returned by /np, /play/<category>/<id>, /play/<category>?q=<query>, /skip, /skip/<category>, /queue/<category>/<id>, /queue/<category>?q=<query>, and /next when a next track exists.
Live example from GET /np:
{
"status": "playing",
"track_id": "4c7Fu6BSxiHiYrjoTHlAuY",
"track_name": "Keep The groovin'",
"artists": ["YUZO KOSHIRO"],
"artist_ids": ["6Tvw2YNOLrcxATPGnFVTzz"],
"album_id": "22mDiQ83M2QjLM9KHsHQ9z",
"album_name": "Streets of Rage: Perfect Soundtrack",
"track_duration_ms": 200746,
"position_ms": 79126,
"listeners": 0,
"active_playlist": "streetsofrage",
"cover_url": "https://i.scdn.co/image/ab67616d0000b2737a14c44b2aa2b6f5a85664db"
}Notes:
listenersis the current live stream subscriber count.position_msis a point-in-time snapshot. On mutation endpoints it is commonly0ornull.track_duration_ms,active_playlist, andcover_urlare omitted when unavailable./nextuses the same shape withstatus: "next".
Used by the WebSocket Playlist message.
{
"name": "default",
"tracks": [
{
"track_id": "1GbtB4zTqAsyfZEsm1RZfx",
"track_name": "Blinding Lights",
"artists": ["The Weeknd"],
"queue_idx": null,
"artist_ids": ["1XyoAE8jLE1Z1eUzyUsj7C"],
"album_id": "4yP0hdKOZPNshxUOjY0cZj",
"album_name": "After Hours",
"cover_url": "https://i.scdn.co/image/ab67616d0000b2730d..."
}
]
}Authorization helper served on the API port.
Behavior:
- If Spotifm has not finished OAuth authorization yet, this endpoint responds with an HTTP redirect to the Spotify authorization URL.
- Once startup is complete, this endpoint shows success and automatically opens the configured web player.
Notes:
- The Spotify callback goes to
redirect_urifor playback, orrspotify_redirect_uriwhen optional Web API authorization is enabled. - This is especially useful for headless or Docker deployments where opening a local browser from the CLI is inconvenient.
A successful callback redirects to /oauth/complete, preserving the callback
request's hostname. Hostnames other than 127.0.0.1 use HTTPS on the configured
tls_port (3443 by default); 127.0.0.1 can keep HTTP. The page polls
/oauth/status until startup is ready, follows /oauth if another authorization
is required, then opens the configured player path automatically. Once ready,
the status response is {"status":"authorized","player_url":"/","tls_port":3443}
(with the configured player_endpoint and tls_port). The final player
navigation applies the same HTTPS rule, including when visiting /oauth
after startup is complete.
category is one of track, album, artist, or playlist.
Notes:
limitmust be between1and10, regardless of which provider is used.- Each provider attempt fetches one page. Larger limits return
400. - Unknown categories return
400. - The response is an array whose item shape depends on the category.
X-Spotify-Sourceidentifiesspotify_web_apiorspotify_anonymous.
With rspotify_client_id unset, search uses anonymous web-player search
directly and metadata uses the playback session. When Web API access is enabled,
search automatically falls back to anonymous web-player search after Web API
rate limits, authorization failures, temporary network/server failures, or an
incompatible response. Subsequent catalogue requests use the backup during the
Web API's Retry-After interval plus one second, or for 60 seconds after other
qualifying failures. The next request after that interval tries the Web API
again. Metadata needed to play or queue results can use the existing playback
session. See fallback details.
Spotify failures include source: "spotify" for the Web API or
source: "spotify_anonymous" for the backup, so clients can distinguish upstream
failures from Spotifm API-key failures. If anonymous search is also rate limited,
the response includes 429, Retry-After, and retry_after_seconds when
Spotify supplies a wait interval. For example:
{
"error": "Spotify anonymous search returned 429 Too Many Requests",
"source": "spotify_anonymous",
"retry_after_seconds": 18
}Catalogue requests try the backup immediately after a qualifying failure.
Rate limits do not trigger token refresh or repeated anonymous requests.
Unavailable popularity and preview URLs are represented as null in anonymous
results. The JSON array and category-specific item shapes are unchanged.
Each outgoing Web API GET logs request_number (the count since this client
was created), local_gets_30s (GETs started during the preceding 30 seconds,
including this request), and the configured client ID. Search type and limit
are logged; query text and tokens are excluded. These counters measure this
Spotifm process's GETs, which helps investigate traffic before the first 429.
The web player shows the wait interval, suppresses duplicate pending searches, and ignores responses from searches that have been replaced by a newer query. The wait message does not prevent a subsequent manual search. Using the bundled ncspot app ID also means using that application's quota.
Live example from GET /search/track/2?q=daft%20punk:
[
{
"track_id": "0DiWol3AO6WpXZgp0goxAV",
"uri": "spotify:track:0DiWol3AO6WpXZgp0goxAV",
"track_name": "One More Time",
"duration_ms": 320357,
"explicit": false,
"popularity": 84,
"artists": ["Daft Punk"],
"artist_ids": ["4tZwfgrHOc3mvqYlEYSvVi"],
"album_id": "2noRn2Aes5aoNVsU6iWThc",
"album_name": "Discovery",
"album_artists": ["Daft Punk"],
"cover_url": "https://i.scdn.co/image/ab67616d0000b2731e81bff9807a9e629fce5ade",
"preview_url": null
},
{
"track_id": "09TlxralXOGX35LUutvw7I",
"uri": "spotify:track:09TlxralXOGX35LUutvw7I",
"track_name": "End of Line",
"duration_ms": 156486,
"explicit": false,
"popularity": 70,
"artists": ["Daft Punk"],
"artist_ids": ["4tZwfgrHOc3mvqYlEYSvVi"],
"album_id": "3AMXFnwHWXCvNr5NCCpLZI",
"album_name": "TRON: Legacy - The Complete Edition (Original Motion Picture Soundtrack)",
"album_artists": ["Daft Punk"],
"cover_url": "https://i.scdn.co/image/ab67616d0000b2738323143296ff7b2801e32789",
"preview_url": null
}
]Category-specific item shapes:
track:ExtendedTrack[]album: objects withalbum_id,uri,album_name,artists,artist_ids,cover_urlartist: objects withartist_id,uri,artist_name,genres,popularity,cover_urlplaylist: objects withplaylist_id,uri,playlist_name,owner,total_tracks,cover_url
For playlist search results, total_tracks is null when the provider does not
supply a count. The player omits unknown counts; a confirmed empty playlist has
total_tracks: 0 and displays 0 tracks.
Searches only the official Spotify Web API and returns its native JSON object,
including the category's paging object (tracks, albums, artists, or
playlists). Provider fields are preserved; Spotifm does not convert them to
the common item shapes above. X-Spotify-Source is spotify_web_api.
category accepts the same four categories as the common endpoint. limit
must be 1–10, and the optional offset must be 0–1000. This performs
one provider request, with the usual token refresh if needed. It requires
rspotify_client_id; otherwise it returns 503. A provider failure is
returned to the caller, including Retry-After when supplied. This endpoint
does not fall back, even during the common endpoint's fallback interval.
Searches only Spotify's internal web-player API and returns the complete native
GraphQL JSON response, including data, any errors, and additional provider
fields. The internal search operation returns several categories together,
so this endpoint has no category parameter. limit must be 1–50 per
category; the optional offset is a nonnegative integer. X-Spotify-Source
is spotify_anonymous.
This endpoint works without rspotify_client_id, shares the anonymous visitor
session and successful-response cache with the common endpoint, and does not
try the official API. GraphQL errors delivered with HTTP 200 retain that
status and body; the common endpoint instead rejects a response without usable
search data. HTTP failures use Spotifm's usual provider error format.
All three search endpoints use the search permission. The bundled player
uses the common endpoint with a limit of ten and its normalized JSON array.
Returns the current NowPlaying snapshot.
category is one of track, album, artist, or playlist.
Behavior:
- If
playlistis omitted, the resolved tracks are inserted into the default playlist immediately after the current track and playback jumps to the first resolved track. - If
playlistis provided, the named playlist is loaded or created on disk, the resolved tracks are appended, the active playlist switches to it, and playback starts there.
Response: NowPlaying
Errors:
400for an invalid category or invalid playlist name400if no tracks could be resolved- the corresponding Spotify status, or
502for other Spotify/API failures
Searches Spotify in the given category, uses the first result, and then behaves like GET /play/<category>/<id>.
Response: NowPlaying
Skips to the next available track with a single playback load.
Response: NowPlaying
Skips by n tracks by advancing the in-memory queue/playlist cursor to the final target and loading that track once.
Notes:
- positive
nskips forward and consumes transient queued tracks first - negative
nskips backward through the normal playlist/library order and leaves transient queued tracks intact nmust not be0- if the playlist runs out during the skip sequence, the final response is the normal idle
NowPlayingpayload
Response: NowPlaying
category is album or artist.
Skips forward in memory until the next track that does not share the current album or artist grouping, then loads only that final track.
Response: NowPlaying
Returns the upcoming track using the same shape as NowPlaying, with status: "next".
Example:
{
"status": "next",
"track_id": "3Mv6pY1vvRbVBjuccDjin1",
"track_name": "Beatnik On The Ship",
"artists": ["YUZO KOSHIRO"],
"artist_ids": ["6Tvw2YNOLrcxATPGnFVTzz"],
"album_id": "22mDiQ83M2QjLM9KHsHQ9z",
"album_name": "Streets of Rage: Perfect Soundtrack",
"position_ms": null,
"listeners": 0,
"active_playlist": "streetsofrage",
"cover_url": "https://i.scdn.co/image/ab67616d0000b2737a14c44b2aa2b6f5a85664db"
}If there is no next track, the REST endpoint returns:
{ "error": "No next track" }with HTTP 404.
Returns the transient queue only, sorted by queue_idx.
Example:
[
{
"track_id": "1GbtB4zTqAsyfZEsm1RZfx",
"track_name": "Blinding Lights",
"artists": ["The Weeknd"],
"queue_idx": 0,
"artist_ids": ["1XyoAE8jLE1Z1eUzyUsj7C"],
"album_id": "4yP0hdKOZPNshxUOjY0cZj",
"album_name": "After Hours",
"cover_url": "https://i.scdn.co/image/ab67616d0000b2730d..."
}
]Queues tracks resolved from a track, album, artist, or playlist ID without interrupting the current track.
Response: NowPlaying with status: "queued"
Searches Spotify in the given category, uses the first result, and then behaves like GET /queue/<category>/<id>.
Response: NowPlaying with status: "queued"
Removes a track from the transient queue and returns the updated queue as TrackItem[].
If the track is not present in the queue, returns 404 with:
{ "error": "Track is not in the active transient queue" }Returns the current active playlist's tracks as TrackItem[].
Returns detailed information about all saved playlists on disk.
Example:
[
{
"name": "default",
"num_tracks": 42,
"cover_urls": ["https://i.scdn.co/..."],
"artists": ["Daft Punk", "Kraftwerk"],
"last_modified": 1672531199
}
]Returns the named playlist's tracks as TrackItem[].
Switches the active playlist and returns its full track list as TrackItem[].
If the named playlist does not exist yet, it is created implicitly as an empty playlist and then activated.
Shuffles either:
- the current active playlist with
GET /playlist/shuffle - the named playlist with
GET /playlist/shuffle/<name>
Response: the shuffled playlist as TrackItem[]
If a named playlist does not exist yet, it is created implicitly and the endpoint returns an empty list.
Sorts either:
- the current active playlist with
GET /playlist/sort?by=... - the named playlist with
GET /playlist/<name>/sort?by=...
Response: the sorted playlist as TrackItem[]
by=playlist sorts by source Spotify playlist metadata when present. Tracks without source playlist metadata sort after tracks that have it.
If a named playlist does not exist yet, it is created implicitly and the endpoint returns an empty list.
Removes a track from the current active playlist and returns the updated TrackItem[].
Immediately starts the selected track from the current active playlist without changing playlists or reordering its tracks.
Response: NowPlaying with status: "playing".
Returns 404 when the track is not part of the active playlist.
Resolves Spotify objects into tracks and appends them to the named playlist.
For POST, you can pass a JSON body with the equivalent structure instead of query params.
POST JSON Body:
{
"tracks": ["3n3Ppam7vgaVa1iaRUc9Lp"],
"albums": ["2noRn2Aes5aoNVsU6iWThc"],
"artists": [],
"playlists": []
}Accepted query params (for GET):
tracks[]albums[]artists[]playlists[]
Example (for GET):
GET /playlist/mix/add?tracks[]=3n3Ppam7vgaVa1iaRUc9Lp&albums[]=2noRn2Aes5aoNVsU6iWThc
Success response:
{
"status": "success",
"added_tracks": 14,
"total_tracks": 52
}Batch-removes tracks from the named playlist.
For POST, you can pass a JSON body with the equivalent structure instead of query params.
POST JSON Body:
{
"tracks": ["..."],
"albums": ["..."],
"artists": [],
"playlists": []
}Accepted query params (for DELETE):
tracks[]albums[]artists[]playlists[]
Success response:
{ "status": "success" }Deletes the named playlist file from disk.
If the deleted playlist was active, the server falls back to the default playlist in memory.
Success response:
{ "status": "success" }Saved playlists are always stored under $XDG_DATA_HOME/spotifm/playlists
(normally ~/.local/share/spotifm/playlists). If default.json exists there,
it is loaded on startup.
This is the REST lyrics-state endpoint. It is not the WebSocket endpoint.
Spotify supplies synced lyrics first. When they are missing, unsynced, empty,
or unavailable, spotifm looks up timestamped lyrics on LRCLIB using the track's
title, artist, album, and duration. This fallback needs no API key. Both sources
use the same Lyrics payload and millisecond timestamps on REST and WebSocket
endpoints. If neither source has usable timed lyrics, the state is NoLyrics.
Each Lyrics payload includes source, either "spotify" or "lrclib".
This field is the same on REST and WebSocket messages, including lyrics read
from the LRCLIB cache. NoLyrics and Idle have no source field.
Successful timed LRCLIB results are saved in
$XDG_CACHE_HOME/spotifm/lyrics/lrclib (normally
~/.cache/spotifm/lyrics/lrclib). They survive restarts and are reused when the
track's metadata still matches. Spotify is checked first on every lookup.
Missing, unsynced, or failed LRCLIB responses are not cached. Remove a track's
<Spotify track ID>.json file to fetch its LRCLIB lyrics again.
It returns the cached lyrics state for the current track, which is one of:
LyricsNoLyricsIdle
Live example:
{ "type": "NoLyrics" }Example Lyrics payload:
{
"type": "Lyrics",
"track_id": "3n3Ppam7vgaVa1iaRUc9Lp",
"source": "spotify",
"background": 123456,
"text_color": 16777215,
"highlight_color": 65280,
"lines": [
{ "time_ms": 0, "text": "..." },
{ "time_ms": 15420, "text": "..." }
]
}This is the current WebSocket endpoint. /lyrics is no longer the socket endpoint.
Optional query parameters:
sid: per-player stream session identifier. When it matches thesidused on the audio stream URL,Positionmessages are adjusted to the latest Ogg granule observed for that listener's audio stream.
On connect, the server sends:
- the current cached lyrics state, or
{"type":"Idle"} - the current
Positionmessage if a track is already playing - the current
NowPlayingsnapshot
Client requests are JSON messages with an action field:
{ "action": "get_now_playing" }Supported actions:
get_now_playingget_nextget_playlist
Outgoing messages are internally tagged with a top-level "type" field.
Live initial messages from /ws:
{ "type": "NoLyrics" }{ "type": "Position", "position_ms": 47066771 }{
"type": "NowPlaying",
"status": "playing",
"track_id": "3Mv6pY1vvRbVBjuccDjin1",
"track_name": "Beatnik On The Ship",
"artists": ["YUZO KOSHIRO"],
"artist_ids": ["6Tvw2YNOLrcxATPGnFVTzz"],
"album_id": "22mDiQ83M2QjLM9KHsHQ9z",
"album_name": "Streets of Rage: Perfect Soundtrack",
"track_duration_ms": 270093,
"position_ms": null,
"listeners": 0,
"active_playlist": "streetsofrage",
"cover_url": "https://i.scdn.co/image/ab67616d0000b2737a14c44b2aa2b6f5a85664db"
}get_next returns the same flattened playback shape as NowPlaying, but tagged as Next:
{
"type": "Next",
"status": "next",
"track_id": "3Mv6pY1vvRbVBjuccDjin1",
"track_name": "Beatnik On The Ship",
"artists": ["YUZO KOSHIRO"],
"artist_ids": ["6Tvw2YNOLrcxATPGnFVTzz"],
"album_id": "22mDiQ83M2QjLM9KHsHQ9z",
"album_name": "Streets of Rage: Perfect Soundtrack",
"position_ms": null,
"listeners": 0,
"active_playlist": "streetsofrage",
"cover_url": "https://i.scdn.co/image/ab67616d0000b2737a14c44b2aa2b6f5a85664db"
}If there is no next track, the socket sends:
{ "type": "Next" }get_playlist returns the ActivePlaylistResponse shape:
{
"type": "Playlist",
"name": "default",
"tracks": [
{
"track_id": "1GbtB4zTqAsyfZEsm1RZfx",
"track_name": "Blinding Lights",
"artists": ["The Weeknd"],
"queue_idx": null,
"artist_ids": ["1XyoAE8jLE1Z1eUzyUsj7C"],
"album_id": "4yP0hdKOZPNshxUOjY0cZj",
"album_name": "After Hours",
"cover_url": "https://i.scdn.co/image/ab67616d0000b2730d..."
}
]
}Default: GET /
Serves the web player HTML. The configured player setting and --player flag
accept a local directory or a direct path to index.html.
Default: GET /minimal
Serves a minimal reference player from minimal.html next to the configured
player path. It includes basic playback, now-playing metadata, progress, album
art, and synced lyrics without the visualizer or settings UI.
Serves additional files from the configured player path. For directory paths,
<path> is resolved under that directory; for a direct index.html path, it is
resolved next to that file.
Default: GET /spotifm-player-sw.js
Serves the web player's Service Worker. The player uses it to tee the live audio response in the browser and parse Ogg granules from the same stream that feeds the <audio> element.
Default: GET /spotifm-audio-worklet.js
Serves the web player's audio worklet script from the configured player path.
Default: GET /player-assets/<path>
Serves additional files from the configured player path. This is equivalent to
GET <player_endpoint>/<path> and is kept for player assets that use the
existing player-assets/... URL layout.
Default: GET /listen
Serves the live audio stream.
Ogg responses include X-Spotifm-Ogg-Granule-Rate. Consumers that inspect
Ogg granule positions must divide by this value; for example, Opus uses 48000
while the native Vorbis stream normally uses 44100.
The response content type is derived from native passthrough or the selected GStreamer pipeline:
- MP3 pipelines:
audio/mpeg - Ogg pipelines:
audio/ogg - WebM pipelines:
audio/webm - WAV pipelines:
audio/wav - AAC/MP4 pipelines:
audio/aac
When API keys are configured in config.toml, access to restricted endpoints requires supplying a valid API key.
An API key can be supplied using one of the following:
X-Api-KeyHTTP Header.X-Api-Key: some_keyAuthorization: Bearer <key>HTTP Header.Authorization: Bearer some_keyapi_key=<key>query parameter.GET /api/privs?api_key=some_key
Returns the active authentication status and the list of permitted privilege scopes for the provided key.
{
"auth_enabled": true,
"authenticated": true,
"permissions": ["play", "queue", "search"]
}Notes:
- If API authentication is disabled (i.e., no API keys are specified in
config.toml), the response will be:{ "auth_enabled": false, "authenticated": true, "permissions": ["*"] } - If an invalid key is provided or the key is missing when authentication is enabled, the response will be:
{ "auth_enabled": true, "authenticated": false, "permissions": [] }