For the complete documentation index, see llms.txt. This page is also available as Markdown.

Migrating from v3 to v4

Move from the deprecated /v3/ aggregation endpoints to the /v4/query API, with a v3 and a v4 example for each endpoint.

The /v3/devices/... and /v3/tags/... aggregation endpoints are deprecated. Use the /v4/query API instead. This page shows, for each deprecated endpoint, how to send the same query to v4. Each section has the v3 request and its v4 replacement as curl commands.

Endpoint overview

Deprecated v3 endpoint
v4 endpoint

/v4/query/single-metrics/by-device

/v4/query/single-metrics with RAW

/v4/query/time-series with RAW

/v4/query/time-series/by-device with RAW

/v4/query/single-metrics/by-device with RAW

/v4/query/single-metrics with LAST and RAW

/v4/query/single-metrics/by-device with LAST and RAW

/v4/query/single-metrics/by-device

/v4/query/single-metrics/by-device with RAW

/v4/query/single-metrics/by-device with LAST and RAW

/v4/query/single-metrics with RAW

All endpoints use POST. Four v3 endpoints have no full v4 replacement yet and stay supported. See Endpoints that stay supported.

Before you start

The examples send an API key in the x-api-key header. They use these shell variables:

What changes

Request body

v3 had one flat body. v4 groups the same information into two sections. match says which data to read. aggregation says how to aggregate it.

v3 field
v4 field

{deviceId} in the path

match.devices.deviceIds: ["..."]

deviceIds (batch endpoints)

match.devices.deviceIds

{tagId} in the path

match.devices.tagId: "..."

interval.from and interval.to

match.timestamps.from and match.timestamps.to. Required in v4.

topic and dataKey

match.dataPointSelector.topic and match.dataPointSelector.dataKey

accumulator

aggregation.accumulator (simple mode). See Accumulators.

bucketInterval

aggregation.interval (simple mode) or aggregation.timeStage.interval

filterWorkingHours

flags.filterWorkingHours

/raw/ in the path

aggregation.sourceStage.sourceDataProduct: "RAW"

/aggregated/hourly/ in the path

Nothing to set. Hourly data is the default.

The v3 hourly endpoints merged the values of all measurement types of a topic and dataKey. To get the same result in v4, set match.dataPointSelector.mergeMeasurementTypes to true. The hourly examples below do this.

Response body

v3 response
v4 response

Single metric: {deviceId, topic, dataKey, kpi, timestamp}

{metric: {topic, dataKey, measurementType, akenzaDeviceIds}, dataPoint, timestamp}

Time series: {deviceId, topic, dataKey, dataPoints, timestamps}

{metric: {...}, dataPoints, timestamps}

Trend status: {deviceId, topic, dataKey, trendStatus}

{metric: {...}, trendStatus}

Single-device endpoints return one object.

{devicesQueryMode, results: [...]}. Read results[0].

Batch endpoints return a JSON array.

A page {content: [...], totalElements, ...}. Read content.

  • kpi is now dataPoint.

  • The device ID moved from deviceId to metric.akenzaDeviceIds. This is a set with one entry per result.

Accumulators

v4 has two modes:

  • Simple mode uses one accumulator for the whole query: aggregation.accumulator. Use it for a v3 request that has an accumulator and no summationAccumulator.

  • Advanced mode sets one accumulator per stage. Use it for a v3 request that has a summationAccumulator or reads raw data. sourceDataProduct only exists in advanced mode, so every raw example below sets all three stages.

In advanced mode, map the v3 accumulators to the stages as follows:

v3

v4 sourceStage

v4 timeStage

v4 devicesStage

accumulator: X

X

X

X

accumulator: X (FIRST or LAST), summationAccumulator: Y

X

X

Y

accumulator: X, summationAccumulator: COUNT

X

COUNT

SUM

accumulator: X, summationAccumulator: Y (any other)

X

Y

Y

accumulator: MATCHED_COUNT or UNMATCHED_COUNT

same as v3

SUM

SUM

Behaviour differences

  • Hour alignment (hourly data): v3 aligned interval to full hours without telling you, and left out the hour that contains interval.to. To get the same results as v3, send from and to on full hours.

  • Working hours: if filterWorkingHours is not set, akenza applies it only for the OCCUPANCY accumulator. This is the same as in v3.

  • Raw data (RAW) can cover at most 30 days. The v3 tag latest samples endpoint accepted up to one year.

  • Auto-routing: if you do not set sourceDataProduct, akenza picks the source data product for you. The time range of your query affects the choice: a range shorter than one day can be routed to raw data, a longer range to hourly data.

  • Raw single-metrics aggregates across devices. It therefore accepts only one device ID. To get one value per device, use single-metrics/by-device.

  • /by-device with deviceIds takes no pagination parameters (page, size, sort). It returns all requested devices at once. v3 batch/raw/kpi accepted ?sort=. In v4, sort the results in your application.

  • NONE accumulator: the v3 hourly endpoints replaced NONE with LAST without telling you. In v4, use LAST. v4 rejects NONE together with RAW.

Hourly data

Hourly single metric for one device

Replaces POST /v3/devices/{deviceId}/query/aggregated/hourly/kpi with POST /v4/query/single-metrics.

Response: the v3 kpi is results[0].dataPoint.

Hourly time series for one device

