Time series data
Yggio saves numerical and string data into a time series database.
Using the REST API you can get time-series-data of a specific attribute from an iotnode.
The following is the format of time series data for an attribute of an iotnode:
[
{
"time": String,
"value": Number || String
},
...
]
time
is a ISO 8601 timestamp. E.g.: 2019-08-07T12:30:00.00Z.
value
is the saved value.
Set time interval
One can choose to get the data with a set time between each data point. This might be desirable if a high data resolution is not needed. It can improve loading times and performance. The database then uses interpolation to set the values for the data points.
If a set time interval is used the data will have the following format:
[
{
"time": String,
"value": Number,
"min": Number,
"max": Number,
"stddev": Number
},
...
]
time
is a ISO 8601 timestamp. E.g.: 2019-08-07T12:30:00.00Z.
value
is the interpolated value.
min
is the value of the smallest point in the interpolated area.
max
is the value of the largest point in the interpolated area.
stddev
is the standard deviation of the points in the interpolation area.
Downsample data with valueFunction
The valueFunction
feature allows you to perform operations on data grouped within specific time windows. This can be useful for analyzing data trends over time by summarizing the data points within each window.
Supported Operations
The following operations can be performed using valueFunction
:
mean
: Calculates the average of all values within the window.max
: Finds the maximum value within the window.min
: Finds the minimum value within the window.first
: Uses the first value within the window.last
: Uses the last value within the window.sum
: Calculates the sum of all values within the window.count
: Counts the number of values within the window.difference
: Calculates the difference between the fist value of subsequent windows
Defining the Time Window
The time window for the valueFunction
is determined by the "distance" option. This specifies the length of each window given in number of seconds
Response format
When using the valueFunction
feature, the response will be in the following JSON format:
[
{
"time": String,
"value": Number
},
...
]
time
: An ISO 8601 timestamp (e.g., 2019-08-07T12:30:00.00Z) indicating the start of the time window.
value
: The result of the specified valueFunction operation for the time window.
Handling Empty Windows
If there are no data points within a specified time window, that window will be skipped in the response.
Example
Here's an example response for an API request with valueFunction=mean and distance=3600 (1 hour):
[
{
"time": "2019-08-07T12:00:00.00Z",
"value": 23.5
},
{
"time": "2019-08-07T13:00:00.00Z",
"value": 19.8
},
...
]
In this example, the value
at each timestamp is the mean of all values within the corresponding one-hour window.