Get variable aggregated data

This endpoint retrieves variable aggregated data

To get a single aggregated value for a variable within a time range, make a GET request to the following URL:

HTTP MethodURL
GEThttps://industrial.api.ubidots.com/api/v1.6/variables/<variable_id>/statistics/<aggregation>/<start>/<end>

The path parameters are:

Path parameterDescription
<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 POSIX timestamp, in milliseconds, for the variable values (inclusive).
<end>Final POSIX timestamp, in milliseconds, for the variable values (inclusive).

Headers

The X-Auth-Token header is required for your request:

HeaderValueRequired?Description
X-Auth-TokenTokenYesAuthentication token for the account.

Query Parameters

You may add optional parameters to the URL of your request:

ParameterValueTypeDescription
tokenTokenStringThe token used to authenticate the request.
While sending it as a query parameter is supported, we strongly recommend using the X-Auth-Token header.

Examples

Get the 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 the max value of a variable in a time range:
Retrieves the max 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."
}