Library / SDK
SoCo/SoCo avatar
SoCo/SoCo

SoCo for Python: controlling Sonos speakers locally

SoCo (Sonos Controller) is a Python project that allows you to programmatically control Sonos speakers.

1,611 stars244 forksPythonMIT

At a glance

What is it?
SoCo is a Python library for controlling Sonos Zone Players through local discovery, playback, volume, queues, groups, and device settings. It suits home automation and scripting, but streaming service authentication remains a documented limitation.
Who is it for?
Adopt SoCo when your Python application needs local Sonos control and can work with the documented feature and service constraints. Do not choose it as the only integration layer for Apple Music, Amazon Music, Spotify, or Napster until the current issue status is checked.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 8 days ago.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on October 15, 2026, and from our analysis. They are not legal advice.

Editorial analysis

SoCo's local Sonos control surface

SoCo solves the problem of controlling Sonos speakers from Python instead of relying on manual commands in the Sonos application. It targets developers building home automation scripts, media controllers, household utilities, and applications that need to coordinate playback across Zone Players. The library is not limited to basic transport commands. The README documents play, pause, stop, track skipping, volume control, mute control, current transport state, and current track metadata.

The scope extends beyond a remote-control interface. SoCo can search and play items from a local music library, TuneIn, music services, and Sonos favorites. It can also manipulate the queue, join and unjoin speakers, place a network into party mode, manage alarms and sleep timers, alter surround and subwoofer settings, and toggle device options such as bass, treble, loudness compensation, night mode, and dialog mode. This makes it closer to a Python API for household audio administration than to a narrow playback wrapper.

The intended boundary is local Sonos control. SoCo does not present itself as a cloud API client or a replacement for the Sonos application. Its low-level access to Sonos services, including ContentDirectory and RenderingControl, is useful for code that needs behavior beyond the high-level convenience methods. The project documentation at python-soco.com and its GitHub repository are the relevant references for detailed functionality, while the README supplies the basic usage model.

Discovery, SoCo objects, and playback data flow

The main programming object is a SoCo instance representing one Zone Player. When the IP address is known, the README creates that object directly. The object exposes properties such as player_name, status_light, and volume. When the address is unknown, discover() searches the network and returns a Python set of SoCo objects. Converting that set to a list is useful when the calling code needs ordered, repeatable access.

A playback script follows a simple data path. It creates or discovers a Zone Player, sends a URI to play_uri(), then calls get_current_track_info(). The returned dictionary contains fields such as title, artist, album, track length, elapsed duration, playlist position, and URI when available. Transport methods such as pause() and play() act on the selected speaker or group.

The API also represents Sonos system relationships. Queue operations can retrieve, add, clear, and play items. Grouping methods join or unjoin speakers, and party mode operates across the speakers in a network. This matters for applications because a single SoCo object is not necessarily the same thing as one physical speaker once several Zone Players are grouped. The README does not document discovery timeouts, retry behavior, authentication for discovery, or conflict handling when two scripts control the same player. Those behaviors should therefore be checked against the detailed documentation and the target network rather than assumed.

Installing SoCo and controlling a first speaker

The README states that SoCo requires Python 3.8 or newer and gives pip as the installation route. The repository also contains setup metadata, requirements files, tests, examples, and documentation. Install the published package in the environment where the automation will run:

bash
pip install soco

The README says pip installs the Python dependencies automatically. The listed dependencies include requests, xmltodict, ifaddr, appdirs, and lxml. A first script can import SoCo, connect to a known speaker, change its status light and volume, and read the player name:

python
from soco import SoCo

my_zone = SoCo('192.168.1.101')
my_zone.status_light = True
my_zone.volume = 6

The README uses 192.168.1.101 as the example address. The script assumes that the speaker is reachable at that address. For a network with several devices, the documented discovery form prints the names of every returned Zone Player:

python
from soco import discover

for zone in discover():
    print(zone.player_name)

A caller that needs indexable results can convert the set to a list, as shown in the README. That distinction is a small implementation constraint. `discover()` does not return a list by default, and the README does not promise a particular ordering.

Streaming service authentication and documented feature gaps

The most significant limitation is stated directly in the README: Sonos changed music service authentication, and a number of streaming services currently have known issues or cannot be used at all. Apple Music, Amazon Music, Spotify, and Napster are listed as affected. The README points readers to the project's GitHub Issues for current status and describes support as an ongoing effort.

