# Fetch from other devices’ API

**URL:** <https://community.homey.app/t/fetch-from-other-devices-api/79840>\
**Category:** Developers\
**Tags:** app, homey-pro\
**Created:** [April 29, 2023, 9:56am UTC](https://community.homey.app/t/fetch-from-other-devices-api/79840 "2023-04-29T09:56:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![hordak](https://avatars.discourse-cdn.com/v4/letter/h/ecb155/32.png) [@hordak](https://community.homey.app/u/hordak)\
**Post date:** [April 29, 2023, 9:56am UTC](https://community.homey.app/t/fetch-from-other-devices-api/79840/1 "2023-04-29T09:56:39Z")

</div>

Hi,  
Trying to figure how interaction with other devices’ API is meant to be handled.

I have a device on lan with an API, from which I want to get data into my Homey app, but somehow I can’t get it right using a ordinary fetch in onInit.

fetch(“[http://ip-address/endpoint](http://ip-address/endpoint)”)  
.then((response) =\> {  
// Do something with response  
})  
.catch(function (err) {  
console.log(“Unable to fetch -”, err);  
});

Is the approach to fetch from Homey and store in a variable or do I have to put from other device to Homey, having enabled Homey API?

Any suggestion most appreciated

---

<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:** [April 29, 2023, 10:22am UTC](https://community.homey.app/t/fetch-from-other-devices-api/79840/2 "2023-04-29T10:22:48Z")

</div>

> [@hordak](#):
>
> but somehow I can’t get it right using a ordinary fetch in onInit.

That’s not enough information for others to help you.

---

<div class="post-metadata">

**Author:** ![hordak](https://avatars.discourse-cdn.com/v4/letter/h/ecb155/32.png) [@hordak](https://community.homey.app/u/hordak)\
**Post date:** [May 1, 2023, 12:18pm UTC](https://community.homey.app/t/fetch-from-other-devices-api/79840/3 "2023-05-01T12:18:18Z")

</div>

Sorry for being unprecise,  
Searching the docs for how to read from another devices’ API, but could only find information regarding Homey API, hence my question if I had to enable HomeyAPI and put from my rPi (tried to make a request using fetch without luck). Some trial and error led me back on track though, using require node-fetch (which I assumed was already loaded from start and that I could use same syntax as in HomeyScript).

Well, problem solved, and to answer my own question:  
No, you don’t have to use HomeyAPI, you can fetch from another devices’ API using node-fetch module.

---

<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:** [May 1, 2023, 12:38pm UTC](https://community.homey.app/t/fetch-from-other-devices-api/79840/4 "2023-05-01T12:38:00Z")

</div>

> [@hordak](#):
>
> No, you don’t have to use HomeyAPI, you can fetch from another devices’ API using node-fetch module.

I assume that your goal is to access information for devices from other apps? If so, you should use [`homey-api`](https://www.npmjs.com/package/homey-api/v/3.0.0-rc.19), which can be used from an app directly (no need for Raspberry Pi’s or anything like that).

---

<div class="post-metadata">

**Author:** ![hordak](https://avatars.discourse-cdn.com/v4/letter/h/ecb155/32.png) [@hordak](https://community.homey.app/u/hordak)\
**Post date:** [May 2, 2023, 5:55am UTC](https://community.homey.app/t/fetch-from-other-devices-api/79840/5 "2023-05-02T05:55:00Z")

</div>

Hello, thanks for your reply.  
I have the Pi connected to the modbus interface on my energy recovering ventilation unit. In the Pi, I have created an API for the ventilation unit and up til now, I can control it with a simple web app on LAN. It would be neat to add it to Homey though, to interact with temp sensors, heat pump etc. I realize that I probably won’t get the app published because of the Pi’s custom requirements (could post the API code on git and make it available, but it’s still have a rather specific use case) 🙂

---

<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:** [May 2, 2023, 5:57am UTC](https://community.homey.app/t/fetch-from-other-devices-api/79840/6 "2023-05-02T05:57:47Z")

</div>

HomeyAPI is only meant to control devices _on your Homey_, to access external API’s you can indeed use `fetch`.
