Get Aggregation by Time
POST/aggregates/variable/byTime
Time aggregates allows you to question answers like:
- What is the average value of a variable over a time period?
- What is maximum value of a variable over blocks of 15 minute?
- What is the difference between initial and last value of a variable over a week?
Time aggregation APIs are very powerful APIs which allows you to summarize millions of datapoins into aggregated form on demand.
Aggregation APIs incur charge based on how much data scanned to compute the output. Measured in GB-Scanned
Maximum processing time for each request is 10s
Fields from
and to
defines a global range from which data is read. This data is then processed as per provided config
object.
First option defines the type of aggregation you want to perform.
Aggregation | Description |
---|---|
sum | Sums all values over given interval |
avg | Computes average value over given interval |
median | Computes median value over given interval |
min | Computes minimum value over given interval |
max | Computes maximum value over given interval |
diff | Computes difference between first and last value over given interval. For example: If values are (1,2,3,1,2) the result will be 1 |
deltasum | Computes difference between first and last value over given interval, but accounts for reset in counter between time ranges. For example: If values are (1,2,3,1,2) the result will be 5. i.e the decrease in value is neglected. Useful when your values are ever increasing, like energy or water meters |
Along with aggregation one more field forEachNode
is specified which controls whether the aggregation should be performed for each individual node
specified or values from all nodes should be combined in single output. Note: This feature works only when valid filter
object is specified and type is include
.
interval
object defines the time intervals for aggregation. For example: Specifying aggregation as max
, interval type
to be minute
and interval
to be 5
will give maximum value of variable in intervals of 5 minutes for the time range specified in to
and from
.
filter
object allows you to perform aggregation only for a particular set of nodes or excluding particular set of nodes.
Request
- application/json
Body
config objectrequired
aggregation object
Possible values: [sum
, avg
, median
, min
, max
, diff
, deltasum
, stddev
]
interval objectrequired
Possible values: [year
, month
, week
, day
, hour
, minute
]
responseOptions object
Possible values: [UTC
]
filter object
Possible values: [include
, exclude
]
Responses
- 200
OK
- application/json
- Schema
- Example (from schema)
Schema
- Array [
- ]
config object
aggregation object
interval object
filter object
responseOptions object
data object
node1 object[]
{
"success": true,
"error": "string",
"errorcode": 0,
"variable": "string",
"config": {
"aggregation": {
"compute": "string",
"forEachNode": true
},
"interval": {
"measure": "string",
"interval": 0
},
"filter": {
"nodes": [
"string"
],
"type": "string"
},
"responseOptions": {
"timezone": "string"
}
},
"data": {
"node1": [
{
"timestamp": 0,
"aggregate": 0
}
]
}
}