Replaces POST /v3/devices/{deviceId}/query/aggregated/hourly/time-series with POST /v4/query/time-series.

Response: the v3 dataPoints and timestamps are results[0].dataPoints and results[0].timestamps.

Hourly time series for several devices

Replaces POST /v3/devices/query/batch/aggregated/hourly/time-series with POST /v4/query/time-series/by-device.

Response: the v3 array is content, with one entry per device (metric.akenzaDeviceIds).

Hourly single metric for several devices

Replaces POST /v3/devices/query/batch/aggregated/hourly/kpi with POST /v4/query/single-metrics/by-device.

Response: the v3 array is content, with one entry per device. kpi is dataPoint.

Hourly trend status

Replaces POST /v3/devices/{deviceId}/query/aggregated/hourly/trend-status with POST /v4/query/trend-status.

Response: the v3 trendStatus is results[0].trendStatus. Trend status accepts exactly one device ID.

Raw data

Raw single metric for one device

Replaces POST /v3/devices/{deviceId}/query/raw/kpi with POST /v4/query/single-metrics and RAW.

Response: the v3 kpi is results[0].dataPoint.

Raw time series for one device

Replaces POST /v3/devices/{deviceId}/query/raw/time-series with POST /v4/query/time-series and RAW.

Response: results[0].dataPoints and results[0].timestamps. To get the raw samples instead of buckets, set "timeStage": { "interval": null }.

Raw time series for several devices

Replaces POST /v3/devices/query/batch/raw/time-series with POST /v4/query/time-series/by-device and RAW.

Response: the v3 array is content, with one entry per device.

Raw single metric for several devices

Replaces POST /v3/devices/query/batch/raw/kpi with POST /v4/query/single-metrics/by-device and RAW.

Response: the v3 array is content, with one entry per device. v3 accepted ?sort=. v4 takes no pagination parameters here, so sort the results in your application.

Latest sample for one device

Replaces POST /v3/devices/{deviceId}/query/raw/latest-sample with POST /v4/query/single-metrics, LAST and RAW.

v4 requires timestamps. Pick a time window of up to 30 days that contains the latest sample. In the v4 example, from is $SINCE (7 days ago) and the shell fills in the current time for to.

Response: v3 returned an array with one entry. In v4, read results[0]. It contains the dataPoint and timestamp of the latest sample.

Latest sample for several devices

Replaces POST /v3/devices/query/batch/raw/latest-sample with POST /v4/query/single-metrics/by-device, LAST and RAW. The same time window rule applies as for one device.

Response: the v3 array is content, with one entry per device.

Tags

In v4, you select the devices of a tag with match.devices.tagId instead of the {tagId} path segment.

The per-device tag endpoints (.../by-device) return one page of the devices of the tag at a time. They require the page and size query parameters.

Hourly single metric per device of a tag

Replaces POST /v3/tags/{tagId}/query/aggregated/hourly/kpi with POST /v4/query/single-metrics/by-device.

Response: the page structure is the same as in v3. In each entry of content, kpi is now dataPoint.

Hourly single metric across a tag

Replaces POST /v3/tags/{tagId}/query/aggregated/hourly/accumulated-kpi with POST /v4/query/single-metrics.

Response: the v3 kpi is results[0].dataPoint.

Hourly time series across a tag

Replaces POST /v3/tags/{tagId}/query/aggregated/hourly/accumulated-time-series with POST /v4/query/time-series.

Response: the v3 dataPoints and timestamps are results[0].dataPoints and results[0].timestamps.

Raw single metric per device of a tag

Replaces POST /v3/tags/{tagId}/query/raw/kpi with POST /v4/query/single-metrics/by-device and RAW.

Response: the page structure is the same as in v3. kpi is now dataPoint.

Latest sample per device of a tag

Replaces POST /v3/tags/{tagId}/query/raw/latest-samples with POST /v4/query/single-metrics/by-device, LAST and RAW. The same time window rule applies as for one device: up to 30 days.

Response: the page structure is the same as in v3. kpi is now dataPoint.

Raw single metric across a tag

Replaces POST /v3/tags/{tagId}/query/raw/accumulated-kpi with POST /v4/query/single-metrics and RAW.

Response: the v3 kpi is results[0].dataPoint. For raw tag queries, metric.akenzaDeviceIds is empty.

Raw time series across a tag

Replaces POST /v3/tags/{tagId}/query/raw/accumulated-time-series with POST /v4/query/time-series and RAW.

Response: the v3 dataPoints and timestamps are results[0].dataPoints and results[0].timestamps. For raw tag queries, metric.akenzaDeviceIds is empty.

Endpoints that stay supported

These v3 endpoints have no full v4 replacement yet. They stay supported:

  • POST /v3/devices/{deviceId}/query/raw/trend-status: /v4/query/trend-status only supports hourly data for now.

  • POST /v3/devices/query/batch/raw/accumulated-kpi: /v4/query/single-metrics with RAW accepts one device ID (or a tagId), not a list of devices.

  • POST /v3/tags/{tagId}/query/latest-samples: it returns whole samples (all data keys of a topic) and supports assetPropertyFilters. v4 always selects one topic and dataKey.

  • POST /v3/tags/{tagId}/query/aggregate/latest-samples: v4 has no way to group or match latest samples.

Last updated

Was this helpful?