Permalink
Switch branches/tags
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
38 lines (32 sloc) 1.53 KB
layout title description date sidebar comments sharing footer
page
Emoncms API
Emoncms API
2014-12-18 21:49
true
false
true
true

Emoncms API docs

The API is the same for remote Emoncms.org and local Emoncms (running on emonPi). To get started on the EmonPi, read /var/www/emoncms/readme.md or browse to http://127.0.0.1/emoncms/feed/api.

For a local EmonCMS system, just replace emoncms.org with <EMONPI_LOCAL_IP_ADDDRESS>/emoncms. For instance http://127.0.0.1/emoncms.

When trying to read a value, you'll notice that authentication is required.

pi@emonpi(ro):~$ wget -qO- "http://127.0.0.1/emoncms/feed/timevalue.json?id=1"
{"success":false,"message":"Username or password empty"}pi@emonpi(ro):~$ 

Visit https://emoncms.org/site/api# for more information on authentication. Retrieve the API keys from http://127.0.0.1/emoncms/feed/api. For this example, the read only key is ok.

pi@emonpi(ro):~$ APIKEY=put_your_api_key_here
pi@emonpi(ro):~$ wget -qO- "http://127.0.0.1/emoncms/feed/timevalue.json?id=1&apikey=$APIKEY"
{"time":1523695587,"value":32}pi@emonpi(ro):~$ 

If you specify an invalid feed id, you'll get an error message.

pi@emonpi(rw):~$ wget -qO- "http://127.0.0.1/emoncms/feed/timevalue.json?id=3&apikey=$APIKEY"
{"success":false,"message":"Feed does not exist"}

Check your feed list id against the EmonCMS web interface at http://127.0.0.1/emoncms/feed/list