That warning affects more than search. An application can work with a direct media URI, local library items, and documented playback controls while still failing when it assumes every Sonos music service will authenticate correctly. SoCo should not be treated as a promise of uniform access across commercial streaming providers. The library also does not, in the README, describe how credentials are supplied for each service, whether token storage is handled by SoCo, or how a caller can safely recover from an authentication failure. Those details need to come from the service-specific documentation or current issue discussions.

Another limitation is the gap between broad feature listing and deployment conditions. Line-in and TV input require a Zone Player that supports them. Album art is conditional on availability. Transport information is limited to the playing, paused, or stopped states documented by the project. Local library access also depends on the speaker's configured library and the network context. SoCo offers many endpoints, but it does not remove hardware or account requirements imposed by Sonos.

Command-line and GUI alternatives to direct Python control

The README identifies Socos as a command-line tool developed in conjunction with SoCo but kept in a separate repository. Its approach is scriptable terminal operation rather than importing a Python object into an application. This can be useful when the required behavior is a shell command, a scheduled task, or a small operational script that does not need a custom Python program.

SoCo-CLI is another documented alternative, described as a fully featured command-line tool for scripts and scheduled tasks. The README says it supports time-based and state-based actions, repeated commands through loops, direct playback of local audio files, and multi-household Sonos systems. Its center of gravity is command automation, while SoCo's center of gravity is Python API access. The choice depends on whether the team needs to embed control logic in Python or prefers command-oriented automation.

For graphical or non-Python use, the README mentions older projects, including a Ruby gem and SoCo-Tk, but explicitly describes them as no longer maintained. That makes them weaker choices for a new deployment based solely on the available maintenance information. SoCo itself is released under the MIT license, which generally permits broad reuse and modification, subject to the license terms, but the README does not provide legal guidance or compatibility guarantees for a particular product.

Upgrade cost, packaging, and maintenance signals

SoCo is packaged as the `soco` project and is installable with `pip`. The repository contains `pyproject.toml`, `setup.py`, `requirements.txt`, `requirements-dev.txt`, a `makefile`, tests, documentation, and several example directories. The `setup.py` file retains a test command that excludes integration tests because those tests need an actual Sonos device. Based on that file, local test execution does not replace validation against real hardware.

There is a version-support inconsistency worth checking before adoption. The README requires Python 3.8 or newer. `pyproject.toml` declares `requires-python = ">=3.6"`, and its classifiers list Python 3.6 through 3.15, while the README's stated minimum is higher. The package metadata also uses different setuptools requirements depending on Python versions. A developer should not infer the supported runtime from one file alone. The README's explicit installation requirement is the safer starting point, but the package metadata should be checked when preparing a supported production environment.

The repository is not archived, and the last push was on 2026-10-15. Recent releases listed include v0.31.5 on 2026-10-06, v0.31.4 on 2026-09-24, and v0.31.3 on 2026-09-24. Those records indicate recent project activity, but they do not guarantee compatibility with every streaming service or every Sonos deployment. Upgrades require reviewing release notes and testing the particular services, discovery setup, and hardware used by the application.

Editorial conclusion

Adopt SoCo when your Python application needs local Sonos control and can work with the documented feature and service constraints. Do not choose it as the only integration layer for Apple Music, Amazon Music, Spotify, or Napster until the current issue status is checked. Verify first that your Python version, network discovery, target Zone Player, and required control surface match the documented setup, because the repository has conflicting support statements: the README requires Python 3.8 or newer, while pyproject.toml declares requires-python >=3.6. The last push was on 2026-10-15, and releases v0.31.3, v0.31.4, and v0.31.5 are listed.

Frequently asked questions

How do I install SoCo for Python?

The README instructs users to run `pip install soco` and says SoCo requires Python 3.8 or newer. The repository metadata also contains Python version classifiers, but it declares a lower `requires-python` value, so the runtime requirement should be checked before deployment.

How does SoCo discover Sonos speakers?

The documented `discover()` function searches the network and returns a Python set of SoCo objects representing Zone Players. If the IP address is known, `SoCo('192.168.1.101')` can target a specific device instead.

Can SoCo control Apple Music, Amazon Music, Spotify, and Napster?

The README warns that these services currently have known issues or cannot be used at all because Sonos changed music service authentication. It points to the SoCo GitHub Issues for current status.

What can SoCo do besides play audio?

The documented API includes volume and mute control, track metadata, queues, groups, party mode, alarms, sleep timers, audio settings, source switching, speaker information, and library updates. Some operations depend on Zone Player capabilities, such as TV input or surround configuration.

Official sources

  1. License: MIT
  2. Project website
  3. README
  4. Releases
  5. SoCo/SoCo on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/soco-soco.svg)](https://hysenlabs.com/projects/soco-soco)