Download a CSV file
- sensor_idsstringrequiredExample
[ "_id1_", "_id2_", { "operation": "SUM", "label": "My sum", "sensor_ids": [ { "sign": "NEG", "sensor_id": "_id1_" }, { "sign": "NEG", "sensor_id": "_id2_" } ] } ]Description - granularitystringrequiredExampleDescription
- start_timestringrequiredExampleDescription
- end_timestringrequiredExampleDescription
- fieldsstringrequiredExample
[ "p", "u", "i" ]
Description - utc_offsetnumberExampleDescription
- AuthorizationstringrequiredExample
{ "Authorization": "Bearer {jwt token}" }Description
- object
- namestringExampleDescription
- messagestringExampleDescription
- codenumberExampleDescription
- classNamestringExampleDescription
- datastringDescription
- errorsobject[]Example
[ "detailed description of error" ]
Description
- object
- namestringExampleDescription
- messagestringExampleDescription
- codenumberExampleDescription
- classNamestringExampleDescription
- errorsobjectDescription
- object
- namestringExampleDescription
- messagestringExampleDescription
- codenumberExampleDescription
- classNamestringExampleDescription
- errorsobjectDescription
curl --request GET \
--url '/download/csv?sensor_ids=[%22_id1_%22%2C%22_id2_%22%2C{%22operation%22%3A%20%22SUM%22%2C%20%22label%22%3A%20%22My%20sum%22%2C%20%22sensor_ids%22%3A%20[{%22sign%22%3A%20%22NEG%22%2C%20%22sensor_id%22%3A%20%22_id1_%22}%2C%20{%22sign%22%3A%20%22NEG%22%2C%20%22sensor_id%22%3A%20%22_id2_%22}]}]&granularity=h&start_time=2023-01-01T00%3A00%3A00.000Z&end_time=2023-01-02T00%3A00%3A00.000Z&fields=[%22p%22%2C%20%22u%22%2C%20%22i%22]' \
--header 'accept: application/json' \
--header 'authorization: {"Authorization":"Bearer {jwt token}"}'var myHeaders = new Headers();
myHeaders.append("accept", "application/json");
myHeaders.append("content-type", "application/json");
myHeaders.append("authorization", "{\"Authorization\":\"Bearer {jwt token}\"}");
var requestOptions = {
method: 'GET',
headers: myHeaders,
redirect: 'follow'
};
fetch("/download/csv?sensor_ids=[\"_id1_\",\"_id2_\",{\"operation\": \"SUM\", \"label\": \"My sum\", \"sensor_ids\": [{\"sign\": \"NEG\", \"sensor_id\": \"_id1_\"}, {\"sign\": \"NEG\", \"sensor_id\": \"_id2_\"}]}]&granularity=h&start_time=2023-01-01T00:00:00.000Z&end_time=2023-01-02T00:00:00.000Z&fields=[\"p\", \"u\", \"i\"]", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));require "uri"
require "json"
require "net/http"
url = URI("/download/csv?sensor_ids=[\"_id1_\",\"_id2_\",{\"operation\": \"SUM\", \"label\": \"My sum\", \"sensor_ids\": [{\"sign\": \"NEG\", \"sensor_id\": \"_id1_\"}, {\"sign\": \"NEG\", \"sensor_id\": \"_id2_\"}]}]&granularity=h&start_time=2023-01-01T00:00:00.000Z&end_time=2023-01-02T00:00:00.000Z&fields=[\"p\", \"u\", \"i\"]")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Get.new(url)
request["accept"] = "application/json"
request["content-type"] = "application/json"
request["authorization"] = "{\"Authorization\":\"Bearer {jwt token}\"}"
response = http.request(request)
puts response.read_body
import requests
import json
url = "/download/csv?sensor_ids=[\"_id1_\",\"_id2_\",{\"operation\": \"SUM\", \"label\": \"My sum\", \"sensor_ids\": [{\"sign\": \"NEG\", \"sensor_id\": \"_id1_\"}, {\"sign\": \"NEG\", \"sensor_id\": \"_id2_\"}]}]&granularity=h&start_time=2023-01-01T00:00:00.000Z&end_time=2023-01-02T00:00:00.000Z&fields=[\"p\", \"u\", \"i\"]"
payload = {}
headers = {
'accept': 'application/json',
'content-type': 'application/json',
'authorization': '{"Authorization":"Bearer {jwt token}"}'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
// Bad Request
{
"name": "BadRequest",
"message": "Data does not match schema",
"code": 400,
"className": "bad-request",
"data": "",
"errors": [
{}
]
}// Unauthorized
{
"name": "NotAuthenticated",
"message": "Not authenticated",
"code": 401,
"className": "not-authenticated",
"errors": {}
}// Forbidden
{
"name": "Forbidden",
"message": "Access Forbidden",
"code": 403,
"className": "forbidden",
"errors": {}
}This endpoint returns data as a CSV file from one or multiple sensors, or sums of sensors for different granularities and time frames.
Using the parameters, the different granularities, time frames, selected fields and sensor IDs can be specified. Additionally, instead of a simple sensor ID, an operation object can be specified to perform calculations with power values. Operation objects can be used to compute sums of power values over multiple sensors. Sums are only calculated over active power (only field "p"). Each sensor in an operation object requires a sign ("POS" / "NEG") allowing for subtraction of individual sensor's power values.
An example operation object looks as follows:
{
"operation": "SUM",
"label": "my label",
"sensor_ids": [
{
"sign": "POS",
"sensor_id": "_id1_"
},
{
"sign": "NEG",
"sensor_id": "_id2_"
}
]
}
Note that for ten-second values (i.e. granularity="t"), only the fields p, q, and pf are available.
Example Requests:
/download/csv?sensor_ids=["_id1_","_id2_"]&granularity=d&start_time=2023-01-01T00:00:00Z&end_time=2023-01-02T00:00:00Z&fields=["p","i"]
/download/csv?sensor_ids=["_id1_","_id2_",{"operation": "SUM", "label": "my label", "sensor_ids": [{"sign": "POS", "sensor_id": "_id1_"}, {"sign": "NEG", "sensor_id": "_id2_"}]}]&granularity=d&start_time=2021-11-20 00:00:00&end_time=2021-11-21 00:00:00&fields=["u","i","p"]
Limit
The result size is limited depending on the granularity. Note that the limit values apply to the total number of returned lines, not per sensor.
Granularity | Limit |
|---|---|
d | 3'650 (10 y) |
h | 4'320 (6 mo) |
q | 2'880 (1 mo) |
m | 2'880 (2 d) |
ts | 4'320 (12 h) |