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:
204
If there isn't any active session (Zeroconf only)500
If the session is invalid503
If the session is reconnecting (Retry-After
is always 10 seconds)
POST /player/load
Load a track from a given URIuri
, can specify to start playing withplay
and to shuffle withshuffle
.POST /player/play-pause
Toggle play/pause status. Useful when using a remote.POST /player/pause
Pause playback.POST /player/resume
Resume playback.POST /player/next
Skip to next track.POST /player/prev
Skip to previous track.POST /player/seek
Seek to a given position in ms specified bypos
.POST /player/shuffle
Set shuffle enabled or disabled accordingly toval
.POST /player/repeat
Set repeating mode as specified byval
(modes arenone
,track
,context
).POST /player/set-volume
Either set volume to a givenvolume
value (from 0 to 65536), or change it by astep
count (positive or negative).POST /player/volume-up
Up the volume a little bit.POST /player/volume-down
Lower the volume a little bit.POST /player/current
Retrieve information about the current track (metadata and time).POST /player/tracks
Retrieve all the tracks in the player state with metadata, you can specifywithQueue
.POST /player/addToQueue
Add a track to the queue, specified byuri
.POST /player/removeFromQueue
Remove a track from the queue, specified byuri
.
POST /metadata/{type}/{uri}
Retrieve metadata.type
can be one ofepisode
,track
,album
,show
,artist
orplaylist
,uri
is the standard Spotify uri.POST /metadata/{uri}
Retrieve metadata.uri
is 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}/followers
Retrieve a list of profiles that are followers of the specified userGET /profile/{user_id}/following
Retrieve a list of profiles that the specified user is following
GET /instance
Returns a json model that contains basic information about the current session;device_id
,device_name
,device_type
,country_code
, andpreferred_locale
POST /instance/terminate
Terminates the API server.POST /instance/close
Closes the current session (and player).
POST /discovery/list
List 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:
contextChanged
The Spotify context URI changedtrackChanged
The Spotify track URI changedplaybackEnded
Playback has endedplaybackPaused
Playback has been pausedplaybackResumed
Playback has been resumedvolumeChanged
Playback volume changedtrackSeeked
Track has been seekedmetadataAvailable
Metadata for the current track is availableplaybackHaltStateChanged
Playback halted or resumed from haltsessionCleared
Current session went away (Zeroconf only)sessionChanged
Current session changed (Zeroconf only)inactiveSession
Current session is now inactive (no audio)connectionDropped
A network error occurred and we're trying to reconnectconnectionEstablished
Successfully reconnectedpanic
Entered 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