This endpoint retrieves variable aggregated data
To get a single aggregated value of a variable within a time range, please make a GET request to the following URL:
HTTP Method | URL |
---|---|
GET | https://industrial.api.ubidots.com/api/v1.6/variables/<variable_id>/statistics/<aggregation>/<start>/<end> |
Where the path parameters are:
Path parameter | Description |
---|---|
<variable_id> | String with the id of the Variable from which data will be retrieved |
<aggregation> | The aggregation to apply to the variable in the selected time range. Available aggregations: - mean - variance - min - max - sum - count |
<start> | Initial timestamp in milliseconds POSIX format for values of the variable (inclusive). |
<end> | Final timestamp in milliseconds POSIX format for values of the variable (inclusive). |
Headers
The "X-Auth-Token" header is required for your request:
Header | Value | Required? | Description |
---|---|---|---|
X-Auth-Token | Token | Yes | Authentication Token of account. |
Query Parameters
You may add optional parameters to the URL of your request:
Parameter | Value | Type | Description |
---|---|---|---|
token | Token | String | The token to authenticate the request. While sending it as a query parameter is supported, we strongly recommend using the X-Auth-Token header |
Examples
Get mean value of a variable in a time range:
Retrieves the mean value of a variable between 24/11/2021 00:00:00 and 24/11/2021 23:59:59
$ curl -X GET 'https://industrial.api.ubidots.com/api/v1.6/variables/<variable_id>/statistics/mean/1637730000000/1637816399999' \
-H 'X-Auth-Token: oaXBo6ODhIjPsusNRPUGIK4d72bc73'
{
"mean": 56724.07
}
{
"code": 401002,
"message": "Incorrect authentication credentials."
}
Get max value of a variable in a time range:
Retrieves the mean value of a variable between 24/11/2021 00:00:00 and 24/11/2021 23:59:59
$ curl -X GET 'https://industrial.api.ubidots.com/api/v1.6/variables/<variable_id>/statistics/max/1637730000000/1637816399999' \
-H 'X-Auth-Token: oaXBo6ODhIjPsusNRPUGIK4d72bc73'
{
"max": 57424.65
}
{
"code": 401002,
"message": "Incorrect authentication credentials."
}