# API request with headers

**URL:** <https://community.homey.app/t/api-request-with-headers/65677>\
**Category:** Developers\
**Created:** [July 7, 2022, 5:44pm UTC](https://community.homey.app/t/api-request-with-headers/65677 "2022-07-07T17:44:01Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![LauraLuc](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/lauraluc/32/18240_2.png) [@LauraLuc](https://community.homey.app/u/LauraLuc)\
**Post date:** [July 7, 2022, 5:44pm UTC](https://community.homey.app/t/api-request-with-headers/65677/1 "2022-07-07T17:44:01Z")

</div>

I need to add an API key to my request but it returns an error. Do you know why I can’t use Headers?

```auto
var url = "https://api.iopool.com/v1/pools";
var headers = new Headers();

headers.append('x-api-key', 'myKey);

fetch(url, headers)
  .then(response => response.json())
  .then(data => console.log(data));

```

❌ Script Error  
⚠ ReferenceError: Headers is not defined  
at API Iopool.js:2:15  
at processTicksAndRejections (node:internal/process/task\_queues:96:5)

---

<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:** [July 7, 2022, 6:00pm UTC](https://community.homey.app/t/api-request-with-headers/65677/2 "2022-07-07T18:00:54Z")

</div>

```auto
fetch(url, {
  headers : {
    'x-api-key': myKey
  }
)

```

See last example [here](https://developer.mozilla.org/en-US/docs/Web/API/fetch#examples).

---

<div class="post-metadata">

**Author:** ![LauraLuc](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/lauraluc/32/18240_2.png) [@LauraLuc](https://community.homey.app/u/LauraLuc)\
**Post date:** [July 7, 2022, 6:12pm UTC](https://community.homey.app/t/api-request-with-headers/65677/3 "2022-07-07T18:12:36Z")

</div>

Yes thank you ! There was one missing } 😉

```auto
fetch(url, { headers : { 'x-api-key': apiKey }})
  .then(response => response.json())
  .then(data => console.log(data));

```

---

<div class="post-metadata">

**Author:** ![JeffLux](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jefflux/32/34174_2.png) [@JeffLux](https://community.homey.app/u/JeffLux)\
**Post date:** [August 6, 2022, 1:48pm UTC](https://community.homey.app/t/api-request-with-headers/65677/4 "2022-08-06T13:48:22Z")

</div>

Hello  
I am also trying to setup a script from my IoPool. Could you share your full script ? Mine is… not so efficient 🙂  
Thanks

---

<div class="post-metadata">

**Author:** ![LauraLuc](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/lauraluc/32/18240_2.png) [@LauraLuc](https://community.homey.app/u/LauraLuc)\
**Post date:** [August 15, 2022, 11:19am UTC](https://community.homey.app/t/api-request-with-headers/65677/5 "2022-08-15T11:19:12Z")

</div>

Hello, here is the script I use to do my tests. I haven’t made much progress on the application.

```auto
var url = "https://api.iopool.com/v1/pools/";
var apiKey = "yourApiKey";
var titre;
var temp;
var heureReleve;

fetch(url, { headers : { 'x-api-key': apiKey }})
  .then(response => 
    response.json())
  .then(data => {
    titre = data[0].title;
    temp = data[0].latestMeasure.temperature;
    heureReleve = data[0].latestMeasure.measuredAt;
    console.log(titre, 'n°',data[0].id);
    console.log('Temperature:',temp.toFixed(1), '°C');
    console.log('Dernier relevé le', heureReleve)
    //console.log(data);
  })

```

---

<div class="post-metadata">

**Author:** ![Robvred](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robvred/32/121097_2.png) [@Robvred](https://community.homey.app/u/Robvred)\
**Post date:** [August 21, 2025, 8:19am UTC](https://community.homey.app/t/api-request-with-headers/65677/6 "2025-08-21T08:19:01Z")

</div>

Hey There,

I’ve just post an message on the forum to let you know I’ve developped an app for iopool

> [@\[APP\]\[Pro\] iopool Pool Monitor - The health of your pool at a glance](https://community.homey.app/t/app-pro-iopool-api-pool-monitoring/141600/1):
>
> I’ve been building this to make looking after my pool less manual. Today I’m sharing the first public release of iopool Monitor for Homey. I hope it’s useful and I’d love feedback from fellow iopool users. iopool Monitor for Homey App page: [iopool Pool Monitor App for Homey | Homey](https://homey.app/a/com.iopool.api)What it does Reads temperature, pH, ORP, pool mode, and recommended filtration duration Flags when an action is required Flow cards: Trigger: pool mode changed Condition: action required? Action: g…

Let me know !

---

<div class="post-metadata">

**Author:** ![Lasse\_Bodal](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/lasse_bodal/32/81236_2.png) [@Lasse\_Bodal](https://community.homey.app/u/Lasse_Bodal)\
**Post date:** [August 25, 2025, 9:20pm UTC](https://community.homey.app/t/api-request-with-headers/65677/7 "2025-08-25T21:20:04Z")

</div>

How do I integrate this into Homey?

> **[Homey App: Behringer X32 Integration (osc)](https://chatgpt.com/canvas/shared/68acd27dc6748191b2c8dd88a6adc512)**
>
> A conversational AI system that listens, learns, and challenges

---

<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:** [August 26, 2025, 4:56am UTC](https://community.homey.app/t/api-request-with-headers/65677/8 "2025-08-26T04:56:18Z")

</div>

Ask ChatGPT?
