soco
SoCo (Sonos Controller) is a simple library to control Sonos speakers.
What it is and what it does
SoCo provides a Python interface to control Sonos speakers on your local network. It lets you discover speakers, adjust volume and playback, manage queues, group speakers, and retrieve track information—all programmatically rather than through the official app. The library communicates with Sonos devices via UPnP/SOAP protocols and exposes both high-level convenience methods (play, pause, volume) and lower-level access to Sonos services for advanced use cases.
The package depends on requests for HTTP communication, xmltodict and lxml for parsing Sonos XML responses, ifaddr for network interface discovery, and appdirs for configuration storage. It supports Python 3.6 and newer, including recent versions through 3.14. The library is actively maintained and has been in development since 2013, with a team of contributors managing the GitHub repository.
Use it for:
- Automate music playback across multiple Sonos speakers from a Python script or home automation system.
- Build a custom web dashboard or mobile app to control Sonos speakers without relying on the official Sonos app.
- Integrate Sonos control into a larger home automation workflow (e.g., play music when motion is detected).
- Programmatically manage speaker groups and queue content based on time of day or external events.
- Query current playback state and track information to log listening history or trigger actions based on what's playing.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
SoCo is a Python library for programmatic control of Sonos speakers over a network, supporting playback, volume, queue management, and speaker grouping.
Yes. SoCo is actively maintained, has no known vulnerabilities, installs with low friction, and is released under a permissive MIT license. It is well-suited for anyone needing programmatic control of Sonos speakers. Be aware that some music services (Spotify, Apple Music, Amazon Music, Google Play Music, Napster) have known authentication issues; local library and TuneIn radio are more reliable. If your use case centers on those services, verify the current status of issue #557 before committing.
Install
soco on PyPI
pip
pip install socouv
uv add socopoetry
poetry add socoInstalling soco
Before you install
Installation is straightforward with low friction; the package is pure Python and pulls in five standard dependencies (requests, xmltodict, ifaddr, appdirs, lxml). Maintenance is active with a recent release and ongoing development.
License in practice
MIT License is permissive and imposes no significant restrictions on use, modification, or distribution for commercial or private projects.
Quickstart
pip install soco
from soco import discover
for zone in discover():
print(zone.player_name)
zone.volume = 10
Requires a Sonos speaker reachable on the local network; discovery relies on network access to the Sonos device.
Verify before relying
- Current status of music service authentication issues (Google Play Music, Apple Music, Amazon Music, Spotify, Napster) and whether v0.26.0+ fixes are stable.
- Whether the nascent music service support mentioned in the description is production-ready or still experimental.
Package facts
| License | MIT License (permissive) |
| Python support | supports the current Python release (>=3.6) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 5 — requests, xmltodict, ifaddr, appdirs, lxml |
| Maintenance | actively maintained — 16 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 164,232/month — #10,556 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: soco-0.31.2-py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
libsoundtouchControl Bose Soundtouch devices over the…
permissive · top 15,000 on PyPI
sonos-websocketAsync Python library for communicating with…
permissive · top 15,000 on PyPI
wiimwiim provides a Python API to discover,…
permissive · top 15,000 on PyPI
roonapiPython client library for the Roon music server…
permissive · top 15,000 on PyPI
python-songpalPython library for controlling Sony audio…
copyleft · top 15,000 on PyPI
aioslimprotoAsync Python implementation of the SLIMProto…
permissive · top 15,000 on PyPI
pysqueezeboxAsynchronous Python library to control Logitech…
permissive · top 15,000 on PyPI
playsoundPlays audio files (MP3, WAV) and URLs from…
permissive · top 15,000 on PyPI
pyheosAn asynchronous Python library for controlling…
permissive · top 15,000 on PyPI
SoundCardSoundCard plays and records audio across Linux,…
permissive · top 15,000 on PyPI