How do you use Tuneblade API http

280 views
Skip to first unread message

Lindeck...@yahoo.fr

unread,
Apr 2, 2016, 9:47:54 AM4/2/16
to TuneBlade
Hi

I try to use Tuneblade API but i don't understand (i'm a newbie of course)
I just read the tuneblade remote api v0.7.pdf and i don't undestand the http command line.
I just want to connect a Device
I must use this line below to make my command

Connect/Disconnect with a device
HTTP
MethodPUT
URI/devices/{ID}
RequestHeaders Content-length Content-type
Request Body{“Status”: “Connect”}
Response Headers n/a
Response Body n/a

can you give me a example to make this http command line like this:

http://192.168.x.x:51459.....................................................

thanks for your help

TuneBlade Support

unread,
Apr 3, 2016, 2:22:10 PM4/3/16
to tune...@googlegroups.com
Hi, 

We prepared a small document a while back explaining on how to use the API including some sample test cases:


The examples are shown using  DEV HTTP Client from the Chrome app store: https://chrome.google.com/webstore/detail/dhc-rest-client/aejoelaoggembcahagimdiliamlcdmfm?hl=en

You can read from the second section "Rest Client for Testing" of the document. 

To summarize, you need to first send a "GET" request to get a list of all devices available in TuneBlade: 


(Where 192.168.x.x is the IP address of the PC running TuneBlade, and 51459 is the port number. Make sure these are as per your setup.)

The response will be in json format, including the ID of each device which you'll need to control that device in TuneBlade. Refer Test 1 in the document. 

Once you have the ID of a device you're interested in, you can then issue a PUT statement for that device, example: 

Refer Test 2 in the document.

Please feel free to get back to us for any further support on this. 

Thanks,
The TuneBlade Team

Lindeck...@yahoo.fr

unread,
Apr 4, 2016, 11:52:06 AM4/4/16
to TuneBlade
Ok thanks this is very helpful

I followed your answer and:

To obtain the list of ID Device: everything is good, i use this command line http://192.168.x.x:51459/devices with my own Ip adress and i have my five ID device

to connect a device and increase or decrease volume, i used http requester firefox addon. i used the PUT command and no problem

But i try this commande line http://192.168.x.x:51459/devices/F4CAE5512C5F@Freebox Server
with my own IP adress and I only GET the status. This sentence doesn't connect my device. What is the good http command line with argument to PUT command. I try this but no response:

http://localhost:51497/devices/F4CAE5512C5F@Freebox Server,"Status":"Connect"

An other help please ?. Noob is back

Noel Hibbard

unread,
Apr 4, 2016, 2:17:26 PM4/4/16
to TuneBlade
What do you mean by "command line"? Are you trying to build a curl command line? If so there is already an example on this forum somewhere if I recall correctly.

Lindeck...@yahoo.fr

unread,
Apr 5, 2016, 5:55:03 AM4/5/16
to TuneBlade
Arf. My english is not very good. Not à command line but à http request.

This http request in my browser search bar is ok. It's seems like a get command
http://192.168.x.x:51459/devices

This http request is also good i have the status of my device
http://192.168.x.x:51459/devices/Dreyfus@free box

But what is the http request to connect and disconnect à device and increase or decrease the volume ?

TuneBlade Support

unread,
Apr 5, 2016, 4:58:58 PM4/5/16
to TuneBlade
Hi, 

When you enter a URL in the browser address bar, it goes as a GET request. Connect/Disconnect and Volume changes require you to send a PUT request which can't be done normally by entering in the address bar. 

There are several HTTP/REST clients available that you can use to send a PUT request. The command in json format, {"Status": "Connect"} should be in the body of the request.  One such is an add-on for Chrome that we use internally for our testing as mentioned in our previous post: https://chrome.google.com/webstore/detail/dhc-rest-client/aejoelaoggembcahagimdiliamlcdmfm?hl=en . Refer the screenshot below especially the highlighted areas on where to change to 'PUT and insert the body':


Lindeck...@yahoo.fr

unread,
Apr 6, 2016, 1:47:42 PM4/6/16
to TuneBlade
ok i tried your solution and it works thanks for your help

I have a other question (my last question) about curl command to send a PUT to connect and diconnect device and a PUT to increase and decrease volume

