Skip to content

IoT TS Aggregates Client for Node.js

Introduction

The IoT TS Aggregates Node.js client allows you to query aggregated time series data. Refer to IoT TS Aggregates for more information about the service.

Hint

In the IoT context, assets are referred to as entity and aspects as propertyset.
Placeholders in the following samples are indicated by angluar brackets < >.

TS Aggregates operations

Client name: AggregatesClient

Read aggregated time series

Read aggregated time series data of a specific asset and aspect. This feature is only available if aspect data is available within the specified time range.

Note

A query can only return up to 200 aggregate intervals in one response.
Aggregates can only be created from up to 5,000 raw time series entries.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Import the mindsphere-sdk-node-core module and require AppCredentials and ClientConfig
let AppCredentials = require('mindsphere-sdk-node-core').AppCredentials;
let ClientConfig = require('mindsphere-sdk-node-core').ClientConfig;

// Import the timeseriesaggregate module and require AggregatesClient
const AggregatesClient = require('tsaggregates-sdk').AggregatesClient;

// Construct the ClientConfig and AppCredentials objects
let config = new ClientConfig();
let credentials = new AppCredentials();

// Construct the AggregatesClient object
let aggregates_client = new AggregatesClient(config, credentials);

try {

  const request_object = {
    entity: <entity_id>,
    propertyset : <property_set>,
    from: <from_date>,
    to: <to_date>,
    intervalValue: <interval_length>,
    intervalUnit: <interval_unit>,
    select: <select>
  };

  let aggregates_data = await aggregates_client.getAggregateTimeseries(request_object);

} catch (ex) {
  // Exception handling
}

Any questions left?

Ask the community


Except where otherwise noted, content on this site is licensed under the MindSphere Development License Agreement.