# \[Unsupported\] Homey v2 REST API

**URL:** <https://community.homey.app/t/unsupported-homey-v2-rest-api/7268>\
**Category:** Developers\
**Created:** [January 18, 2019, 3:07pm UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268 "2019-01-18T15:07:04Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![lesterchan](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/lesterchan/32/51_2.png) [@lesterchan](https://community.homey.app/u/lesterchan)\
**Post date:** [January 18, 2019, 3:07pm UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/1 "2019-01-18T15:07:04Z")

</div>

I am not sure whether this topic is allowed. But I thought I share my findings for the v2 API. I have personal use cases for directly calling the API through iOS shortcuts.

In v2, the on and off REST API path has changed to `/capability/onoff` from `/state`.

So now to switch on:  
`PUT { "value": true } TO http://<HOMEY_IP>/api/manager/devices/device/<DEVICE_ID>/capability/onoff`

and to switch off:  
`PUT { "value": false } TO http://<HOMEY_IP>/api/manager/devices/device/<DEVICE_ID>/capability/onoff`

Other than that, the rest of the APIs path rename the same  
`GET http://<HOMEY_IP>/api/manager/devices/device`  
`GET http://<HOMEY_IP>/api/manager/devices/device/<DEVICE_ID>`  
`GET http://<HOMEY_IP>/api/manager/devices/device/<DEVICE_ID>`  
`GET http://<HOMEY_IP>/api/manager/insights/log/homey:device:<DEVICE_ID>/measure_temperature/entry`

To get the token needed to do call the API, see my reply below [[Unsupported] Homey v2 REST API](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/6?u=lesterchan)

---

<div class="post-metadata">

**Author:** ![Slof](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/slof/32/1318_2.png) [@Slof](https://community.homey.app/u/Slof)\
**Post date:** [January 18, 2019, 3:33pm UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/2 "2019-01-18T15:33:22Z")

</div>

Nice thanks

---

<div class="post-metadata">

**Author:** ![Jamie](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jamie/32/5274_2.png) [@Jamie](https://community.homey.app/u/Jamie)\
**Post date:** [January 18, 2019, 4:01pm UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/3 "2019-01-18T16:01:22Z")

</div>

From previous forums (no idea if they still work):

> **[Rest API - Page 2](https://forum.athom.com/discussion/1192/rest-api/p2)**
>
> Anyone who knows the rest calls for the following? get better logic variable values. set better logic variable values.

```auto
# Get all zones
GET http://<HOMEY_IP>/api/manager/zones/

# Get all devices 
GET http://<HOMEY_IP>/api/manager/devices/

# Get all devices within a zone:
GET http://<HOMEY_IP>/api/manager/devices/?zone=01234567-89ab-cdef-0123-456789abcdef

# Get Device
GET http://<HOMEY_IP>//api/manager/device/01234567-89ab-cdef-0123-456789abcdef

```

From Candy

```auto
function updateFlowEnabled (flowId, enabled) {
  return api('put', `/manager/flow/flow/${flowId}/enabled`, {enabled})
  return api('put', '/manager/flow/flow/' + flowId, {enabled})
}

```

> **[Rest API - Page 2](https://forum.athom.com/discussion/1192/rest-api/p2)**
>
> Anyone who knows the rest calls for the following? get better logic variable values. set better logic variable values.

```auto
A few examples:

Get data
GET http://<HomeyIP>/api/manager/geolocation/ (read location)
GET http://<HomeyIP>/api/manager/devices/device/ (read all devices)
GET http://<HomeyIP>/api/manager/devices/device/<device_id>/ (read device by id)
GET http://<HomeyIP>/api/manager/flow/flow/ (read all flows)
GET http://<HomeyIP>/api/manager/flow/flow/<flow_id>/ (read all flow by id)

Set data
PUT http://<HomeyIP>/api/manager/devices/device/<device_id>/state/
(update capability of a device via json body, e.g. {'target_temperature': 20} triggers an thermostat to temperature of 20°, {'onoff': 1} switches a plug / switch 'on', etc). 

```

Im guesing : `http://<HomeyIP>/api/manager/devices/device/<device_id>/capability/target_temperature`

Speech :

```auto
http://YOUR-HOMEY-IP/api/manager/speech-output/

```

---

<div class="post-metadata">

**Author:** ![Jeroen\_Somhorst](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jeroen_somhorst/32/184_2.png) [@Jeroen\_Somhorst](https://community.homey.app/u/Jeroen_Somhorst)\
**Post date:** [January 18, 2019, 4:08pm UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/4 "2019-01-18T16:08:26Z")

</div>

the main question is… how are you authenticating?

---

<div class="post-metadata">

**Author:** ![Erik](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/erik/32/9865_2.png) [@Erik](https://community.homey.app/u/Erik)\
**Post date:** [January 18, 2019, 10:19pm UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/5 "2019-01-18T22:19:23Z")

</div>

These keys can be used for local dev:  
[https://developer.athom.com/api/projects](https://developer.athom.com/api/projects)

API docs are documented for most parts: [https://developer.athom.com/docs/api/HomeyAPI.ManagerDevices.html](https://developer.athom.com/docs/api/HomeyAPI.ManagerDevices.html)

---

<div class="post-metadata">

**Author:** ![lesterchan](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/lesterchan/32/51_2.png) [@lesterchan](https://community.homey.app/u/lesterchan)\
**Post date:** [January 19, 2019, 12:11pm UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/6 "2019-01-19T12:11:59Z")

</div>

To get the token to do auth authenticated, go to [https://developer.athom.com/](https://developer.athom.com/) and login.

After logging in, open up developer console and go to the network tab.

Look for the URL that ends with `/sessions/session/me`. Click on it and on the right should appear another panel showing the header response.

Under request headers, look for the key `authorization` and what you need is the token starting after `Bearer`

 ![Untitled-1](https://us1.discourse-cdn.com/flex025/uploads/athom/original/2X/a/a9d6bf897cddbed3f622cce715d3c7570c945eaf.jpeg)

In v2, the token changed. Used to be just `<HASH>`, now it is `<UUID>:<UUID>:<HASH>` which makes it much longer.

With that, you can do a call like

```auto
curl -H "Authorization: Bearer <TOKEN>" http://<HOMEY_IP>/api/manager/devices/device

```

And you should get back a list of your devices

---

<div class="post-metadata">

**Author:** ![Magnus\_Johansson](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/magnus_johansson/32/12555_2.png) [@Magnus\_Johansson](https://community.homey.app/u/Magnus_Johansson)\
**Post date:** [January 19, 2019, 1:17pm UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/7 "2019-01-19T13:17:07Z")

</div>

I have a problem

curl -H "Authorization: Bearer " http://\<HOMEY\_IP\>/api/manager/devices/

with token and ip added I get:

{“code”:404,“error”:“not\_found”,“error\_description”:“Not found: GET /api/manager/devices/”}

I’m cannot solve the problem

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [January 19, 2019, 1:20pm UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/8 "2019-01-19T13:20:03Z")

</div>

Did you try any of the other URL’s that @Jamie mentioned in [this comment](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/3)?

---

<div class="post-metadata">

**Author:** ![dhanjel](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dhanjel/32/10878_2.png) [@dhanjel](https://community.homey.app/u/dhanjel)\
**Post date:** [January 19, 2019, 1:24pm UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/9 "2019-01-19T13:24:27Z")

</div>

> [@lesterchan](#):
>
> http://\<HOMEY\_IP\>/api/manager/devices/

Try with: /api/manager/devices/device/

---

<div class="post-metadata">

**Author:** ![Magnus\_Johansson](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/magnus_johansson/32/12555_2.png) [@Magnus\_Johansson](https://community.homey.app/u/Magnus_Johansson)\
**Post date:** [January 19, 2019, 1:27pm UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/10 "2019-01-19T13:27:01Z")

</div>

/api/manager/devices/device/

gave me a slightly different response

{“code”:401,“error”:“invalid\_session”,“error\_description”:“An unkown error has occured [invalid\_session]”}

---

<div class="post-metadata">

**Author:** ![dhanjel](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dhanjel/32/10878_2.png) [@dhanjel](https://community.homey.app/u/dhanjel)\
**Post date:** [January 19, 2019, 1:34pm UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/11 "2019-01-19T13:34:28Z")

</div>

That worked for me, just did a quick test in c# though.

public async Task GetDevicesAsync()  
{  
using (var client = GetClient())  
{  
var response = await client.GetStringAsync($“http://{homeyIp}/api/manager/devices/device/”).ConfigureAwait(true);  
var result = JArray.Parse(response);  
}  
}

```
    private static HttpClient GetClient()
    {
        var client = new HttpClient();
        client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", bearerToken);
        return client;
    }
```

---

<div class="post-metadata">

**Author:** ![Magnus\_Johansson](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/magnus_johansson/32/12555_2.png) [@Magnus\_Johansson](https://community.homey.app/u/Magnus_Johansson)\
**Post date:** [January 19, 2019, 2:02pm UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/12 "2019-01-19T14:02:17Z")

</div>

Thanks for quick response. However, I still get the same problem. Tried on two different computers

---

<div class="post-metadata">

**Author:** ![dhanjel](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dhanjel/32/10878_2.png) [@dhanjel](https://community.homey.app/u/dhanjel)\
**Post date:** [January 19, 2019, 2:02pm UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/13 "2019-01-19T14:02:56Z")

</div>

Are you using the correct bearer token? xxx:xxx:xxx

---

<div class="post-metadata">

**Author:** ![Jeroen\_Somhorst](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jeroen_somhorst/32/184_2.png) [@Jeroen\_Somhorst](https://community.homey.app/u/Jeroen_Somhorst)\
**Post date:** [January 19, 2019, 2:03pm UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/14 "2019-01-19T14:03:17Z")

</div>

So infact the information in this topic could be used to create a web ui? 😈

---

<div class="post-metadata">

**Author:** ![lesterchan](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/lesterchan/32/51_2.png) [@lesterchan](https://community.homey.app/u/lesterchan)\
**Post date:** [January 19, 2019, 2:37pm UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/15 "2019-01-19T14:37:37Z")

</div>

Share your code?

---

<div class="post-metadata">

**Author:** ![Magnus\_Johansson](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/magnus_johansson/32/12555_2.png) [@Magnus\_Johansson](https://community.homey.app/u/Magnus_Johansson)\
**Post date:** [January 19, 2019, 5:33pm UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/16 "2019-01-19T17:33:44Z")

</div>

The code is just a one liner

curl -H “Authorization: Bearer 80c58bxxxxxxxxxxxxxxxxxxxxxxxxxeb93ae449” [http://192.168.1](http://192.168.1)  
.20/api/manager/devices/device/

---

<div class="post-metadata">

**Author:** ![lesterchan](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/lesterchan/32/51_2.png) [@lesterchan](https://community.homey.app/u/lesterchan)\
**Post date:** [January 19, 2019, 6:04pm UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/17 "2019-01-19T18:04:39Z")

</div>

Your Bearer token seems to be the old v1.5 rather than v2

---

<div class="post-metadata">

**Author:** ![Magnus\_Johansson](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/magnus_johansson/32/12555_2.png) [@Magnus\_Johansson](https://community.homey.app/u/Magnus_Johansson)\
**Post date:** [January 20, 2019, 6:05am UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/18 "2019-01-20T06:05:28Z")

</div>

Thanks, lesterchan  
My Homey version is 2.0.0 according to the Homey app. The bearer token is one continuous number.

---

<div class="post-metadata">

**Author:** ![lesterchan](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/lesterchan/32/51_2.png) [@lesterchan](https://community.homey.app/u/lesterchan)\
**Post date:** [January 20, 2019, 6:24am UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/19 "2019-01-20T06:24:49Z")

</div>

Does it have any colon? There should be two colons separating three values. If you see one continuous string of chars without any colon or dash, it is the old v1.5 token.

---

<div class="post-metadata">

**Author:** ![Magnus\_Johansson](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/magnus_johansson/32/12555_2.png) [@Magnus\_Johansson](https://community.homey.app/u/Magnus_Johansson)\
**Post date:** [January 20, 2019, 6:29am UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/20 "2019-01-20T06:29:13Z")

</div>

It hasn’t any colon and it is probably a v1.5 bearer. So then the question is, how can i generate a v2.0 one?

[Next page](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268.md?page=2)