I found this on support but i don't understand your answer because it's new for me:

the question about curl volume
curl -X PUT -H "Content-Type: application/json" -H "Content-Length: 34" -d "{\"Status\": \"Connect\", \"Volume\": 5}" http://localhost:52000/Functions

... and your answer
Hi,

The uri should be <base-url>/master instead of <base-url>/functions. Our apologies as the developer document has this errata. (You may already know this: in order to control Master volume, it should be enabled in TuneBlade)

Thanks,
The TuneBlade Team


Can you give me the complete curl command line to PUT connect/diconnect device and to PUT volume (set level)

thks for your patience

TuneBlade Support

unread,
Apr 6, 2016, 5:26:40 PM4/6/16
to TuneBlade
Hi, 

The post you're referring to was for Master control i.e. if you have more than one device, you can use this command to increase/decrease volume or connect/disconnect to all devices simultaneously. This will only work if the Master control options is enabled in TuneBlade's General settings (Settings > General tab > User interface settings > Show master control options checkbox should be checked.) . Example for curl command for Master control: 

curl -X PUT -H "Content-Type: application/json" -H "Content-Length: 34" -d "{\"Status\": \"Connect\", \"Volume\": 5}" http://localhost:52000/Master

Similarly, for specific device, example curl will be: 

curl -X PUT -H "Content-Type: application/json" -H "Content-Length: 34" -d "{\"Status\": \"Connect\", \"Volume\": 5}" http://localhost:52000/F4CAE5512C5F@Freebox Server

Please feel free to contact us again. 

Thanks,
The TuneBlade Team

Lindeck...@yahoo.fr

unread,
Apr 7, 2016, 3:05:38 PM4/7/16
to TuneBlade
hi
it'me again

I tested your command and............failed
i have install curl on windows in C:\Users\Administrateur\Documents\curl , i opened a command windows and my command line seems to be :

C:\Users\Administrateur\Documents\curl\curl -X PUT -H "Content-Type: application/json" -H "Content-Length: 34" -d "{\"Status\": \"Connect\", \"Volume\": 5}" http://localhost:52000/F4CAE5512C5F@Freebox Server

the response is
curl(7) fail to connect to localhost :connection refused

i tried 127.0.0.1, tried my own IP 192.168.1.xx, i disabled my firewall and antivirus. The port is auto so 51497

do you have an idea?

TuneBlade Support

