Skip to content
πŸ”ˆ Sonos Media Player Interface/Client
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github docs: Some tests for real devices Jan 31, 2018
docs feat: Added removing items from the queue Dec 5, 2018
examples Merge pull request #390 from Villarrealized/feature/queue-events Jan 21, 2019
lib expose items id and parentID (#404) Mar 21, 2019
test expose items id and parentID (#404) Mar 21, 2019
.gitignore added VSCode ignores May 28, 2016
.travis.yml Add Node 10 to test matrix May 11, 2018 docs: update licence year Jan 1, 2018
index.js Standard Code Style Apr 10, 2015
logo.svg Optimize the svg logo Jan 13, 2018
renovate.json chore: automate dependency upgrades < major May 9, 2018

node-sonos logo


Control your Sonos devices with JavaScript (node.js)

Travis Build NPM Version NPM Downloads Standard Codestyle

node-sonos gives you the power to control all your Sonos devices from your own apps in JavaScript. Automatically discover your devices on the network and control the playback and queue with instant events announcing change.


  • Device Discovery
  • Queue Control
  • Volume Control
  • Spotify Support
  • Radio
  • Change Events


Published versions (recommended)

$ npm install sonos

From the repo, living on the edge

$ npm install git://

Quick Start

Discovering Devices

const { DeviceDiscovery } = require('sonos')

// event on all found...
DeviceDiscovery((device) => {
  console.log('found device at ' +

  // mute every device...
    .then(`${} now muted`)

// find one device
DeviceDiscovery().once('DeviceAvailable', (device) => {
  console.log('found device at ' +

  // get all groups

Controlling Known Devices

const { Sonos } = require('sonos')

const device = new Sonos('');
  .then(() => console.log('now playing'))

  .then((volume) => console.log(`current volume = ${volume}`))


  • DeviceDiscovery([options], [deviceAvailableListener])
  • Class: DeviceDiscovery([options])
    • Event: 'DeviceAvailable'
    • destroy()
  • Class: Sonos(host, [port])
    • currentTrack()
    • deviceDescription()
    • flush()
    • getCurrentState()
    • getLEDState()
    • getMusicLibrary(search, options)
    • getMuted()
    • getTopology() Doesn't work if you upgraded to Sonos v9.1. Check-out getAllGroups() for some replacement.
    • getVolume()
    • getZoneAttrs()
    • getZoneInfo()
    • getQueue()
    • next()
    • parseDIDL(didl)
    • pause()
    • play(uri)
    • togglePlayback()
    • previous()
    • queue(uri, positionInQueue)
    • queueNext(uri)
    • request(endpoint, action, body, responseTag)
    • seek(seconds)
    • setLEDState(desiredState)
    • setMuted(muted)
    • setName(name)
    • getPlayMode()
    • setPlayMode(mode)
    • setVolume(volume)
    • stop()
    • setSpotifyRegion(region)
    • alarmClockService()
      • ListAlarms()
      • PatchAlarm(id,options)
      • SetAlarm(id,enabled)
    • joinGroup(otherDeviceName)
    • leaveGroup()
    • getAllGroups()
    • startListening(options)
    • stopListening()
    • Event: 'CurrentTrack'
    • Event: 'NextTrack'
    • Event: 'PlayState' and 'PlaybackStopped'
    • Event: 'AVTransport'
    • Event: 'Volume'
    • Event: 'Muted'
    • Event: 'RenderingControl'


We tried to add jsdoc info to all functions, and generate documentation from it. /docs


Additional examples can be found in the /examples directory within the repository.

In The Wild

node-sonos in use across the interwebs. Missing yours? Add it and send us a pull request!


  • AirSonos - Apple AirPlay (iOS, OS X) support to all Sonos devices on a network.
  • sonos-cli - Command Line Interface for Sonos
  • sonos2mqtt - Bridge between Sonos and an MQTT server
  • homebridge-zp - Homebridge plugin for Sonos ZonePlayer
  • ZenMusic - Control Sonos thru #Slack!
  • gladys-sonos - Control Sonos with Gladys a Raspberry Pi Home Assistant
  • sonos-web - Sonos controller for your web browser



  • Ben Evans (@bencevans)
  • Stephen Wan (@stephen)
  • Marshall T. Rose (@mrose17)
  • Stephan van Rooij (@svrooij)

And a big thanks to all you other contributors! Pull-requests are beautiful things.


If you got discovered an issue with this library, please check the issue-tracker. And create an issue if your problem isn't discovered by someone else. If you want to contribute something check out these 'help-wanted' issues.


Do you have a question about this library, we are glad to help you Ask Question. You can see all questions here

NPM publish

We try to react to all pull-requests, but if you think we don't respond in time, please don't create a 'sonos-by-xyz' or a 'node-sonos-by-xyz' package on NPM. This might lead to people installing the wrong version.

If you want to publish your own version, please do it as a user-scoped eg. @svrooij/sonos package.

  1. Change the top of the readme to state your specific changes.
  2. Change the name of the project to @npm_username/sonos
  3. Publish it to npm npm publish --access=public

Node Sonos v0.x (non async)

At 30 jan 2018 we released an promisified version of node-sonos. The old version can be found in the v0.x branch. It won't get any new features, but it might get security updates.


MIT Β© Ben Evans

You can’t perform that action at this time.