Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Logitech SqueezeServer JSONRPC API
Squeezebox API
--------------
This document outlines the JSON RPC interface with a squeezeserver to control and obtain information about squeezeboxes.
JSON : JavaScript Object Notation
RPC : Remote Procedure Call
Uses POST requests sent to:
http://<squeezeserver_address>:9000/jsonrpc.js
With Content-Type header set to
application/json
And a JSON object in the body.
{'method': 'slim.request', 'params': [<player_mac_address>, <command>]}
where <player_mac_address> is the squeezebox's MAC address that you are controlling (or "-" to get server info).
and <command> is the command you want to send.
# Simple commands:
- PLAY: ["play"]
- PAUSE: ["pause"],
- POWER ON: ["power", "1"],
- POWER OFF: ["power", "0"],
- VOLUME UP: ["mixer","volume","+<i>"], # <i> is a base 10 number. (volume goes from 0-100)
- VOLUME DOWN: ["mixer","volume","-<i>"],
- SET VOLUME: ["mixer","volume","<i>"],
- SLEEP IN SECONDS: ["sleep","300"],
- SLEEP END OF SONG: ["jiveendoftracksleep"],
- SKIP: ["playlist","index","+1"],
- PREVIOUS: ["playlist","index","-1"],
- UNSYNC FROM ALL PLAYERS: ["sync","-"]
So to pause the squeezebox with mac address FF:FF:FF:FF you would send the JSON object:
{'method': 'slim.request', 'params': ["FF:FF:FF:FF", ["play"]]}
To get a player's status use the command:
STATUS: ["status","-"]
To SYNCHRONISE two players together:
'params': [<master>, ["sync",<slave>]]
where <master> and <slave> are the player MAC address strings.
The slave player will follow the master player.
To SWITCH PLAYER from one squeezebox to another.
'params': [<either>["switchplayer","from:" + <source>,"to:" + <destination>]]
where <source>, <destination> and <either> are the player MAC address strings.
The music will be sent from the source player to the destination player.
You can get the connected players with:
use get number of players first:
'params': ["FF:FF:FF:FF", ["player","count", "?"]]
Then using returned _count:
'params': ["FF:FF:FF:FF", ["players","0", <count>]]
You can search for music accroding to a search term by:
SEARCH: ["search", <i>, <j>, "term:" + <search_term>]
where <search_term> is the search term,
<i> is the beginning index, and <j> the finish index. ie. for the first 10 results: i=0, j=10.
Once you have obtained the "id" of the music you want to play, you can set it to play on a squeezebox:
- ["playlistcontrol", "cmd:"+<cmd>, "artist_id:"+<artist_id>]
- ["playlistcontrol", "cmd:"+<cmd>, "album_id:"+<album_id>]
- ["playlistcontrol", "cmd:"+<cmd>, "track_id:"+<track_id>]
where command is one of:
- PLAY NOW: "load"
- ADD TO END: "add"
- ADD NEXT: "insert"
@Ishidres

This comment has been minimized.

Copy link

@Ishidres Ishidres commented May 24, 2019

Thanks, very helpful!

@foxsam21

This comment has been minimized.

Copy link

@foxsam21 foxsam21 commented Jul 21, 2019

To get a player's status use the command:
STATUS: ["status","-"]

Does this work using this library or is it only by querying the server directly?

@samtherussell

This comment has been minimized.

Copy link
Owner Author

@samtherussell samtherussell commented Oct 27, 2019

Sorry for not replying. This is the Squeeze Server JSON RPC api. https://github.com/samtherussell/squeezebox-controller library interfaces with the Squeeze Server using this api, but so could any thing else if it so wished.

@mvgrimes

This comment has been minimized.

Copy link

@mvgrimes mvgrimes commented Jul 21, 2020

Thanks for this. One fix for getting the list of players:

'params': ["FF:FF:FF:FF", ["player","0", <count>]]

should be:

'params': ["FF:FF:FF:FF", ["players","0", <count>]]
@samtherussell

This comment has been minimized.

Copy link
Owner Author

@samtherussell samtherussell commented Jul 27, 2020

Thanks for this. One fix for getting the list of players:

'params': ["FF:FF:FF:FF", ["player","0", <count>]]

should be:

'params': ["FF:FF:FF:FF", ["players","0", <count>]]

Done. Thanks for the suggestion

@nbeversl

This comment has been minimized.

Copy link

@nbeversl nbeversl commented Nov 13, 2020

If you are doing this from an IP address other than the server's, how do you get around the CORS issue?

@samtherussell

This comment has been minimized.

Copy link
Owner Author

@samtherussell samtherussell commented Nov 22, 2020

Sorry, I ran these requests from a python program not a webpage so I don't know. My intuition would be you'd have to disable CORS protection in the browser or make your webserver do the request not the client browser.

@dcsooner

This comment has been minimized.

Copy link

@dcsooner dcsooner commented Feb 15, 2021

Warnings here that I don't have much of a coding background. Running LMS on an RPi with the Chromecast add-in to play on my speakers. Do you know how to incorporate this into webCoRE? Below is a piston I'm trying to write to play a playlist, but I'd probably first need to start with a single file. Also, I'm having trouble using the commands to figure out the track or album IDs.

image

@samtherussell

This comment has been minimized.

Copy link
Owner Author

@samtherussell samtherussell commented Feb 21, 2021

Sorry I don't know and don't a have a system to test on at the moment but could image it would take the form:

["playlistcontrol", "cmd:load", "playlist_id:<playlist_id>"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment