I’m trying to access the API. Requested an API key and -secret from AP-Systems and got that without any issues. Also without an invoice
I’m not a developer, just tinkering and googling a lot.
Thus far I seem to be able to send a request to the web API, but the only result I get is '[200[ (which is ‘success’) and then ‘code 4000’, which is ‘request parameter exception’.
I got in touch with APsystems again, found that the timestamp should be in milliseconds, but no luck yet with retrieving JSON info from the APS site.
This is a snippet from my code, feel free to correct this.
I posted the API manual after getting an API key (for free from within my APSystems app). I can successfully connect to the ECU, but I get a (described) error because I couldn’t get the hashed data right. So, it seems this route work…if I can get some help with the code
Hi @Dick_J , thanks for posting your code. Did you run this in a HomeyScript? I copy/pasted it in a script on my Homey, but unfortunately it won’t run because of various errors on functions. I think Homey runs node.js. Where did you run this on?
Hi Rob, I ran this in visual studio code, in Python . I got a piece of code from AP systems as well, this was written for Postman (?). See pictures. This is a bit like JavaScript
I can’t get it converted to JS on Homey’s node implementation, because it lacks the functions you use. I got the code to connect, working, but the hashing I don’t know.
Hi Rob, unfortunately not. There must be something going wrong with calculating the signature. I moved over to the app development environment, and there it worked, but of course it uses JavaScript. Crypto is not supported in Homey script, so this doesn’t work there.
I called out to Diederik (see reply from Patrick), because there’s already something that works.
Hi @doyouevencomputer I tried your code and yes, I do get a response from the APSystems API. However, the response is OK (200) with subcode 4000, which is a “Request parameter exception”.
Same result as @Dick_J I guess.
When you say that “I was able to get data back using this python script”, do you mean you got back actual data, or did you also get the 4000 code?
If either of these are wrong (same length but change 1 character), I get the 4000 response.
I got the app_id and secret from the https://www.apsystemsema.com portal under Setting > OpenAPI Service > Developer Authorization.
Interestingly, under “Historical Call Statistics” I still see 0 for all months even though I was using the above code with many other endpoints to get various details:
Here are some others that require your sid and/or ecu:
If you’ve only ever got a 4000 error, maybe you could try to generate new app_id/creds values. If the call stats history isn’t working, maybe neither is a prompt that you are locked out or been disabled?
The error I made was that I interpreted “RequestPath” to be a piece of the URL, where is should be just the last part (after the last slash).
So it works. Now, I have to figure out how the command “Get Energy in Period for a Particular System” works. This (and other commands) uses extra parameters, but it is not really described how to send these.
That is something I have not figured out yet, maybe I’ll ask AP for this. Ending the url with ?energy_level:yearly doesn’t work.
Unfortunately, my internet connector (Delta fiber) is now down for the last week, so I have paused my efforts.
Okay, so to send parameters with your request, add a question mark and then parameter name and value. Like:
/user/api/v2/systems/SID/devices/inverter/batch/energy/ECUID?energy_level=power&date_range=2025-05-08
or:
/user/api/v2/systems/energy/ECUID?energy_level=hourly&date_range=2025-05-08