skillfed

soco

SoCo (Sonos Controller) is a simple library to control Sonos speakers.

soco v0.31.2 164.2K downloads/30d#10,556 on PyPI1,603
Permissive license MIT License Active released

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 soco

uv

uv add soco

poetry

poetry add soco

Installing 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

Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Home AutomationTopic :: Multimedia :: Sound/AudioTopic :: Multimedia :: Sound/Audio :: PlayersTopic :: Software Development :: Libraries :: Python Modules

Tags

sonos speaker control pythonsonos api librarycontrol sonos speakers programmaticallysonos zone player automationsonos music playback controlsonos home automationsonos queue managementsonos device discovery
home-automationsonosupnp

More Python Modules packages