Difference between revisions of "Maker API"

From Hubitat Documentation
Jump to: navigation, search
(Content 2.0 change)
 
(Refined instructions to match other docs and added images)
Line 1: Line 1:
 
This API is a simple HTTP GET API that allows you to get the status of your authorized devices and interact with them.
 
This API is a simple HTTP GET API that allows you to get the status of your authorized devices and interact with them.
  
'''Installation:'''
+
=== '''Installing Maker API''' ===
  
Go to Apps, click Load New App
+
# From the Hubitat Web Interface select '''Apps'''[[File:Install Built-In App 2.0.png|none|thumb|600x600px]]
 
+
# Choose Maker API from the list of Hubitat Elevation<sup>®</sup> Built-In Apps.[[File:Install Maker API.png|none|thumb|600x600px]]
Select Hubitat Maker API
+
# You can enable Logging if you want to see detailed information in the [[logs]]. Remember to open up logs in another tab.[[File:Enable Logging Maker API.png|none|thumb|600x600px]]
 
+
# Select the devices you want to authorize for this API. '''NOTE''': Only the devices you select will be accessible via the endpoints.[[File:Maker API Select Devices.png|none|thumb|600x600px]]
Click Done.
+
# Select '''Update'''
 
+
# Next, you will see URLs to get you started. Each endpoint URL is made up of the following segments: http:// [hub ip address] /apps/api/[app id] /[endpoint path ?access_token=[access_token]
The App is now installed and you are back at the list of installed apps.
+
#* '''NOTE''': Your access token is an Authorization Token, similar to a username and password.  Anyone with this token can access these endpoints. To reset your access token, you will need to remove and re-add the Maker API app.[[File:Maker API endpoints.png|none|thumb|686x686px]]
 
+
# Press '''Done'''
Click on Hubitat Maker API in the list of Apps
 
 
 
You can enable logging if you want to see detailed information in the logs. Remember to open up logs in another tab.
 
 
 
Select the devices you want to authorize for this API. Only the devices you select will be accessible via the endpoints.
 
 
 
Next, you will see URLs to get you started.
 
 
 
Each endpoint url is made up of the following segments: http:// [hub ip address] /apps/api/[app id] /[endpoint path ?access_token=[access_token]
 
 
 
NOTE: Your access token is an authorization token, similar to a username and password.  Anyone with this token can access these endpoints. To reset your access token, you will need to remove and re-add Hubitat Maker API
 
 
 
To Get a list of all authorized devices:
 
  
 +
=== To Get a list of all authorized devices ===
 
'''/devices'''
 
'''/devices'''
  
Line 38: Line 26:
 
         "label": "Living Room Switch"
 
         "label": "Living Room Switch"
 
     }
 
     }
]</pre>'''/devices/all'''
+
]</pre>
 +
 
 +
'''/devices/all'''
  
 
This returns detailed information about each authorized device in JSON:<pre>[
 
This returns detailed information about each authorized device in JSON:<pre>[
Line 97: Line 87:
 
]</pre>This endpoint contains all the known information about the device, including capabilities, attributes and commands.
 
]</pre>This endpoint contains all the known information about the device, including capabilities, attributes and commands.
  
NOTE: there is a limited subset of allowed commands, so just because a command shows up in this list, does not mean it will work via the API.
+
* '''NOTE''': There is a limited subset of allowed commands, so just because a command shows up in this list, does not mean it will work via the API.
  
 
'''/devices/[device id]'''
 
'''/devices/[device id]'''
Line 105: Line 95:
 
'''/devices/[device id]/events'''
 
'''/devices/[device id]/events'''
  
returns a JSON object of recent events for that [device id]<pre>[
+
Returns a JSON object of recent events for that [device id]<pre>[
 
     {
 
     {
 
         "device_id": "1",
 
         "device_id": "1",
Line 115: Line 105:
 
         "source": "DEVICE"
 
         "source": "DEVICE"
 
     }
 
     }
]</pre>'''/devices/[device id]/commands'''
+
]</pre>
  
returns a JSON object of the commands for that [device id]<pre>
+
'''/devices/[device id]/commands'''
 +
 
 +
Returns a JSON object of the commands for that [device id]<pre>
 
[
 
[
 
     {
 
     {
Line 129: Line 121:
 
     }
 
     }
 
]
 
]
</pre>'''/devices/[device id]/[command]/[secondary value]'''
+
</pre>
 +
 
 +
