API call to get daily kWh total

Has anyone played with the API to make a single call to get the daily total of a kWh feed?

ie, start 04-11-22 00:00 and end 04-11-22 23:59
I just want to get back the total kWh used between those two times.

I collect and log to feed W, kWh and kWh/d

Wanting to pull that value with a single API call into my Python code. :slight_smile:

Any help or tips appreciated.


feed/data.json?id=<feed>&start=2022-11-04 00:00&end=2022-11-04 23:59&interval=daily&delta=1

Thanks Tim

How is that feed logged?
I do my power “log”, “kwh” and “kwhd”.

Do I need to create a different type of feed to be able to pull the data?
Cos none of my three feeds come back with anything.

I’ve missed that feature - where is that found?

That was with a regular kWh feed, though your kwhd feed should also work without delta.

You might need to play around with feed/api until you find something that works for you. It took me a few goes.

You may also need to input dates in ISO8601 format, i.e. YYYY-MM-DD.

Should work with an integer (which is always the best).

Top right-corner of Feeds page, links to feed/api


1 Like

Cool. I need to update my main system (I found it on one of my test systems) - been avoiding it.

1 Like

This is getting a bit mad now.
So I can get the Feed API helper to work (and subsequent API call) against my emoncms account

But the same commands and settings (against same kWh feeds) come back with null on my VM cloud hosted emoncms install.

It’s a pretty recent build.

Components: Emoncms Core v11.1.3 | App v2.6.2 | Dashboard v2.3.3 | Device v2.1.9 | Graph v2.2.2 | Backup v2.3.2 | DemandShaper v2.2.2 | Postprocess v2.2.4 | Sync v2.1.3 | Usefulscripts v2.3.9 | EmonScripts v1.4.1

Okay, looks for some strange reason that the data specified on the cloud version has to be
03-11-2022 23:59:59

Whereas emoncms.org seems to be a bit more lax about formats? :man_shrugging:


By clous, you mean an instance of EmonCMS on a remote VM? Did you try a UNIX date?

@TrystanLea - not ISO format date/times?

The API does say any PHP supported DTG. What were you trying?

As I say, integers always the best format!!! :rofl:

Think i’m sorted. It might not have entirely been date.

My Sync upto my emoncms (on a remote VM) sent the data over at 23:50.
But the ‘daily’ API interval didn’t like that and came back with ‘null’ from that day.

The emoncms.org worked because I don’t use the sync for that, I just use emonhub to fire instant inputs across.

I’ve amended my code and timings, so hopefully all good now for future runs.

Thanks @Timbones and @borpin for your input. Always good stuff! :+1: