If you want to call any of the following actions when your not logged in you can authenticate with an API key:
There are two types of api key the write apikey and read apikey giving read & write access or read-only access. Login or create an account to obtain these keys.
If you want to call any of the following actions when your not logged in you can authenticate with your API key:
Alternatively use the encrypted input method to post data with higher security where HTTPS is not available.
The EmonCMS input API provides three ways of sending data to emoncms:
If your starting out with EmonCMS 'input/post' is a good starting point for testing, this was the original input method when EmonCMS . The EmonPi/EmonBase uses the 'input/bulk' input method to post to a remote emoncms server as this method provides the option to efficiently bulk upload buffered data after an internet connection outage. Combining multiple updates in a single input/bulk request also reduces bandwidth requirements.
For applications where HTTPS or TLS is not available, emoncms offers an in-built transport layer encryption solution where the emoncms apikey is used as the pre-shared key for encrypting the data with AES-128-CBC.
The "fulljson" format is recommended for new integrations, it uses the PHP JSON decoder and answer is also in json.
The "json like" format is based on the CSV input parsing implementation and maintained for backwards compatibility.
A node name can be a name e.g: emontx or a number e.g: 10.
The input/post API is compatible with both GET and POST request methods (POST examples given use curl).
Description | Method | Example |
---|---|---|
JSON format | GET | input/post?node=emontx&fulljson={"power1":100,"power2":200,"power3":300} |
JSON like format | GET | input/post?node=emontx&json={power1:100,power2:200,power3:300} |
CSV format | GET | input/post?node=mynode&csv=100,200,300 |
Set the input entry time manually | GET | input/post?time=1741948213&node=1&csv=100,200,300 |
Node name as sub-action | GET | input/post/emontx?fulljson={"power1":100,"power2":200,"power3":300} |
To post data from a remote device you will need to include in the request url your write apikey. This give your device write access to your emoncms account, allowing it to post data. For example using the first json type request above just add the apikey to the end like this: | GET | input/post?node=emontx&fulljson={"power1":100,"power2":200,"power3":300}&apikey=APIKEY_WRITE |
JSON format: | POST | curl --data "node=1&data={power1:100,power2:200,power3:300}&apikey=APIKEY_WRITE" "input/post" |
CSV format: | POST | curl --data "node=1&data=100,200,300&apikey=APIKEY_WRITE" "input/post" |
Efficiently upload multiple updates from multiple nodes.
Description | Method | Example |
---|---|---|
Example request: | GET | input/bulk?data=[[0,16,1137],[2,17,1437,3164],[4,19,1412,3077]] |
Legacy default format (4 is now, 2 is -2 seconds and 0 is -4 seconds to now): | GET | input/bulk?data=[[0,16,1137],[2,17,1437,3164],[4,19,1412,3077]] |
Time offset format (-6 is -16 seconds to now): | GET | input/bulk?data=[[-10,16,1137],[-8,17,1437,3164],[-6,19,1412,3077]]&offset=-10 |
Sentat format: (useful for sending as positive increasing time index) | GET | input/bulk?data=[[520,16,1137],[530,17,1437,3164],[535,19,1412,3077]]&sentat=543 |
Absolute time format (-6 is 1387730121 seconds since 1970-01-01 00:00:00 UTC)) | GET | input/bulk?data=[[-10,16,1137],[-8,17,1437,3164],[-6,19,1412,3077]]&time=1741948213 |
Named feeds (similar to the main example but updates the keys "data" and "anotherData" for node 19) | GET | input/bulk?data=[[0,16,1137],[2,17,1437,3164],[4,19,{"data":1412},{"anotherData":3077}]] |
Legacy format: | POST | curl --data "data=[[0,16,1137],[2,17,1437,3164],[4,19,1412,3077]]&apikey=APIKEY_WRITE" "input/bulk" |
Time offset format: | POST | curl --data "data=[[-10,16,1137],[-8,17,1437,3164],[-6,19,1412,3077]]&offset=-10&apikey=APIKEY_WRITE" "input/bulk" |
Sentat format: | POST | curl --data "data=[[520,16,1137],[530,17,1437,3164],[535,19,1412,3077]]&sentat=543&apikey=APIKEY_WRITE" "input/bulk" |
Absolute time format: | POST | curl --data "data=[[-10,16,1137],[-8,17,1437,3164],[-6,19,1412,3077]]&time=1741948213&apikey=APIKEY_WRITE" "input/bulk" |
For applications where HTTPS or TLS is not available, emoncms offers an in-built transport layer encryption solution where the emoncms apikey is used as the pre-shared key for encrypting the data with AES-128-CBC.
There is a PHP example of how to generate an encrypted request here: PHP Example source code.
1. Start with a request string conforming with the API options above e.g: node=emontx&data={power1:100,power2:200,power3:300}
2. Create an initialization vector.
3. Encrypt using AES-128-CBC.
4. Create a single string starting with the initialization vector followed by the cipher-text result of the AES-128-CBC encryption.
5. Convert to a base64 encoded string.
6. Generate a HMAC_HASH of the data string together, using the emoncms apikey for authorization.
7. Send the encrypted string in the POST body of a request to either input/post or input/bulk with headers properties 'Content-type' and 'Authorization' set as below
8. Verify the result. The result is a base64 encoded sha256 hash of the json data string.
Description | Method | Example |
---|---|---|
GET/POST | URL: /input/post or /input/bulk HEADER: Authorization: USERID:HMAC_HASH, Content-Type: aes128cbc POST BODY: IV+CIPHERTEXT |
Input get
List all nodes and associated inputs: | GET | input/get |
List inputs for specific node: | GET | input/get/emontx |
Fetch specific input from node: | GET | input/get/emontx/power1 |
Input actions
List of inputs with latest data | GET | input/list |
Get inputs configuration (last time and value not included) | GET | input/get_inputs |
Set input fields | GET | input/set?inputid=0&fields={'description':'Input Description'} |
Delete an input | GET | input/delete?inputid=0 |
Clean inputs without a process list | GET | input/clean |