unread,
Apr 8, 2016, 12:15:16 AM4/8/16
to TuneBlade
We suggest you to configure a manual port number for remote control via the Settings>Remote Control tab, under Auto/Manual port selection, select 'Manual' and enter a random number between 10000-65535, and then use this port number in curl. (When this is set to Auto, the port number isn't fixed, you need to use Bonjour/Zeroconf APIs to find the port number.)  

Lindeck...@yahoo.fr

unread,
Apr 8, 2016, 1:14:16 PM4/8/16
to TuneBlade
Hi

i changed the port to 40000 and the command line for master volume is:
curl -X PUT -H "Content-Type: application/json" -H "Content-Length: 34" -d "{\"Status\": \"Connect\", \"Volume\": 5}" http://localhost:40000/Master

this line works

but if i replace Master by my device:
curl -X PUT -H "Content-Type: application/json" -H "Content-Length: 34" -d "{\"Status\": \"Connect\", \"Volume\": 5}" http://localhost:40000/1C2800D2F280@Cuisine
it doesn't works

the error message is
unknown resource requested

a solution?

TuneBlade Support

unread,
Apr 8, 2016, 2:55:50 PM4/8/16
to TuneBlade
Our apologies, the URL was missing the "devices" string. It should be:  http://localhost:40000/devices/1C2800D2F280@Cuisine 

Complete command: curl -X PUT -H "Content-Type: application/json" -H "Content-Length: 34" -d "{\"Status\": \"Connect\", \"Volume\": 5}" http://localhost:40000/devices/1C2800D2F280@Cuisine

watchdog.secu...@gmail.com

unread,
May 2, 2016, 5:16:06 AM5/2/16
to TuneBlade
What is the command to disconnect and connect device on curl?

Is there also a command via http like http://localhost:40000/devices/1C2800D2F280@Cuisine/"status:disconnect. ?

TuneBlade Support

unread,
May 3, 2016, 11:15:24 AM5/3/16
to TuneBlade
Hi, 

In order to get the list of devices and their IDs in TuneBlade, you can use the following GET request: 

http://<baseURL(IP:port)>/devices


In order to run a GET command you can use curl, or simply type the URL in any browser and you can get the response in JSON format in the browser window. 

Once you have the IDs, you can also get status of individual devices with  a GET command: 

http://<baseURL(IP:port>/devices/<ID of requested device>


Now, in order to connect/disconnect and change volume, you need to send PUT requests. PUT requests cannot be normally sent via the browser, you need to use CURL or code it in any programming language or use a browser extension such as "DEV HTTP Client"

Here are the curl examples: 

Connect: 
E:\Downloads>curl -X PUT -H "Content-Type: application/json" -H "Content-Length:
 34" -d "{\"Status\": \"Connect\", \"Volume\": 5}" http://10.0.1.10:51490/device
s/123456789@Apple%20TV


Disconnect: 
E:\Downloads>curl -X PUT -H "Content-Type: application/json" -H "Content-Length:
 37" -d "{\"Status\": \"Disconnect\", \"Volume\": 5}" http://10.0.1.10:51490/device
s/C869CD7186DB@Apple%20TV

Note: 
If the URL contains spaces, replace them with %20. 
The Content-Length value should match the length of the body (ignoring escape character "\"). The connect and disconnect command examples can be without the volume change parameter and accordingly, the content-length should be adjusted. Similarly the commands can be without the Status parameter and only with Volume parameter. 

Hope this clarifies, please feel free to discuss. 

We're planning to implement an additional API so that you can control entirely using simple GET requests. Requests will be like : 





etc. 

We think this will make it easier for anyone to integrate into their systems. 

Please feel free to suggest. 

Thanks,
TuneBlade Team


  

 

tki...@gmail.com

unread,
May 20, 2017, 3:24:42 AM5/20/17
to Breakfree Audio, tune...@googlegroups.com
Hi, are there any news about the additional api with GET requests. I would appreciate it very much.

TK

TuneBlade Support

unread,
May 24, 2017, 9:49:09 AM5/24/17
to Breakfree Audio, tune...@googlegroups.com, Lindeck...@yahoo.fr
Hi, 

Thank you for your interest. 

The simpler GET only API is developed, and is in alpha stage. Feel free to try it out in pre-release version 1.6.5.0 : 


Please note the API isn't finalized yet, and is likely to change a little in the final release, and it isn't documented yet. To help you get started: 

- Service discovery is the same as previous i.e.either using Zeroconf / Bonjour, or manually find the IP and hard-code the port in TuneBlade settings. 

- The base url for the new API is http://<baseURL>/v2 . This request will return list of all receivers in plain text format (new line and space separated) in the content section of response. Sample output: 

MASTER 0 100  Master
6BDF379163D2 0 35 TuneAero
FCF152F2C97B 0 86 Sony
 
- The first row is for the master volume if it is enabled in TuneBlade settings, else it will not be there. 
- The first column is the ID of the receiver which should be used to query individual receivers. 
- The second column is the status of the receiver. 0 : Disconnected, 100 : Connected . 
- The third column is the volume at a scale of 100. 
- The fourth column is the friendly name of the receiver. 
- For querying status of individual receiver, use the ID received from the first request, column 1. For example for TuneAero in first example:
 
http://<baseURL>/v2/6BDF379163D2

Some other examples:

Get status: 
http://<baseURL>/v2/6BDF379163D2/Status

Trigger connect: 
http://<baseURL>/v2/6BDF379163D2/Status/Connect

Trigger disconnect: 
http://<baseURL>/v2/6BDF379163D2/Status/Disconnect

Get volume: 
http://<baseURL>/v2/6BDF379163D2/Volume

Set volume to 20: 
http://<baseURL>/v2/6BDF379163D2/Volume/20

For master volume and status, use "master" as the ID in the URL. 

Let us know of any issues, or for any further help. 

Thanks,
The TuneBlade Team
 
Reply all
Reply to author
Forward
0 new messages