An asynchronous Python wrapper and WebSocket server for controlling the Spotify desktop client via Spicetify and the spicetify-connect-api extension.
✨ Features
- ⚡ Real-time Push Events: Instant updates for song changes, volume, seeking, and playback state.
- 🎮 Full Playback Control: Play, pause, skip, seek, volume, repeat, and shuffle.
- 🛠️ Convenience Decorators: Easy event listening with syntax like
@server.on_song_changed. - 🏷️ Fully Typed: Pydantic V2 models (
TrackInfo,PlayerState,RepeatMode). - 🔄 Async & Non-blocking: Built on
asyncioandwebsocketsfor maximum performance.
⚙️ Installation
Python 3.10 or higher is required.
pip install spicetify-websocket
📋 Prerequisites
To use this library, ensure you have:
- Spotify Desktop Client installed.
- Spicetify CLI installed and configured.
- The spicetify-connect-api extension enabled in Spicetify.
🚀 Example Usage
import asyncio
from spicetify import RepeatMode, SpotifyServer, TrackInfo
async def main():
async with SpotifyServer() as server:
# Events
@server.on_song_changed
def callback(track: TrackInfo):
print("New song is playing:", track.title)
print("Artist/s:", ", ".join(artist.name for artist in track.artists))
# Wait until Spicetify client connects
await server.wait_for_connection()
# Playback State
is_playing: bool = await server.get_is_playing()
print("Is Spotify playing:", is_playing)
# Playback Controls
await server.play_url(url="https://open.spotify.com/intl-de/track/55pBIZO1cqoldeqpp5WR7H?si=57cde33a1bd34ac9")
await server.set_volume(percent=75)
await server.set_repeat(mode=RepeatMode.TRACK)
# Keep the server running to receive events
await asyncio.Event().wait()
if __name__ == "__main__":
asyncio.run(main())
📻 Events Reference
| Event Name | Convenience Decorator | Callback Payload Type | Description |
|---|---|---|---|
InitialState |
@server.on_initial_state |
PlayerState |
Fired immediately when Spicetify connects. |
SongChanged |
@server.on_song_changed |
TrackInfo |
Fired when a new track starts playing. |
PlayPauseChanged |
@server.on_play_pause_changed |
PlayerState |
Fired when playback state changes. |
VolumeChanged |
@server.on_volume_changed |
float (0–100%) |
Fired when volume level changes. |
RepeatChanged |
@server.on_repeat_changed |
RepeatMode |
Fired when repeat mode changes (OFF, CONTEXT, TRACK). |
ShuffleChanged |
@server.on_shuffle_changed |
bool |
Fired when shuffle mode is toggled. |
SeekChanged |
@server.on_seek_changed |
int (ms) |
Fired when timeline position is manually changed. |
Metadata
Release files for spicetify-websocket 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| spicetify_websocket-0.1.1.tar.gz | 16.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| spicetify_websocket-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.3 kB
Release files / spicetify_websocket-0.1.1.tar.gz
| Download URL | spicetify_websocket-0.1.1.tar.gz |
|---|---|
| Size | 16.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4be2779eb2adaea241db16f093772f33c838a05477857ea61be2c2656537fff4
|
|
BLAKE2b-256 checksum How to use checksums |
8df2c2a84c37a0be7068a9140deed70edd33570a0893b335752523a7cf18dc0a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 29, 2026.
Transparency logRelease files / spicetify_websocket-0.1.1-py3-none-any.whl
| Download URL | spicetify_websocket-0.1.1-py3-none-any.whl |
|---|---|
| Size | 13.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f05ccd45f7f51b474bca73c5f251ddd3fe912d121e73fb27bf449748ea395290
|
|
BLAKE2b-256 checksum How to use checksums |
43088ff85966002f8ed23d815ad75619a26e2c3fedc4bd6ebd066fc87338f074
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 29, 2026.
Transparency log