'''/devices/[device id]/[command]/[secondary value]'''
  
 
This is the most powerful endpoint, as it can send a command to the authorized [device id] including an optional [secondary value]
 
This is the most powerful endpoint, as it can send a command to the authorized [device id] including an optional [secondary value]
  
Example, to turn on a light device 1
+
''Example'': To turn on a light '''device 1'''
  
 
'''/devices/1/on'''
 
'''/devices/1/on'''
  
Another Example, to set the level of a light to 50%
+
''Example 2'': To set the level of a light to 50%
  
 
'''/devices/1/setLevel/50'''
 
'''/devices/1/setLevel/50'''
  
 
You should get back a full detail response in JSON for that object.
 
You should get back a full detail response in JSON for that object.

Revision as of 23:25, 12 March 2020

This API is a simple HTTP GET API that allows you to get the status of your authorized devices and interact with them.

Installing Maker API

  1. From the Hubitat Web Interface select Apps
    Install Built-In App 2.0.png
  2. Choose Maker API from the list of Hubitat Elevation® Built-In Apps.
    Install Maker API.png
  3. You can enable Logging if you want to see detailed information in the logs. Remember to open up logs in another tab.
    Enable Logging Maker API.png
  4. Select the devices you want to authorize for this API. NOTE: Only the devices you select will be accessible via the endpoints.
    Maker API Select Devices.png
  5. Select Update
  6. Next, you will see URLs to get you started. Each endpoint URL is made up of the following segments: http:// [hub ip address] /apps/api/[app id] /[endpoint path ?access_token=[access_token]
    • NOTE: Your access token is an Authorization Token, similar to a username and password. Anyone with this token can access these endpoints. To reset your access token, you will need to remove and re-add the Maker API app.
      Maker API endpoints.png
  7. Press Done

To Get a list of all authorized devices

/devices

This returns the following JSON:

[
    {
        "id": "1",
        "name": "My First Device",
        "label": "Living Room Light"
    },
    {
        "id": "2",
        "name": "My Second Device",
        "label": "Living Room Switch"
    }
]

/devices/all

This returns detailed information about each authorized device in JSON:

[
    {
        "name": "My First Device",
        "label": "Living Room Light",
        "type": "Virtual Switch",
        "id": "1",
        "date": "2018-10-16T00:08:18+0000",
        "model": null,
        "manufacturer": null,
        "capabilities": [
            "Switch",
            "Refresh"
        ],
        "attributes": {
            "switch": "off"
        },
        "commands": [
            {
                "command": "off"
            },
            {
                "command": "on"
            },
            {
                "command": "refresh"
            }
        ]
    },
    {
        "name": "My Second Device",
        "label": "Living Room Switch",
        "type": "Virtual Switch",
        "id": "2",
        "date": "2018-01-03T02:49:57+0000",
        "model": null,
        "manufacturer": null,
        "capabilities": [
            "Switch",
            "Refresh"
        ],
        "attributes": {
            "switch": "on"
        },
        "commands": [
            {
                "command": "off"
            },
            {
                "command": "on"
            },
            {
                "command": "refresh"
            }
        ]
    }
]

This endpoint contains all the known information about the device, including capabilities, attributes and commands.

  • NOTE: There is a limited subset of allowed commands, so just because a command shows up in this list, does not mean it will work via the API.

/devices/[device id]

This endpoint returns back the same details as /devices/all but only for a specific device.

/devices/[device id]/events

Returns a JSON object of recent events for that [device id]

[
    {
        "device_id": "1",
        "label": "Living Room Light",
        "name": "My First Device",
        "value": "off",
        "date": "2018-10-16T00:08:18+0000",
        "isStateChange": null,
        "source": "DEVICE"
    }
]

/devices/[device id]/commands

Returns a JSON object of the commands for that [device id]

[
    {
        "command": "off"
    },
    {
        "command": "on"
    },
    {
        "command": "refresh"
    }
]

/devices/[device id]/[command]/[secondary value]

This is the most powerful endpoint, as it can send a command to the authorized [device id] including an optional [secondary value]

Example: To turn on a light device 1

/devices/1/on

Example 2: To set the level of a light to 50%

/devices/1/setLevel/50

You should get back a full detail response in JSON for that object.