A lightweight, feature-rich JavaScript extension for Spicetify that acts as a real-time bi-directional bridge between the Spotify Desktop Client and a WebSocket server (e.g., Python).
- Native Settings UI: Access configuration settings directly inside Spotify by clicking your Profile Picture.
- API Key Authentication: Optional security token support to protect incoming commands and authenticate outgoing push events.
- WSS / Secure Connections: Full support for encrypted
wss://connections for remote setups or local SSL environments. - Automatic Reconnection: Safely attempts auto-reconnecting if the server drops or restarts.
- Real-Time Push Events: Emits instant WebSocket events on player state changes:
InitialState: Dispatched immediately upon WebSocket connection (includes live-patched progress timestamp).SongChanged: Triggered on track changes.PlayPauseChanged: Triggered when playback is paused or resumed.VolumeChanged: Triggered on volume adjustments (uses trailing debounce to avoid network spam).RepeatChanged: Triggered when repeat mode is changed.ShuffleChanged: Triggered when shuffle mode is toggled.SeekChanged: Triggered only when manually seeking or scrubbing through a track.Ping: Triggered periodically every 30 seconds as a heartbeat.
- Full Control Commands: Supports incoming JSON requests to control playback, volume, shuffle, repeat, seeking, and status queries.
You can configure the extension directly within Spotify:
- Click on your Profile Picture in the top-right corner of Spotify.
- Click Connect API Settings.
- Adjust your settings in the popup modal:
- WebSocket Server URL: Default is
ws://127.0.0.1:9090. Usewss://IP:PORT:9090for encrypted connections orwss://DOMAIN:PORTfor remote connections. - API Key / Secret Token (Optional): Set a custom secret token matching your server configuration for authenticated setups.
- Reconnect Interval (ms): Set how fast the extension attempts to reconnect on disconnect (Minimum
1000ms).
- WebSocket Server URL: Default is
-
Download spicetify-connect-api.js.
-
Place the file in the appropriate path for your operating system:
- Windows:
C:\Users\%username%\AppData\Roaming\spicetify\Extensions\(Paste inWin + R) - Linux / macOS:
~/.config/spicetify/Extensions/
- Windows:
-
Enable the extension in your terminal:
spicetify config extensions spicetify-connect-api.js- Apply the changes:
spicetify applyIf you are building a Python application to interact with this extension, use the companion Python package:
It handles the WebSocket server setup, SSL/WSS contexts, API Key verification, event listeners, response matching, and typed command execution out of the box!
By default, the extension connects to ws://127.0.0.1:9090.
Send JSON messages in the following structure (include "token" if API Key is set in settings):
{
"requestName": "SetVolume",
"requestId": "unique-id-123",
"token": "your-optional-api-key",
"payload": {
"level": 0.8
}
}| Request Name | Payload Parameters | Description |
|---|---|---|
Ping |
None | Responds with { "message": "Pong", "timestamp": ... }. |
Play |
None | Resumes playback. |
Pause |
None | Pauses playback. |
TogglePlay |
None | Toggles play/pause state. |
NextSong |
None | Skips to the next track. |
PreviousSong / Back |
None | Standard Spotify back action (resets to 00:00 if playing > 2s). |
ForcePreviousSong / ForceBack |
None | Forces skip to the actual previous track regardless of elapsed time. |
SetVolume |
level (float 0.0 - 1.0) |
Sets the volume level. |
SetRepeat |
mode (0: Off, 1: All, 2: One) |
Sets repeat mode. |
SetShuffle |
state (boolean) |
Enables/disables shuffle. |
SetMute |
state (boolean) |
Mutes/unmutes audio. |
PlayUri |
uri or url (string) |
Plays an item via URI (spotify:track:...) or URL (https://open.spotify.com/...). |
Seek |
position (number in ms) |
Seeks to a specific track position in milliseconds. |
GetPlayerState |
None | Returns full player state snapshot (with patched live position_as_of_timestamp). |
GetCurrentTrack |
None | Returns active track object. |
GetVolume |
None | Returns current volume level. |
GetPlayPause |
None | Returns current play/pause status. |
Emitted event types include: InitialState, SongChanged, PlayPauseChanged, VolumeChanged, RepeatChanged, ShuffleChanged, SeekChanged, Ping.
{
"eventName": "SongChanged",
"token": "your-optional-api-key",
"payload": { ... }
}{
"eventName": "Response",
"requestId": "unique-id-123",
"token": "your-optional-api-key",
"success": true,
"payload": { ... }
}