# Trying to get data from solis API

**URL:** <https://discourse.nodered.org/t/trying-to-get-data-from-solis-api/91093>\
**Category:** General\
**Created:** [19 September 2024 06:17 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-solis-api/91093 "2024-09-19T06:17:37Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![FireWizard52](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/firewizard52/32/34508_2.png) [@FireWizard52](https://discourse.nodered.org/u/FireWizard52)\
**Post date:** [15 October 2024 20:01 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-solis-api/91093/21 "2024-10-15T20:01:12Z")

</div>

Wiil this be of any help:

> **[GitHub - ZuinigeRijder/SolisCloud2PVOutput: Simple Python3 script to copy latest (normally...](https://github.com/ZuinigeRijder/SolisCloud2PVOutput?tab=readme-ov-file)**
>
> Simple Python3 script to copy latest (normally once per 5 minutes) SolisCloud portal inverter update to PVOutput portal, Domoticz, and/or MQTT Broker (e.g. HomeAssistant, ioBroker).

---

<div class="post-metadata">

**Author:** ![Asche](https://avatars.discourse-cdn.com/v4/letter/a/9dc877/32.png) [@Asche](https://discourse.nodered.org/u/Asche)\
**Post date:** [16 October 2024 15:47 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-solis-api/91093/22 "2024-10-16T15:47:16Z")

</div>

Hello everyone,  
I have finally got the interface up and running. The last code Steve posted here had only one tiny error, a slash in line 43 in the function node. That had to be removed and then it worked.  
Thanks to everyone who gave me help here! You guys are great!  
Best regards

---

<div class="post-metadata">

**Author:** ![xx\_Nexus\_xx](https://avatars.discourse-cdn.com/v4/letter/x/54ee81/32.png) [@xx\_Nexus\_xx](https://discourse.nodered.org/u/xx_Nexus_xx)\
**Post date:** [16 October 2024 22:31 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-solis-api/91093/23 "2024-10-16T22:31:35Z")

</div>

can you share your final code?

---

<div class="post-metadata">

**Author:** ![Asche](https://avatars.discourse-cdn.com/v4/letter/a/9dc877/32.png) [@Asche](https://discourse.nodered.org/u/Asche)\
**Post date:** [17 October 2024 06:20 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-solis-api/91093/24 "2024-10-17T06:20:22Z")

</div>

This is my final code. Some data belonging to the system still needs to be updated.

```auto
[
    {
        "id": "9a840be7e82e3376",
        "type": "tab",
        "label": "Solis API",
        "disabled": false,
        "info": ""
    },
    {
        "id": "7a2fd68cb2eb35fd",
        "type": "function",
        "z": "9a840be7e82e3376",
        "name": "apply headers",
        "func": "// MD5 the payload\nconst payload = JSON.stringify(msg.payload)\nconst md5Hash = crypto.createHash('md5').update(payload, 'utf8').digest();\nconst contentMD5 = md5Hash.toString('base64')\n\n// extract other params or defaults\nmsg.method = msg.method || 'POST'\nconst canonicalResource = msg.canonicalResource || \"/v1/api/inverterDetail\"\nconst apiSecret = msg.secret || 'test-key' // UPDATE ME\nconst domain = msg.domain || 'blahblah.com' // UPDATE ME\nconst apiId = msg.apiId || 'your-api-id' // UPDATE ME\nconst contentType = 'application/json' // fixed\n\n// this might need some work - just hoping the UTC format works\nconst date = new Date().toUTCString()\n\n// Generate the HMAC SHA-1 signature\nconst stringToSign = [\n msg.method, // HTTP verb\n contentMD5,\n contentType,\n date,\n canonicalResource\n].join('\\n')\n\nconst hmac = crypto.createHmac('sha1', apiSecret)\nhmac.update(stringToSign)\nconst signature = hmac.digest('base64')\n\n// add headers\n// doc states: \"all interface requests require adding\" \n// * Content MD5\n// * Content Type\n// * Date\n// * Authorization\nmsg.headers = msg.headers || {}\nmsg.headers['Content-MD5'] = contentMD5\nmsg.headers['Content-Type'] = contentType\nmsg.headers.Date = date\nmsg.headers.Authorization = `API ${apiId}:${signature}`\n\n// set full URL\nmsg.url = `https://${domain}${canonicalResource}`\n\nreturn msg;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [
            {
                "var": "crypto",
                "module": "crypto"
            }
        ],
        "x": 500,
        "y": 340,
        "wires": [
            [
                "ba2d79213a40cb8d",
                "3045441307964241"
            ]
        ]
    },
    {
        "id": "f05243cf398e86f6",
        "type": "inject",
        "z": "9a840be7e82e3376",
        "name": "UPDATE ME",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "method",
                "v": "POST",
                "vt": "str"
            },
            {
                "p": "canonicalResource",
                "v": "/v1/api/inverterDetail",
                "vt": "str"
            },
            {
                "p": "apiId",
                "v": "update me",
                "vt": "str"
            },
            {
                "p": "secret",
                "v": "update me",
                "vt": "str"
            },
            {
                "p": "domain",
                "v": "www.soliscloud.com:13333",
                "vt": "str"
            }
        ],
        "repeat": "30",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{\"id\": \"update me\", \"sn\": \"update me\"}",
        "payloadType": "json",
        "x": 180,
        "y": 340,
        "wires": [
            [
                "7a2fd68cb2eb35fd"
            ]
        ]
    },
    {
        "id": "ba2d79213a40cb8d",
        "type": "http request",
        "z": "9a840be7e82e3376",
        "name": "",
        "method": "use",
        "ret": "obj",
        "paytoqs": "ignore",
        "url": "",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": true,
        "authType": "",
        "senderr": true,
        "headers": [],
        "x": 730,
        "y": 340,
        "wires": [
            [
                "b9092b8b5ffd31bf"
            ]
        ]
    },
    {
        "id": "3045441307964241",
        "type": "debug",
        "z": "9a840be7e82e3376",
        "name": "CHECK ME",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 770,
        "y": 240,
        "wires": []
    },
    {
        "id": "b9092b8b5ffd31bf",
        "type": "debug",
        "z": "9a840be7e82e3376",
        "name": "Result",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 970,
        "y": 280,
        "wires": []
    }
]

```

---

<div class="post-metadata">

**Author:** ![Sirhc](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sirhc](https://discourse.nodered.org/u/Sirhc)\
**Post date:** [24 October 2024 07:51 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-solis-api/91093/25 "2024-10-24T07:51:21Z")

</div>

Apologies for the delay, did you get it all sorted?

---

<div class="post-metadata">

**Author:** ![xx\_Nexus\_xx](https://avatars.discourse-cdn.com/v4/letter/x/54ee81/32.png) [@xx\_Nexus\_xx](https://discourse.nodered.org/u/xx_Nexus_xx)\
**Post date:** [24 October 2024 23:57 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-solis-api/91093/26 "2024-10-24T23:57:30Z")

</div>

yes, the code provided by @Asche does work ..thx a lot .. great work

---

<div class="post-metadata">

**Author:** ![Asche](https://avatars.discourse-cdn.com/v4/letter/a/9dc877/32.png) [@Asche](https://discourse.nodered.org/u/Asche)\
**Post date:** [26 October 2024 12:52 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-solis-api/91093/27 "2024-10-26T12:52:25Z")

</div>

> [@Sirhc](#):
>
> Apologies for the delay, did you get it all sorted?

Thank you for getting in touch again. As xx\_Nexus\_xx had already written, access to the interface is working. The decisive factor for this was the support from Steve!

---

<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:** [24 January 2025 12:52 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-solis-api/91093/28 "2025-01-24T12:52:32Z")

</div>

Closed on 24 January 2025 12:52 UTC

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

[Previous page](https://discourse.nodered.org/t/trying-to-get-data-from-solis-api/91093.md?page=1)
