This module depends on librespot-player and, in addition, provides an API to interact with the Spotify client.
All the endpoints will respond with 200 if successful or:
204If there isn't any active session (Zeroconf only)500If the session is invalid503If the session is reconnecting (Retry-Afteris always 10 seconds)
POST /player/loadLoad a track from a given URIuri, can specify to start playing withplayand to shuffle withshuffle.POST /player/play-pauseToggle play/pause status. Useful when using a remote.POST /player/pausePause playback.POST /player/resumeResume playback.POST /player/nextSkip to next track.POST /player/prevSkip to previous track.POST /player/seekSeek to a given position in ms specified bypos.POST /player/shuffleSet shuffle enabled or disabled accordingly toval.POST /player/repeatSet repeating mode as specified byval(modes arenone,track,context).POST /player/set-volumeEither set volume to a givenvolumevalue (from 0 to 65536), or change it by astepcount (positive or negative).POST /player/volume-upUp the volume a little bit.POST /player/volume-downLower the volume a little bit.POST /player/currentRetrieve information about the current track (metadata and time).POST /player/tracksRetrieve all the tracks in the player state with metadata, you can specifywithQueue.POST /player/addToQueueAdd a track to the queue, specified byuri.POST /player/removeFromQueueRemove a track from the queue, specified byuri.
POST /metadata/{type}/{uri}Retrieve metadata.typecan be one ofepisode,track,album,show,artistorplaylist,uriis the standard Spotify uri.POST /metadata/{uri}Retrieve metadata.uriis the standard Spotify uri, the type will be guessed based on the provided uri.
POST /search/{query}Make a search.
POST /token/{scope}Request an access token for a specific scope (or a comma separated list of scopes).
GET /profile/{user_id}/followersRetrieve a list of profiles that are followers of the specified userGET /profile/{user_id}/followingRetrieve a list of profiles that the specified user is following
GET /instanceReturns a json model that contains basic information about the current session;device_id,device_name,device_type,country_code, andpreferred_localePOST /instance/terminateTerminates the API server.POST /instance/closeCloses the current session (and player).
POST /discovery/listList all Spotify Connect devices on the network.
You can subscribe for players events by creating a WebSocket connection to /events.
The currently available events are:
contextChangedThe Spotify context URI changedtrackChangedThe Spotify track URI changedplaybackEndedPlayback has endedplaybackPausedPlayback has been pausedplaybackResumedPlayback has been resumedvolumeChangedPlayback volume changedtrackSeekedTrack has been seekedmetadataAvailableMetadata for the current track is availableplaybackHaltStateChangedPlayback halted or resumed from haltsessionClearedCurrent session went away (Zeroconf only)sessionChangedCurrent session changed (Zeroconf only)inactiveSessionCurrent session is now inactive (no audio)connectionDroppedA network error occurred and we're trying to reconnectconnectionEstablishedSuccessfully reconnectedpanicEntered the panic state, playback is stopped. This is usually recoverable.
Use any endpoint from the public Web API by appending it to /web-api/, the request will be made to the API with the correct Authorization header and the result will be returned.
The method, body, and content type headers will pass through. Additionally, you can specify an X-Spotify-Scope header to override the requested scope, by default all will be requested.
curl -X POST -d "uri=spotify:track:xxxxxxxxxxxxxxxxxxxxxx&play=true&shuffle=true" http://localhost:24879/player/load
curl -X POST http://localhost:24879/metadata/track/spotify:track:xxxxxxxxxxxxxxxxxxxxxx
curl -X POST http://localhost:24879/metadata/spotify:track:xxxxxxxxxxxxxxxxxxxxxx
curl -X GET http://localhost:24879/web-api/v1/me/top/artists