# Web API

**URL:** <https://community.homey.app/t/web-api/2252>\
**Category:** Developers\
**Created:** [September 29, 2018, 4:18pm UTC](https://community.homey.app/t/web-api/2252 "2018-09-29T16:18:32Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mikael\_Guss](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/mikael_guss/32/3607_2.png) [@Mikael\_Guss](https://community.homey.app/u/Mikael_Guss)\
**Post date:** [September 29, 2018, 4:18pm UTC](https://community.homey.app/t/web-api/2252/1 "2018-09-29T16:18:32Z")

</div>

Is it someone who can make a simple Web-api that trigger a flow and show me the code?  
And Yes, a have read the documentation but need some “hello word” code to start with and i want to trigger a flow from Wab-api.

Please Micke

---

<div class="post-metadata">

**Author:** ![Dijker](https://avatars.discourse-cdn.com/v4/letter/d/b9bd4f/32.png) [@Dijker](https://community.homey.app/u/Dijker)\
**Post date:** [September 29, 2018, 6:16pm UTC](https://community.homey.app/t/web-api/2252/2 "2018-09-29T18:16:15Z")

</div>

Triggers are usually triggered from within Homey,  
It uses the arguments like changed temperature, wind, state or even Who came home as tokens in the flow.

but the ‘This Flow is started’ card can be triggerd from the Web Api.  
fe. Homeyscript uses the Web API and this script triggers the flow with the mentioned id.  
`let result = await Homey.flow.triggerProgrammaticFlow({ id: '3c80f61d-e511-4e10-a4d7-e9d7b6b601be' })`  
`console.log (result)`

if it returns `true` it worked.

---

<div class="post-metadata">

**Author:** ![Mikael\_Guss](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/mikael_guss/32/3607_2.png) [@Mikael\_Guss](https://community.homey.app/u/Mikael_Guss)\
**Post date:** [September 29, 2018, 9:32pm UTC](https://community.homey.app/t/web-api/2252/3 "2018-09-29T21:32:46Z")

</div>

Great. Thanks. Is it any way to trigger script website thru web-api.

---

<div class="post-metadata">

**Author:** ![Dijker](https://avatars.discourse-cdn.com/v4/letter/d/b9bd4f/32.png) [@Dijker](https://community.homey.app/u/Dijker)\
**Post date:** [September 30, 2018, 7:04am UTC](https://community.homey.app/t/web-api/2252/4 "2018-09-30T07:04:49Z")

</div>

Have you looked at [https://apps.athom.com/app/com.internet](https://apps.athom.com/app/com.internet) ?  
Does it provide what you want?

---

<div class="post-metadata">

**Author:** ![Mikael\_Guss](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/mikael_guss/32/3607_2.png) [@Mikael\_Guss](https://community.homey.app/u/Mikael_Guss)\
**Post date:** [September 30, 2018, 7:58am UTC](https://community.homey.app/t/web-api/2252/5 "2018-09-30T07:58:25Z")

</div>

Yes. Exacly. I have try it and its great but i want to access my flows directly not thru a app.

---

<div class="post-metadata">

**Author:** ![CitizenxNZ](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/citizenxnz/32/13176_2.png) [@CitizenxNZ](https://community.homey.app/u/CitizenxNZ)\
**Post date:** [October 1, 2018, 5:29am UTC](https://community.homey.app/t/web-api/2252/6 "2018-10-01T05:29:35Z")

</div>

I agree! I would love to trigger a flow without needing to set up an additional flow that uses a http request

---

<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:** [October 1, 2018, 9:46am UTC](https://community.homey.app/t/web-api/2252/7 "2018-10-01T09:46:42Z")

</div>

I asked about the REST API, apparently its been completely forgotten and "why you would want to use REST’ when we have a JS api.

I was a little dumb founded.

---

<div class="post-metadata">

**Author:** ![Mikael\_Guss](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/mikael_guss/32/3607_2.png) [@Mikael\_Guss](https://community.homey.app/u/Mikael_Guss)\
**Post date:** [October 5, 2018, 9:16pm UTC](https://community.homey.app/t/web-api/2252/8 "2018-10-05T21:16:05Z")

</div>

So. is there a way to trigger a flow externally via web-api? Think that ex. As you Jamie write, Rest is possible the easiest way. Is there anyone out there who knows how to do with the Web-api?

---

<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:** [October 6, 2018, 5:29am UTC](https://community.homey.app/t/web-api/2252/9 "2018-10-06T05:29:45Z")

</div>

I cobbled this up: [https://github.com/robertklep/homey-web-api-example](https://github.com/robertklep/homey-web-api-example)

Since it’s not possible to get custom OAuth2 client credentials (🔜), I’ve borrowed the ones that belong to `athom-cli`. The token is being read from its configuration file, so you need to have a properly configured `athom-cli` before you can use the test code.

Even though [the documentation](https://developer.athom.com/docs/api/HomeyAPI.ManagerFlow.html#triggerFlow) states that there is a `triggerFlow()` method, there isn’t (perhaps it exists in the latest version of `athom-api`, 2.0.133, but that version doesn’t work properly). Instead, I used `testFlow`.

---

<div class="post-metadata">

**Author:** ![Chris\_Peters](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/chris_peters/32/1851_2.png) [@Chris\_Peters](https://community.homey.app/u/Chris_Peters)\
**Post date:** [November 27, 2018, 1:47pm UTC](https://community.homey.app/t/web-api/2252/10 "2018-11-27T13:47:50Z")

</div>

Nice examplw, what I have problems with is understanding how to deploy this on Homey. I have looked at various parts of the documentation but haven’t found anything that helps me with this. Did I miss something?

---

<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:** [November 27, 2018, 2:06pm UTC](https://community.homey.app/t/web-api/2252/11 "2018-11-27T14:06:44Z")

</div>

Do you mean you want to run this code as part of a Homey app, so it runs on Homey itself? Because that’s not what this code is meant for.

For Homey apps, it’s relatively easy to access the Web API from within the app itself, although it does require that the app has the correct permissions.

---

<div class="post-metadata">

**Author:** ![Chris\_Peters](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/chris_peters/32/1851_2.png) [@Chris\_Peters](https://community.homey.app/u/Chris_Peters)\
**Post date:** [November 27, 2018, 2:09pm UTC](https://community.homey.app/t/web-api/2252/12 "2018-11-27T14:09:55Z")

</div>

My intention is that the code runs on a seperate computer or tablet

Chris

---

<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:** [November 27, 2018, 2:34pm UTC](https://community.homey.app/t/web-api/2252/13 "2018-11-27T14:34:29Z")

</div>

Ah okay, in that case it should (theoretically) work. However, I just checked and it looks like something has changed, so it’s crashing now due to missing tokens. I’ll try and see if I can work out why.

---

<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:** [November 27, 2018, 5:45pm UTC](https://community.homey.app/t/web-api/2252/14 "2018-11-27T17:45:53Z")

</div>

I’ve updated the repository, added a dirty hack that abuses `athom-cli` to handle the authentication.
