REST API Conversion Examples¶
In this guide
This page provides side-by-side examples for converting legacy REST API calls to the newer HTTP API format. Familiarity with HTTP API authentication and JSON message formats is recommended before working through the examples.
If you're using the old REST API (which has been deprecated), here are some examples of how you might convert your REST usages to the HTTP API.
The first thing you'll want to understand is how to use authentication with the HTTP API. The examples below use both headers and query args for authentication. You can use whichever works for you. You should replace YOUR-API-KEY with your actual API Key.
Second, all replies to the API will be JSON messages.
In the following examples, we'll be using a mix of authentication headers and the API Key as a query arg. You can use either. We mark the examples REST (old REST API) and HTTP (newer HTTP API).
Device Access¶
Getting Devices¶
get device list¶
REST
HTTP
This will return a JSON list of Device Objects.
get single device¶
REST
HTTP
Insert the ID of the office-lamp device rather than the name. Note you can quickly copy the device ID to the clipboard by right-clicking on the device in Indigo app's main window and choosing the Copy ID context menu. This will return a single Device Object.
Device Commands¶
Sending commands to devices requires that you POST a JSON message to the /v2/api/command URL.
set brightness¶
REST
HTTP
curl -X POST -H "Authorization: Bearer YOUR-API-KEY" -d '{"message":"indigo.device.setBrightness","objectId":123456789,"parameters":{"value":27}}' http://127.0.0.1:8176/v2/api/command
Insert the ID of the office-lamp device as the objectId.
turn on/turn off¶
REST
curl -X PUT -u user:password --digest -d isOn=1 http://127.0.0.1:8176/devices/office-lamp
curl -X PUT -u user:password --digest -d isOn=0 http://127.0.0.1:8176/devices/office-lamp
HTTP
curl -X POST -H "Authorization: Bearer YOUR-API-KEY" -d '{"message":"indigo.device.turnOn","objectId":123456789}' http://127.0.0.1:8176/v2/api/command
curl -X POST -H "Authorization: Bearer YOUR-API-KEY" -d '{"message":"indigo.device.turnOff","objectId":123456789}' http://127.0.0.1:8176/v2/api/command
Insert the ID of the office-lamp device as the objectId.
toggle¶
REST
HTTP
curl -X POST -H "Authorization: Bearer YOUR-API-KEY" -d '{"message":"indigo.device.toggle","objectId":123456789}' http://127.0.0.1:8176/v2/api/command
Insert the ID of the office-lamp device as the objectId.
change speed index (fan)¶
These examples will set device office-ceiling-fan to 0 (off), then set to 3 (high), then decrease back to 0 (off).
REST
curl -X PUT -u user:password --digest -d speedIndex=0 http://127.0.0.1:8176/devices/office-ceiling-fan
curl -X PUT -u user:password --digest -d speedIndex=3 http://127.0.0.1:8176/devices/office-ceiling-fan
curl -X PUT -u user:password --digest -d speedIndex=dn http://127.0.0.1:8176/devices/office-ceiling-fan
curl -X PUT -u user:password --digest -d speedIndex=dn http://127.0.0.1:8176/devices/office-ceiling-fan
curl -X PUT -u user:password --digest -d speedIndex=dn http://127.0.0.1:8176/devices/office-ceiling-fan
HTTP
curl -X POST -H "Authorization: Bearer YOUR-API-KEY" -d '{"message":"indigo.speedcontrol.setSpeedIndex","objectId":123456789,"parameters":{"value":0}}' http://127.0.0.1:8176/v2/api/command
curl -X POST -H "Authorization: Bearer YOUR-API-KEY" -d '{"message":"indigo.speedcontrol.setSpeedIndex","objectId":123456789,"parameters":{"value":3}}' http://127.0.0.1:8176/v2/api/command
curl -X POST -H "Authorization: Bearer YOUR-API-KEY" -d '{"message":"indigo.speedcontrol.decreaseSpeedIndex","objectId":123456789}' http://127.0.0.1:8176/v2/api/command
curl -X POST -H "Authorization: Bearer YOUR-API-KEY" -d '{"message":"indigo.speedcontrol.decreaseSpeedIndex","objectId":123456789}' http://127.0.0.1:8176/v2/api/command
curl -X POST -H "Authorization: Bearer YOUR-API-KEY" -d '{"message":"indigo.speedcontrol.decreaseSpeedIndex","objectId":123456789}' http://127.0.0.1:8176/v2/api/command
Insert the ID of the office-ceiling-fan device as the objectId.
change sprinkler zones¶
These examples will change device irrmaster-pro active sprinkler zone to 3 and all off.
REST
curl -X PUT -u user:password --digest -d activeZone=3 http://127.0.0.1:8176/devices/irrmaster-pro
curl -X PUT -u user:password --digest -d activeZone=0 http://127.0.0.1:8176/devices/irrmaster-pro
HTTP
curl -X POST -H "Authorization: Bearer YOUR-API-KEY" -d '{"message":"indigo.sprinkler.setActiveZone","objectId":123456789,"parameters":{"index":3}}' http://127.0.0.1:8176/v2/api/command
curl -X POST -H "Authorization: Bearer YOUR-API-KEY" -d '{"message":"indigo.sprinkler.setActiveZone","objectId":123456789,"parameters":{"index":0}}' http://127.0.0.1:8176/v2/api/command
Insert the ID of the irrmaster-pro device as the objectId.
set thermostat setpoints¶
These examples will set device thermostat's heat and cool setpoints
REST
curl -X PUT -u user:password --digest -d setpointCool=76 http://127.0.0.1:8176/devices/thermostat
curl -X PUT -u user:password --digest -d setpointHeat=70 http://127.0.0.1:8176/devices/thermostat
Increase Heat Setpoint
HTTP
curl -X POST -H "Authorization: Bearer YOUR-API-KEY" -d '{"message":"indigo.thermostat.setCoolSetpoint","objectId":123456789,"parameters":{"value":76}}' http://127.0.0.1:8176/v2/api/command
curl -X POST -H "Authorization: Bearer YOUR-API-KEY" -d '{"message":"indigo.thermostat.setHeatSetpoint","objectId":123456789,"parameters":{"value":70}}' http://127.0.0.1:8176/v2/api/command
Increase Heat Setpoint
curl -X POST -H "Authorization: Bearer YOUR-API-KEY" -d '{"message":"indigo.thermostat.increaseHeatSetpoint","objectId":123456789}' http://127.0.0.1:8176/v2/api/command
Insert the ID of the thermostat device as the objectId.
set thermostat mode¶
These examples will set device thermostat's mode to "cool on" and "auto on"
REST
curl -X PUT -u user:password --digest -d hvacCurrentMode="cool on" http://127.0.0.1:8176/devices/thermostat
curl -X PUT -u user:password --digest -d hvacCurrentMode="auto on" http://127.0.0.1:8176/devices/thermostat
HTTP
curl -X POST -H "Authorization: Bearer YOUR-API-KEY" -d '{"message":"indigo.thermostat.setHvacMode","objectId":123456789,"parameters":{"value":"indigo.kHvacMode.Cool"}}' http://127.0.0.1:8176/v2/api/command
curl -X POST -H "Authorization: Bearer YOUR-API-KEY" -d '{"message":"indigo.thermostat.setHvacMode","objectId":123456789,"parameters":{"value":"indigo.kHvacMode.HeatCool"}}' http://127.0.0.1:8176/v2/api/command
Insert the ID of the thermostat device as the objectId.
set thermostat fan mode¶
These examples will set device thermostat's fan mode to "always on" and "auto on"
REST
curl -X PUT -u user:password --digest -d hvacFanMode="always on" http://127.0.0.1:8176/devices/thermostat
curl -X PUT -u user:password --digest -d hvacFanMode="auto on" http://127.0.0.1:8176/devices/thermostat
HTTP
curl -X POST -H "Authorization: Bearer YOUR-API-KEY" -d '{"message":"indigo.thermostat.setFanMode","objectId":123456789,"parameters":{"value":"indigo.kFanMode.AlwaysOn"}}' http://127.0.0.1:8176/v2/api/command
curl -X POST -H "Authorization: Bearer YOUR-API-KEY" -d '{"message":"indigo.thermostat.setFanMode","objectId":123456789,"parameters":{"value":"indigo.kFanMode.Auto"}}' http://127.0.0.1:8176/v2/api/command
Insert the ID of the thermostat device as the objectId.
Variable Access¶
Getting Variables¶
get variable list¶
REST
HTTP
This will return a JSON list of Variable Objects.
get single variable¶
REST
HTTP
Insert the ID of the sprinklerDurationMultiplier variable rather than the name. This will return a single Variable Object.
Variable Commands¶
Sending commands to the server requires that you POST a JSON message to the /v2/api/command URL.
update variable value¶
REST
curl -X PUT -u user:password --digest -d value=1.23 http://127.0.0.1:8176/variables/sprinklerDurationMultiplier
HTTP
curl -X POST -H "Authorization: Bearer YOUR-API-KEY" -d '{"message":"indigo.variable.updateValue","objectId":123456789,"parameters":{"value":"1.23"}}' http://127.0.0.1:8176/v2/api/command
Insert the ID of the sprinklerDurationMultiplier variable as the objectId. Note: variable values are always strings to make sure to enclose the value in quotes.
Action Group Access¶
Getting Action Groups¶
get action group list¶
REST
HTTP
This will return a JSON list of Action Group Objects.
get single action group¶
REST
HTTP
Insert the ID of the party scene action group rather than the name. This will return a single Action Group Object.
Action Group Commands¶
Sending commands to the server requires that you POST a JSON message to the /v2/api/command URL.
execute action group¶
REST
HTTP
curl -X POST -H "Authorization: Bearer YOUR-API-KEY" -d '{"message":"indigo.actionGroup.execute","objectId":123456789}' http://127.0.0.1:8176/v2/api/command
Insert the ID of the party scene action group as the objectId.