Get aggregated data stream values
GET/api/v1/orgs/{orgId}/devices/{deviceId}/data-streams/{dataStreamId}/aggregate
Compute one or more aggregate values over a time range in fixed-width buckets (period), optionally
with an overlapping slidingStep.
Parameters
deviceId(string, required): Unique ID of the device. Example:74fe488d5d35dataStreamId(Guid, required): Unique ID of the data stream. Example:3a217ee3-fb2c-617b-6ff6-7257537afadestartTime(DateTime, required): Window start, ISO 8601 date-time. Example:2026-09-01T00:00:00ZendTime(DateTime, required): Window end, ISO 8601 date-time. Example:2026-09-02T00:00:00Zperiod(string, required): Bucket width for the time-windowed grouping, as an ISO 8601 duration.slidingStep(string, optional): Sliding step between consecutive buckets, as an ISO 8601 duration; defaults toperiod(non-overlapping, contiguous buckets) when omitted. Must not be smaller thanperiod.function(string[], required): One or more aggregate functions to compute. Accepts either repeated query parameters (function=COUNT&function=MAX_VALUE) or a single comma-separated value (e.g.function=COUNT,MAX_VALUE); the two forms may also be mixed. The complete set of valid values, matched case-insensitively, is:SUM,COUNT,AVG,EXTREME,MAX_VALUE,MIN_VALUE,FIRST_VALUE,LAST_VALUE,MAX_TIME,MIN_TIME. No other value is accepted. Each requested function becomes a field on everydatarow it has a value for, keyed by the lowercase form of the same name (e.g. requestingMAX_VALUEproduces the fieldmax_value). The request and response spellings differ only in case.
Numerical functions (SUM, AVG, EXTREME, MAX_VALUE, MIN_VALUE) require the data stream's
dataType to be one of the three numeric types: double, integer, long. Requesting a Numerical
function against a data stream whose dataType is any other value (boolean, string,
application/json, application/octet-stream, image/png, image/jpeg, image/jpg, data-pack,
blob) rejects the whole call with 422. The remaining functions (COUNT, FIRST_VALUE,
LAST_VALUE, MAX_TIME, MIN_TIME) are Universal and work against any dataType.
Response Fields:
deviceId(string): Device unique ID the aggregated values belong to.dataStreamId(Guid): Unique ID of the data stream the aggregated values belong to.dataType(string): Data type of the underlying stream values.values(object): One entry per requested function, keyed by its lowercase name (e.g.avg,max_value); a function with no buckets in range is omitted. Each entry is an array of:timestamp(long): Bucket start time as a Unix epoch timestamp in milliseconds (UTC), not an ISO 8601 date-time string. Example:1788220800000is2026-09-01T00:00:00Z.value: Computed value for the bucket (a number, except FIRST_VALUE/LAST_VALUE against a non-numeric stream, which carry that stream's native string/boolean value).
Responses
200 OK: Returnsdata, one row per time bucket ordered by timestamp, each row carrying one field per requested function that has a value for that bucket, alongside itstimestamp.400 Bad Request: Missing or malformed time range, period, or slidingStep (not parseable as ISO 8601), startTime not earlier than endTime, orslidingStepsmaller thanperiod.404 Not Found: Data stream not found.422 Unprocessable Content: A Numerical function (SUM,AVG,EXTREME,MAX_VALUE,MIN_VALUE) requested against a data stream whosedataTypeis notdouble,integer, orlong.
Security
- This API requires authentication.
Request
Responses
- 200
- 400
- 401
- 403
- 404
- 422
Returns deviceId, dataStreamId, dataType, and data: one row per time bucket ordered by timestamp, each row carrying its timestamp plus one field per requested function that has a value for that bucket, keyed by the lowercase function name (e.g. avg, max_value).
Missing or malformed time range, period, or slidingStep (not parseable as ISO 8601), startTime not earlier than endTime, or slidingStep smaller than period.
The request is missing a bearer token, or the token is malformed, expired, or otherwise fails signature/issuer validation.
The bearer token is valid but does not grant access to this request: either it lacks the data-stream.read scope required by this endpoint, or its resource_access claim does not grant the caller access to the organization identified by orgId.
Data stream not found.
A Numerical function (SUM, AVG, EXTREME, MAX_VALUE, MIN_VALUE) requested against a data stream whose dataType is not double, integer, or long.