# \[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:** 2

<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:36am UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/21 "2019-01-20T06:36:37Z")

</div>

Solved  
The error was on my side. I’ve got one Homey but two Homeys registered on my account. When I selected the active one and looked for the bearer I got the correct one.

---

<div class="post-metadata">

**Author:** ![Phuturist](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/phuturist/32/49_2.png) [@Phuturist](https://community.homey.app/u/Phuturist)\
**Post date:** [February 4, 2019, 6:28pm UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/22 "2019-02-04T18:28:12Z")

</div>

Anyone already figured out of it’s possible to read and/or update variables from the Logic functionality?

---

<div class="post-metadata">

**Author:** ![TimTim](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/timtim/32/4675_2.png) [@TimTim](https://community.homey.app/u/TimTim)\
**Post date:** [February 5, 2019, 9:37am UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/23 "2019-02-05T09:37:31Z")

</div>

Did you check out [https://developer.athom.com/docs/api/HomeyAPI.ManagerLogic.html](https://developer.athom.com/docs/api/HomeyAPI.ManagerLogic.html)?

---

<div class="post-metadata">

**Author:** ![Phuturist](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/phuturist/32/49_2.png) [@Phuturist](https://community.homey.app/u/Phuturist)\
**Post date:** [February 5, 2019, 10:07pm UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/24 "2019-02-05T22:07:28Z")

</div>

> [@Jamie](#):
>
> Im guesing : http:///api/manager/devices/device/\<device\_id\>/capability/target\_temperature

I’m trying to get the measure\_temperature value from a sensor. I would figure it would be indeed something like this:

`GET: http://<HomeyIP>/api/manager/devices/device/<device_id>/capability/measure_temperature`

Unfortunately this does not work, anyone any idea how to do this?

[EDIT]  
It looks like there is no getCapabilityValue method under the device class. You will need to get it from the result of the device itself which holds a capabilities object.

---

<div class="post-metadata">

**Author:** ![Robin\_van\_Kekem](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robin_van_kekem/32/8187_2.png) [@Robin\_van\_Kekem](https://community.homey.app/u/Robin_van_Kekem)\
**Post date:** [February 15, 2019, 6:14am UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/25 "2019-02-15T06:14:36Z")

</div>

Anyone an idea as to why there isn’t any official REST API?  
There used to be one on V1 so I don’t understand why there isn’t any on V2…

---

<div class="post-metadata">

**Author:** ![Marlon](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marlon/32/3794_2.png) [@Marlon](https://community.homey.app/u/Marlon)\
**Post date:** [February 16, 2019, 3:30pm UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/26 "2019-02-16T15:30:38Z")

</div>

You could parse the output of the api call **https://\<HomeyIP\>/api/manager/devices/device/\<device\_id\>** for “capabilitiesObj/measure\_temperature/value”

I don’t know if you already looked into it?

```
    "capabilitiesObj": {
      "measure_temperature": {
        "value": 17.1,
        "lastUpdated": "2019-02-16T14:06:48.855Z",
        "type": "number",
        "getable": true,
        "setable": false,
        "title": "Temperature",
        "desc": null,
        "units": "°C",
        "decimals": 2,
        "chartType": "spline",
        "id": "measure_temperature",
        "options": {}
      }
```

---

<div class="post-metadata">

**Author:** ![Phuturist](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/phuturist/32/49_2.png) [@Phuturist](https://community.homey.app/u/Phuturist)\
**Post date:** [February 16, 2019, 3:34pm UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/27 "2019-02-16T15:34:09Z")

</div>

> [@Marlon](#):
>
> I don’t know if you already looked into it?

Yes, but thanx anyway.

---

<div class="post-metadata">

**Author:** ![Marlon](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marlon/32/3794_2.png) [@Marlon](https://community.homey.app/u/Marlon)\
**Post date:** [February 18, 2019, 9:37am UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/28 "2019-02-18T09:37:43Z")

</div>

I have two entries for the API list

Lists all apps:  
`https://<HOMEY_IP>/api/manager/apps/app`

Get single app:  
`https://<HOMEY_IP>/api/manager/apps/app/<APP_ID>`  
example: https://\<HOMEY\_IP\>/api/manager/apps/app/nl.nefit.easy

---

<div class="post-metadata">

**Author:** ![johan\_bendz](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/johan_bendz/32/10344_2.png) [@johan\_bendz](https://community.homey.app/u/johan_bendz)\
**Post date:** [February 28, 2019, 10:18pm UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/29 "2019-02-28T22:18:12Z")

</div>

I put together a document on github with all the Endpoints I could find.

Feel free to create an issue with info if you know of any other endpoints or if something is wrong in the document.

> <https://github.com/JohanBendz/Homey-Endpoints/blob/master/Homey-REST-endpoints>

---

<div class="post-metadata">

**Author:** ![Niels](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/niels/32/89_2.png) [@Niels](https://community.homey.app/u/Niels)\
**Post date:** [May 19, 2019, 12:03pm UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/30 "2019-05-19T12:03:22Z")

</div>

I have no idea how to authenticate local, Using the homey.ink procedure i was able to authenticate on cloud and use all the API’s. As i had trouble finding the needed info here, here is my contribution. Hope this is helpful to someone.

**Getting a unlimited key**  
First step is to get a token that is reusable (longer then 24 Hours), because the API bearer token is only usable for 24 hours and we don’t want to change our code every 24 hours. homey.ink is our solution as it generates a key without an expiration date.

Here we go:

 ![HomeyApi1](https://us1.discourse-cdn.com/flex025/uploads/athom/original/2X/6/64cf183eb12c8115d17cc5689a0a407988fcbbaa.png)

Step 1: Go to [https://homey.ink](https://homey.ink) using google chrome.

Step 2: Right click on the page and select inspect(inspecteren) or use Ctrl + Shift + I

Step 3: Select the Network Tab (this will show the network traffic after the authentication is done)

Step 4: Use the “Log In” button and follow the authentication steps.

Step 5: Use the scrollbar if needed, (If you followed this step by step you’ll probably only see one item)

Step 6: select the item named “token, [api.athom.com/oauth2](http://api.athom.com/oauth2)”

Step 7: In the headers view scroll down to Form Data, and select the “view source” button.

Step 8: below the “View Source” button the needed key will be shown. Copy it . We’ll need it for the API authentication. it will look something like this:

client\_id=09ab2b247cdff0918abfd00d&client\_secret=l159fjann0173h2jllsppehg2vj4l28dhhakl3010&grant\_type=authorization\_code&code=09ab2b247cdff0918abfd00d47cdff0918a2b2414

P.S. This is just an example. your key will look a bit different.

now send the following  
POST [https://api.athom.com/oauth2/token](https://api.athom.com/oauth2/token)  
_Headers:_  
Content-Type: application/x-www-form-urlencoded  
_Body_  
client\_id=09ab2b247cdff0918abfd00d&client\_secret=l159fjann0173h2jllsppehg2vj4l28dhhakl3010&grant\_type=authorization\_code&code=09ab2b247cdff0918abfd00d47cdff0918a2b2414

The response will include a refresh token.

To build the “unlimited” key, use the first part of the key, like:

- client\_id=09ab2b247cdff0918abfd00d&client\_secret=l159fjann0173h2jllsppehg2vj4l28dhhakl3010&grant\_type=

- Add: _refresh\_token&refresh\_token=_

- and then add the refresh\_token (gotten from the authentication above)

The result will look like this:

_client\_id=09ab2b247cdff0918abfd00d&client\_secret=l159fjann0173h2jllsppehg2vj4l28dhhakl3010&grant\_type=refresh\_token&refresh\_token=09ab2b247cdff0918abfd00d47cdff0918a2b2414_

This key can be reused in your code to re authenticate yourself every 24 hours without the need to open your brouwer and the former steps.

**Getting the bearer token**  
With the key we got above we can now programmatically get a bearer token.  
There are a couple of steps needed to get it, the bearer token is valid for 24 Hours. after 24 Hours you will need to get a new bearer token.

**Step 1:**  
use the **KEY** you’ve got from **Getting a unlimited key** as body.

POST [https://api.athom.com/oauth2/token](https://api.athom.com/oauth2/token)  
_Headers:_  
Content-Type: application/x-www-form-urlencoded  
_Body_  
**KEY**

Result: will be a Json formatted output. we’ll need the “access\_token” value.

**Optional Step:**  
With this request you can get all kind of interesting data, i.e. cloud ID’s and users.  
Use the **ACCESS\_TOKEN** gotten in step 1.

GET [https://api.athom.com/user/me](https://api.athom.com/user/me)  
_Headers:_  
Authorization: **ACCESS\_TOKEN**

**Step 2:**  
Use the **ACCESS\_TOKEN** gotten in step 1.

POST [https://api.athom.com/delegation/token?audience=homey](https://api.athom.com/delegation/token?audience=homey)  
_Headers:_  
Authorization: **ACCESS\_TOKEN**

Result: A JWT formated token.

**Step 3:**  
Use the **JWT\_TOKEN** gotten in step 2.  
Use the **CLOUD\_ID** for your homey, this can also be found in the Optional Step.

POST https:// **CLOUD\_ID**.connect.athom.com/api/manager/users/login  
_Headers:_  
Content-Type: application/json  
_Body:_  
{“token”:“ **JWT\_TOKEN** ”}

Result: the bearer token that can be used in all API’s

**API Test Step**  
Use the **BEARER-TOKEN** gotten in step 3  
Use the **CLOUD\_ID** for your homey, this can also be found in the Optional Step.

GET https:// **CLOUD\_ID**.connect.athom.com/api/manager/devices/device/.  
_Headers:_  
Authorization: **BEARER-TOKEN**

---

<div class="post-metadata">

**Author:** ![Rom](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rom/32/11038_2.png) [@Rom](https://community.homey.app/u/Rom)\
**Post date:** [May 22, 2019, 11:31am UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/31 "2019-05-22T11:31:51Z")

</div>

Niels I tried your solution but it is not working. The code parameter I get for oauth2 from the unlimited key (client\_id=09ab2b247cdff0918abfd00d&client\_secret=l159fjann0173h2jllsppehg2vj4l28dhhakl3010&grant\_type=authorization\_code& **code=09ab2b247cdff0918abfd00d47cdff0918a2b2414** )  
is only valid for 30 seconds. Did I miss something here?

---

<div class="post-metadata">

**Author:** ![Niels](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/niels/32/89_2.png) [@Niels](https://community.homey.app/u/Niels)\
**Post date:** [May 22, 2019, 12:35pm UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/32 "2019-05-22T12:35:11Z")

</div>

Hi Rob, welcome to the community. The key that I got from the oauth2 is still valid since I’ve posted. I just started the QT IDE (where I’m trying to develop a embedded system) when running my code it still fully authenticates.

Could you show what’s going on? Don’t show/share your keys.

---

<div class="post-metadata">

**Author:** ![Rom](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rom/32/11038_2.png) [@Rom](https://community.homey.app/u/Rom)\
**Post date:** [May 22, 2019, 1:45pm UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/33 "2019-05-22T13:45:12Z")

</div>

Hi Niels  
Thank you for your fast response.  
I get this when I issue the request:  
{  
“code”: 400,  
“error”: “invalid\_grant”,  
“error\_description”: “Invalid code”  
}  
When I go to homey.ink. Login again I get a new code. When I fill this in, I get the access token as a response. When I do the same again with the same code after about 30 seconds I get the response as above.

---

<div class="post-metadata">

**Author:** ![Niels](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/niels/32/89_2.png) [@Niels](https://community.homey.app/u/Niels)\
**Post date:** [May 22, 2019, 2:15pm UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/34 "2019-05-22T14:15:42Z")

</div>

Ill do some investigations to see if i get the same issue if i generatie a new key. Weird.

---

<div class="post-metadata">

**Author:** ![Rom](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rom/32/11038_2.png) [@Rom](https://community.homey.app/u/Rom)\
**Post date:** [May 22, 2019, 2:58pm UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/35 "2019-05-22T14:58:43Z")

</div>

I also tried it using Postman with the same results.

---

<div class="post-metadata">

**Author:** ![Niels](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/niels/32/89_2.png) [@Niels](https://community.homey.app/u/Niels)\
**Post date:** [May 22, 2019, 3:03pm UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/36 "2019-05-22T15:03:40Z")

</div>

I found the issue but not yet the cause.

In my working key i have “grant\_type=refresh\_token&refresh\_token=”  
Now when i follow my own guide i get a key with “grant\_type=authorization\_code&code=”

Now i’m not so sure how i obtained the key the way i described or if homey had made a change.

I find that authenticating with the key, then use the refresh token in another call will work.  
then keep the refresh token to re-authenticate every 24 hours. I’ll update my instructions.

---

<div class="post-metadata">

**Author:** ![Niels](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/niels/32/89_2.png) [@Niels](https://community.homey.app/u/Niels)\
**Post date:** [May 22, 2019, 3:17pm UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/37 "2019-05-22T15:17:53Z")

</div>

I’m also using postman. this way it’s automatically documented, but not how i got to the first step unfortunately. anyway i’ve just updated my instructions. added an extra step and that seems to work. hopefully it stays working like the key i use in my code.

---

<div class="post-metadata">

**Author:** ![Rom](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rom/32/11038_2.png) [@Rom](https://community.homey.app/u/Rom)\
**Post date:** [May 22, 2019, 9:31pm UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/38 "2019-05-22T21:31:24Z")

</div>

Thank you very much for your help. This is working now. Now I am finaly able to finish my dashboard for the homey. Still two steps away from fully migrating from Vera Edge to Homey. Every time it gets better. One I am able to do myself (an app for Benext devices, the old one stopped working). For the other one I will have to wait for Athom to fullfill their promise to include a full backup.

---

<div class="post-metadata">

**Author:** ![TTXy](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ttxy/32/11223_2.png) [@TTXy](https://community.homey.app/u/TTXy)\
**Post date:** [May 23, 2019, 11:18am UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/39 "2019-05-23T11:18:37Z")

</div>

Hello,

I have tried the guidelines over, but it does not work for me… I only get Error code 400:

```
"code": 400,
"error": "invalid_request",
"error_description": "Invalid or missing grant_type parameter"

```

I have tried with both curl, PowerShell and Postman…

If this is working for others, I must be doing something wrong… would it be possible to get some screenshot of Postman or commands for cURL… So I know I am posting the right request…

---

<div class="post-metadata">

**Author:** ![Niels](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/niels/32/89_2.png) [@Niels](https://community.homey.app/u/Niels)\
**Post date:** [May 23, 2019, 3:55pm UTC](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/40 "2019-05-23T15:55:41Z")

</div>

On what request do you get this error. Can you share the packet send, obscure your keys, then I can see what’s going wrong.

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

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