Bluesound API decoded

Free-for-all chat about the Bluesound Ecosystem.
bruce_miranda
Posts: 51
Joined: Sun Sep 14, 2014 12:08 pm

Bluesound API decoded

Post by bruce_miranda » Tue Nov 10, 2015 11:11 am

The API for controlling the Bluesound players turned out to be surprising simple to decode. This isn't a how to guide. But all I can say is that if you have a Browser and know your player's IP address you can do pretty much everything the controllers do. You just need to know what you want to do, how to do it and then do something with the player's response.

All you need to do is issue HTTP commands to the IP address of the player at port 11000. Every command issued will give you an XML return response that contains more information that you can then use to do stuff with.

e.g. If you player's IP address is 192.168.1.38 (you can find this value in the Diagnostics)

I'm not intending to document and reverse engineer everything because I got what I need. But thought this might be helpful for others.

Simple commands:
http://192.168.1.38:11000/Pause
http://192.168.1.38:11000/Play
http://192.168.1.38:11000/Skip
http://192.168.1.38:11000/Back

Commands can take other variables too.
http://192.168.1.38:11000/Play?id=0 (play 1st song from playlist)
http://192.168.1.38:11000/Play?seek=60 (jump to 60th second in the playing track)

http://192.168.1.38:11000/Volume?level=0 (value is % so 0 is mute or -91db and 100 is full volume or 0db)
http://192.168.1.38:11000/Repeat?state=0 (different repeat states 0,1,2)
http://192.168.1.38:11000/Shuffle?state=0 (different repeat states 0,1)

The controllers seem to issue the following commands every second alternatively to get their status.
http://192.168.1.38:11000/SyncStatus
http://192.168.1.38:11000/Status

And then using the returned values of those commands they do other stuff like get the Artwork for the song playing.
http://192.168.1.38:11000/Artwork?service=LocalMusic&album=&artist= (insert album and artist name in the URL)

Grouping and Ungrouping of players are done with the
http://192.168.1.38:11000/AddSlave?slave=192.168.1.41&group=Study%20Player (Study Player is the group name)
http://192.168.1.38:11000/RemoveSlave?slave=192.168.1.41

You can get the list of Services that the player can use using
http://192.168.1.38:11000/Services
Or browse through the Radio Service using
http://192.168.1.38:11000/RadioBrowse

Jump to
http://192.168.1.38:11000/Playlists
http://192.168.1.38:11000/Genres?service=LocalMusic (Library)
http://192.168.1.38:11000/RadioBrowse?service=TuneIn (TuneIn Radio)

This command appears to provide a list of all the Inputs
http://192.168.1.38:11000/RadioBrowse?service=Capture

Then you can switch to them using
http://192.168.1.38:11000/Play?url=Capture%3Ahw%3A1%2C0%2F1%2F25%2F2&preset_id&image=/images/inputIcon.png (Optical Input)
http://192.168.1.38:11000/Play?url=Capture%3Abluez%3Abluetooth&preset_id&image=/images/BluetoothIcon.png (Bluetooth Input)

Hope other people can build on this library of functions.

cybacolt
Posts: 3
Joined: Sun Jun 21, 2015 10:17 pm

Re: Bluesound API decoded

Post by cybacolt » Sun Nov 22, 2015 10:05 pm

nice!

