Query Time Series Data of Single Device

Last Updated on : 2023-10-25 03:35:14download

Query the statistical trend data of various metrics of the specified device within a certain time range.

API address

POST: /v1.0/m/energy/statistics/device/datadate

Request parameter

Description of body

Parameter nameTypeINRequiredDescription
dev_idStringbodytrueThe device ID.
indicator_codeStringbodytrueThe code of the specified metric.
date_typeStringbodytrueThe statistical granularity. Valid values:
  • month: by month, in the format of yyyyMM. The maximum span is 12 months, and you can only query the data of the most recent year.
  • day: by day, in the format of yyyyMMdd. The maximum span is 7 days, and you can only query the data of the last 90 days.
  • hour: by hour, in the format of yyyyMMddHH. The maximum span is 24 hours, and you can only query the data of the last 7 days.
begin_dateStringbodytrueThe start time.
end_dateStringbodytrueThe end time.
aggregation_typeStringbodyfalseThe aggregation type. Valid values: SUM, AVG, MAX, and MIN.
optionsStringbodyfalseThe extension parameter.

Return parameter

Parameter nameTypeDescription
totalFloatThe total number of returned entries.
unitStringThe unit.
indicatorStringThe code of the specified metric.
listListThe time series data.

Description of list

Parameter nameTypeDescription
valueFloatThe statistical value.
dateStringThe time.

Request example

POST: /v1.0/m/energy/statistics/device/datadate?devId=vdevo168622064605772&indicatorCode=ele_usage&dateType=hour&beginDate=2021092315&endDate=2021092318

Return example

{
    "result": {
        "indicator": "ele_usage",
        "list": [
            {
                "date": "202301",
                "value": 0
            },
            {
                "date": "202302",
                "value": 0
            },
            {
                "date": "202303",
                "value": 0
            },
            {
                "date": "202304",
                "value": 0
            },
            {
                "date": "202305",
                "value": 0
            },
            {
                "date": "202306",
                "value": 3
            }
        ],
        "total": 3,
        "unit": "kWh"
    },
    "success": true
}

Error code

For more information, see error code.