# Can't get this API node to work. help!

**URL:** <https://discourse.nodered.org/t/cant-get-this-api-node-to-work-help/55365>\
**Category:** General\
**Created:** [17 December 2021 21:13 UTC](https://discourse.nodered.org/t/cant-get-this-api-node-to-work-help/55365 "2021-12-17T21:13:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cinghialino](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cinghialino/32/49415_2.png) [@cinghialino](https://discourse.nodered.org/u/cinghialino)\
**Post date:** [17 December 2021 21:13 UTC](https://discourse.nodered.org/t/cant-get-this-api-node-to-work-help/55365/1 "2021-12-17T21:13:25Z")

</div>

Hello,

I tried to connect to an api to return me the USD value of some crypto.  
I would like to use the API provided by [https://www.livecoinwatch.com](https://www.livecoinwatch.com), and I've followed their instruction as per [Live Coin Watch API Documentation](https://livecoinwatch.github.io/lcw-api-docs/?javascript#coinssingle)

I've created several nodes but I can't get this thing to work.  
Of course I've used my actual API key, for the sake of posting I've replaced it with `<MY-API>`

can you please take a look and tell me what I am doing wrong?  
Thank you.

```auto
[{"id":"e1db25fcf55f9b7b","type":"inject","z":"f9b5be42.917d48","name":"","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"str","x":250,"y":1100,"wires":[["9f52a5e5ee9f9186"]]},{"id":"b1472595dc5c674a","type":"debug","z":"f9b5be42.917d48","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":870,"y":1060,"wires":[]},{"id":"550ad075e2642c7e","type":"ha-api","z":"f9b5be42.917d48","name":"Livecoinwatch with data as headers","server":"20f70dbb.a59b52","version":1,"debugenabled":false,"protocol":"http","method":"post","path":"https://api.livecoinwatch.com/exchanges/list","data":"{\t 'headers': (\t {\t 'content-type': 'application/json',\t 'x-api-key': '<MY-API>'\t }\t ),\t 'body': (\t {\t 'currency': 'USD',\t 'code': 'ETH',\t 'meta': true\t}\t )\t}","dataType":"jsonata","responseType":"json","outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"results"}],"x":590,"y":1060,"wires":[["b1472595dc5c674a"]]},{"id":"9f52a5e5ee9f9186","type":"function","z":"f9b5be42.917d48","name":"Send headers + body","func":"msg.headers = {}\nmsg.headers['content-type'] = 'application/json';\nmsg.headers['x-api-key'] = '<MY-API>';\nmsg.body = {};\nmsg.body['currency'] = 'USD';\nmsg.body['code']= 'ETH';\nmsg.body['meta']= true;\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":420,"y":1100,"wires":[["8247c36801658cb2"]]},{"id":"d06e64e2cf268127","type":"inject","z":"f9b5be42.917d48","name":"with headers","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"headers","v":"{\t 'content-type' : \"application/json\",\t 'x-api-key' : \"<MY-API>\"\t}\t","vt":"jsonata"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":270,"y":1060,"wires":[["550ad075e2642c7e"]]},{"id":"3389aa70cc81fae1","type":"ha-api","z":"f9b5be42.917d48","name":"Livecoinwatch with data as headers","server":"20f70dbb.a59b52","version":1,"debugenabled":false,"protocol":"http","method":"post","path":"https://api.livecoinwatch.com/coins/single","data":"{\t 'headers': {\t 'content-type': 'application/json',\t 'x-api-key': '<MY-API>'\t },\t 'body': {\t 'currency': 'ETH',\t 'code': 'gemini',\t 'meta': true\t}\t}","dataType":"jsonata","responseType":"json","outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"results"}],"x":590,"y":1020,"wires":[["b1472595dc5c674a"]]},{"id":"654a0f6f659189c5","type":"inject","z":"f9b5be42.917d48","name":"no headers","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":260,"y":1020,"wires":[["3389aa70cc81fae1"]]},{"id":"8247c36801658cb2","type":"ha-api","z":"f9b5be42.917d48","name":"Livecoinwatch no data","server":"20f70dbb.a59b52","version":1,"debugenabled":false,"protocol":"http","method":"post","path":"https://api.livecoinwatch.com/coins/single","data":"{}","dataType":"jsonata","responseType":"json","outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"results"}],"x":640,"y":1100,"wires":[["b1472595dc5c674a"]]},{"id":"20f70dbb.a59b52","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]

```

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [17 December 2021 21:42 UTC](https://discourse.nodered.org/t/cant-get-this-api-node-to-work-help/55365/2 "2021-12-17T21:42:27Z")

</div>

No Idea with the node you're using, but you should be able to use the built in http request node.  
e.g.

```auto
[{"id":"e1db25fcf55f9b7b","type":"inject","z":"c791cbc0.84f648","name":"","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"str","x":90,"y":1200,"wires":[["9f52a5e5ee9f9186"]]},{"id":"9f52a5e5ee9f9186","type":"function","z":"c791cbc0.84f648","name":"Send headers + body","func":"msg.headers = {}\nmsg.headers['content-type'] = 'application/json';\nmsg.headers['x-api-key'] = '<MY-API>';\nmsg.payload = `{\n \"currency\": \"USD\",\n \"code\": \"ETH\",\n \"meta\": true\n}`;\nmsg.url = \"https://api.livecoinwatch.com/coins/single\";\nmsg.method = \"POST\";\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":320,"y":1200,"wires":[["a5ac8be8.c67ea8"]]},{"id":"a5ac8be8.c67ea8","type":"http request","z":"c791cbc0.84f648","name":"","method":"use","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":310,"y":1260,"wires":[["b1472595dc5c674a"]]},{"id":"b1472595dc5c674a","type":"debug","z":"c791cbc0.84f648","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":710,"y":1160,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![cinghialino](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cinghialino/32/49415_2.png) [@cinghialino](https://discourse.nodered.org/u/cinghialino)\
**Post date:** [17 December 2021 22:02 UTC](https://discourse.nodered.org/t/cant-get-this-api-node-to-work-help/55365/3 "2021-12-17T22:02:50Z")

</div>

that works. thank you so much.

Still wondering what that API node is for. I can't get it to work.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [17 December 2021 22:07 UTC](https://discourse.nodered.org/t/cant-get-this-api-node-to-work-help/55365/4 "2021-12-17T22:07:39Z")

</div>

It's a home assistant node, so I have no idea as i don't use HA  
But this may help explain it for you  
[https://zachowj.github.io/node-red-contrib-home-assistant-websocket/node/API.html#config](https://zachowj.github.io/node-red-contrib-home-assistant-websocket/node/API.html#config)

> **[REST API | Home Assistant Developer Docs](https://developers.home-assistant.io/docs/api/rest/)**
>
> Home Assistant provides a RESTful API on the same port as the web frontend. (default port is port 8123).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [31 December 2021 22:07 UTC](https://discourse.nodered.org/t/cant-get-this-api-node-to-work-help/55365/5 "2021-12-31T22:07:53Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