so tempted to have a go at writing my own player... handling of playlists and the UI in bluesounds app unfortunately leaves alot to be desired... :(

randy
Posts: 7
Joined: Sun Nov 29, 2015 1:08 am

Re: Bluesound API decoded

Post by randy » Sun Nov 29, 2015 1:25 am

I've been looking for a way to play/pause my Node from the media keys on a keyboard, so I wrote the following scripts and configured my media keys to launch them. These scripts first check to see if the player is currently paused, and if so, sends the "Play" HTTP request per the details outlined in bruce_miranda's post. Otherwise, it sends the "Pause" HTTP request. This approach should be valid for any of the requests that the Bluesound products accept.

Windows VB Script
Save this code to a file with a .vbs extension:

Code: Select all

dim HttpRequest
set HttpRequest = CreateObject("Microsoft.XMLHTTP")
HttpRequest.Open "GET", "http://192.168.1.38:11000/Status", False
HttpRequest.Send
If InStr(HttpRequest.ResponseText, "<state>pause</state>") Then
	HttpRequest.Open "GET", "http://192.168.1.38:11000/Play", False
	HttpRequest.Send
Else
	HttpRequest.Open "GET", "http://192.168.1.38:11000/Pause", False
	HttpRequest.Send
End If
Linux Bash Script
Save this code to a file and make it executable with chmod a+x <filename>

Code: Select all

wget -q -O- 192.168.1.38:11000/Status | grep -q "<state>pause</state>"
if [ $? -eq 0 ] ; then
	wget -q -O- 192.168.1.38:11000/Play > null
else
	wget -q -O- 192.168.1.38:11000/Pause > null
fi

randy
Posts: 7
Joined: Sun Nov 29, 2015 1:08 am

Re: Bluesound API decoded

Post by randy » Sun Nov 29, 2015 1:46 am


randy
Posts: 7
Joined: Sun Nov 29, 2015 1:08 am

Re: Bluesound API decoded

Post by randy » Tue Dec 01, 2015 9:35 am

Sorry, my bad. The Linux script should be...

Code: Select all

wget -q -O- 192.168.1.38:11000/Status | grep -q "<state>pause</state>"
if [ $? -eq 0 ] ; then
   wget -q -O- 192.168.1.38:11000/Play > /dev/null
else
   wget -q -O- 192.168.1.38:11000/Pause > /dev/null
fi
And if you want the script to resume playback from a "stopped" state, simply flip the logic as follows:

Windows

Code: Select all

dim HttpRequest
set HttpRequest = CreateObject("Microsoft.XMLHTTP")
HttpRequest.Open "GET", "http://192.168.1.38:11000/Status", False
HttpRequest.Send
If InStr(HttpRequest.ResponseText, "<state>play</state>") Then
   HttpRequest.Open "GET", "http://192.168.1.38:11000/Pause", False
   HttpRequest.Send
Else
   HttpRequest.Open "GET", "http://192.168.1.38:11000/Play", False
   HttpRequest.Send
End If
Linux

Code: Select all

wget -q -O- 192.168.1.38:11000/Status | grep -q "<state>play</state>"
if [ $? -eq 0 ] ; then
   wget -q -O- 192.168.1.38:11000/Pause > /dev/null
else
   wget -q -O- 192.168.1.38:11000/Play > /dev/null
fi

jaga01
Posts: 1
Joined: Fri Dec 04, 2015 4:26 pm

Re: Bluesound API decoded

Post by jaga01 » Fri Dec 04, 2015 4:36 pm

Hi,
I have a node and I have bought the flic button. Now I am able to control my node with those very cool buttons. What I seek is playing my Tunein favorittes or presets. Do you have any idear how to do that?

I have made them presets 1 and 2 and would like to choose one and have it accomplish playback of that station preset.

Can you help?

Regards, Jacob

jelle
Posts: 7
Joined: Wed Dec 09, 2015 1:05 am

Re: Bluesound API decoded

Post by jelle » Wed Dec 09, 2015 1:21 am

You can use the following:

http://192.168.1.115:11000/Preset?id=1

Just replace the IP address to the one of your Bluesound. Of course you can change the preset-id.

mnemoniclane
Posts: 27
Joined: Thu Dec 17, 2015 9:19 am

Re: Bluesound API decoded

Post by mnemoniclane » Thu Dec 17, 2015 9:25 am

Hi there,
This is really great info, thanks!
Any ideas on how to search the local network for players (instead of specifying the ip address)?
What tool did you use to find the commands?

mnemoniclane
Posts: 27
Joined: Thu Dec 17, 2015 9:19 am

Re: Bluesound API decoded

Post by mnemoniclane » Thu Dec 17, 2015 12:51 pm

mnemoniclane wrote: Any ideas on how to search the local network for players (instead of specifying the ip address)?
I found a way to search for players (if anyone else are interested). You can use Zeroconf (https://github.com/onovotny/Zeroconf) and search for "_musc._tcp.local.".

mnemoniclane
Posts: 27
Joined: Thu Dec 17, 2015 9:19 am

Re: Bluesound API decoded

Post by mnemoniclane » Fri Dec 18, 2015 2:27 pm

Are there any alternatives to polling http://x.x.x.x:11000/Status and checking the etag in the xml (long polling, websockets, ...)?

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests