Record Measurements via API

This is a quick tutorial that will show you how you can use the Datacake REST-API to record measurement values into your devices.

There is a large overview of Endpoints and how they function including some examples on an external developer overview. Follow this link if you would like to dive deeply into how the REST-API works.

Record Multiple Values at once

Payload Structure

Make sure that you structure the payload like in the following snippet.

{"field": "WATT", "value": msg.payload.watt },
{"field": "AMPERE", "value": msg.payload.ampere},
{"field": "VOLT", "value": msg.payload.volt}

So the general structure is:

[{"field":"field1", "value":123.00}, {"field":"field2", "value":"a string"}]


The URL you should use for recording multiple measurements at once is:

It is structured as follow:<<device-id>>/record/?batch=true

The Device-Id (<<device-id>>)

This is the ID of your Device. You find this in the URL of the Datacake Portal and on the Device-View.


Rate Limiting

Per default the Datacake REST-API has an internal rate limiting of 1 write per second and per field. If you want to record historical data this might be an issue. So please contact us so that we can deactivate that for you.


Here you find some Examples that show you how to record multiple measurements.


-H "Authorization: Token 923847692384769283469823467"
-H "Content-Type: application/json"
--data '[\
"field": "TEMPERATURE",\
"value": 23.5,\
"timestamp": "1555570137"\
"field": "HUMIDITY",\
"value": 42,\
"timestamp": "1555570137"\


// Set device_id to serial-number of Datacake API Device
device_id = "be525e29-4398-4fc1-a928-dead7fdfe218";
// Set Token to your personal access token or individual token
token = "put your token in here";
// This is the API Information for the HTTP Request Node
url = ""+device_id+"/record/?batch=true"
// Create Header for Node-RED HTTP Node
headers = {
"Authorization": "Token "+token,
"Content-Type": "application/json"
// Now we are going to create the Payload we forward to Datacake API
payload = [
"field": "WATT",
"value": msg.payload.watt
"field": "AMPERE",
"value": msg.payload.ampere
"field": "VOLT",
"value": msg.payload.volt
// Return it - were all set!
return msg;


import requests
DTCK_KEY = 'yourapikey'
DTCK_DEVICE_ID = 'yourdeviceid'
if __name__ == "__main__":
power_dc1 = 234
power_dc2 = 345
​"{DTCK_DEVICE_ID}/record/?batch=true", headers={"Authorization": f"Token {DTCK_KEY}"}, json=[
"field": "POWER_DC1",
"value": power_dc1,
"timestamp": "1555570137" # a timestamp is optional
"field": "POWER_DC2",
"value": power_dc2