Querying aggregations
Aggregate device data with the REST API, from a single metric to multi-stage aggregations across devices and time.
The akenza REST API can aggregate device data across many devices and over long time ranges. To read single data points of one device instead, use the raw samples API.
This page guides you through the concepts of the aggregation API:
data products
goal: understand WHAT you want to query and expected output format
endpoint selection and body structure
goal: understand HOW you want to query
full Postman documentation
goal: have a complete API reference parseable according to OpenAPI standard
Data product: single metric, time series and calendar grouping
The aggregation API returns three types of output data products:
Single metric: one value
for example, the average temperature of 10 sensors over the last 7 days
Time series: several values, each with a timestamp
for example, the maximum daily CO2 of one sensor from October 2026 to November 2026
Calendar grouping: several values grouped into calendar buckets
for example, the average occupancy of 20 desk sensors, grouped by day of the week
akenza computes the output from one of two source data products. They set the granularity of the data used for the calculation.
Hourly aggregates (time series)
✅ fastest. You can query months or years of data.
✅ supports the advanced analytics pipeline (concurrent occupancy, time in range, ...)
❌ the time resolution is limited to one hour
Raw samples (JSON)
✅ no limit on time resolution. It depends only on the sensor.
❌ slower. You can query at most 30 days of data.
❌ does not support the advanced analytics pipeline (concurrent occupancy, time in range, ...)

Endpoint selection and body structure
In order to write your own query, you first need to choose the right endpoint. This depends on the data product (see above) and whether you want to aggregate data across devices or keep one result per device.
Single metric: one value
POST /v4/query/single-metrics
Example: the average temperature of 10 sensors over the last 7 days (one value)
POST /v4/query/single-metrics/by-device
Example: the average temperature of each of 10 sensors over the last 7 days (10 values, one for each sensor)
Time series: several values, each with a timestamp
POST /v4/query/time-series
Example: the maximum daily CO2 across all sensors of a floor from October 2026 to November 2026 (1 timeseries)
POST /v4/query/time-series/by-device
Example: the maximum daily CO2 of each sensor from October 2026 to November 2026 (N timeseries, one for each)
Calendar grouping: several values grouped into calendar buckets
POST /v4/query/calendar-grouping
Example: the average occupancy of 20 desk sensors, grouped by day of the week
POST /v4/query/calendar-grouping/by-device
Example: the average occupancy of each of 20 desk sensors, grouped by day of the week
Then you need to construct your request body accordingly.
A typical body could look like this (query daily average temperature of one sensor)
A default body has three section:
matchselects the data: which devices, which time range, and whichtopicanddataKey.aggregationdescribes how akenza aggregates the selected datait can be in "easy" mode - one accumulator and one interval - as in the example above
OR it can be in expert mode and will have up to three stage (see Querying concurrent occupancy for explaination)
sourceStageselects one value per device (using topic/dataKey or measurementType) from the source datadevicesStagecombines the values of several devices into one value.timeStagecombines values over time.intervalsets the bucket size as an ISO 8601 duration, for exampleP1Dfor one value per day.
flagschanges how akenza formats and filters the result
By default, akenza aggregates over time first and then across devices. Set aggregation.groupByTimeThenDevices to false to aggregate across devices first.
Note the aggregation stage can also be simplified in easy case (when only one accumulator is needed). For example:
Endpoint documentation in Postman
See the Postman documentation for the complete documentation of all endpoints and schema (all accumulators, all filters, all matchers ...)
Accumulators
akenza provides several aggregation methods to sum data in an interval.
MIN
the reported minimum during the time range
MAX
the reported maximum during the time range
AVG
the average of reported values during the time range
SUM
the sum of reported values during the time range
COUNT
the count of reported values during the time range
FIRST
the first value in the time range
LAST (or NONE)
the last value in the time range
DISTINCT_COUNT
the unique value counts for string values during the time range
MATCHED_COUNT
the number of values that are true during the time range
UNMATCHED_COUNT
the number of values that are false during the time range
COUNT_IF
the number of values that match the
filter, for example the number of desks with an occupancy of 0 %
SHARE_IF
the share of values that match the
filter, for example the share of desks with an occupancy of 0 %
OCCUPANCY
Refer to time-based occupancy in % (see below)
Time-based occupancy %
The algorithm to calculate time-based occupancy in % is based on a bucketing algorithm (the hour is split into 12 buckets, the occupancy is determined by the number of buckets that are marked as occupied).
The resulting value is the percentage of occupied time.
The example below returns the time-based occupancy of one desk over 5 days:
Response:
FAQ
Last updated
Was this helpful?