Get statistics
GET
/statistics
Query Parameters
- sensor_idstringrequiredDescription
- yearnumberDescription
- monthnumberDescription
- daynumberDescription
Header Parameters
- AuthorizationstringrequiredExample
{ "Authorization": "Bearer {jwt token}" }Description
Responses
200
- object
- totalnumberDescription
- limitnumberDescription
- skipnumberDescription
- dataobject[]
- _idstringDescription
- sensor_idstringDescription
- sensor_hw_serialstringExampleDescription
- doc_typestringExample
- yearnumberExample
- monthstringExample
- daystringExample
- recording_startstringExample
- recording_stopstringExample
- dataobject
- energy_daynumber
- peak_power_daynumber
- peak_power_datetimestringExample
- cost_energy_daynumber
- cost_peak_daynumber
- cost_daynumber
- kgCO2e_daynumber
- appliance_used_dayobject
- last_journal_updatestringExample
400
- object
- namestringExampleDescription
- messagestringExampleDescription
- codenumberExampleDescription
- classNamestringExampleDescription
- datastringDescription
- errorsobject[]Example
[ "detailed description of error" ]
Description
401
- object
- namestringExampleDescription
- messagestringExampleDescription
- codenumberExampleDescription
- classNamestringExampleDescription
- errorsobjectDescription
403
- object
- namestringExampleDescription
- messagestringExampleDescription
- codenumberExampleDescription
- classNamestringExampleDescription
- errorsobjectDescription
curl
curl --request GET \
--url '/statistics?sensor_id=string' \
--header 'accept: application/json' \
--header 'authorization: {"Authorization":"Bearer {jwt token}"}'javascript
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("/statistics?sensor_id=string", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));ruby
require "uri"
require "json"
require "net/http"
url = URI("/statistics?sensor_id=string")
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
python
import requests
import json
url = "/statistics?sensor_id=string"
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)
200
// OK
{
"total": 0,
"limit": 0,
"skip": 0,
"data": [
{
"_id": "",
"sensor_id": "",
"sensor_hw_serial": "SE01000000",
"doc_type": "statistic",
"year": 2023,
"month": "2",
"day": "21",
"recording_start": "2023-01-01T00:00:00.000Z",
"recording_stop": "2023-02-21T00:00:00.000Z",
"data": {
"energy_day": 0,
"peak_power_day": 0,
"peak_power_datetime": "2023-02-21T19:00:00.000Z",
"cost_energy_day": 0,
"cost_peak_day": 0,
"cost_day": 0,
"kgCO2e_day": 0,
"appliance_used_day": {},
"last_journal_update": "2023-02-21T00:00:00.000Z"
}
}
]
}400
// Bad Request
{
"name": "BadRequest",
"message": "Data does not match schema",
"code": 400,
"className": "bad-request",
"data": "",
"errors": [
{}
]
}401
// Unauthorized
{
"name": "NotAuthenticated",
"message": "Not authenticated",
"code": 401,
"className": "not-authenticated",
"errors": {}
}403
// Forbidden
{
"name": "Forbidden",
"message": "Access Forbidden",
"code": 403,
"className": "forbidden",
"errors": {}
}Allows to retrieve statistics for a single sensor.