Query the Historical Data of Properties Reports
After a device is added to the Milesight Development Platform, it periodically reports property data to the platform, such as current status, collected data, and more. This topic introduces the interface for querying the historical data of device properties reports.
Request URL
GET {base_url}/device/openapi/v1/devices/{deviceId}/properties/history?{query parameters}
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
Authorization | Yes | String | The valid access token for making API calls. The format should be Bearer {access_token}. |
Parameter | Required | Type | Description |
---|---|---|---|
deviceId | Yes | Long | The unique ID of this device, which is returned when you add
the device. Note: If you did NOT save the
deviceID, you can query the device's ID using Search Specific Devices.
|
Parameter | Required | Type | Description |
---|---|---|---|
startTime | No | Long | Specify the start time for querying records in the format of Unix timestamp (Unit: Millisecond). |
endTime | No | Long | Specify the end time for querying records in the format of Unix timestamp (Unit: Millisecond). |
pageSize | No | Integer | Define how many records per page. |
pageKey | No | String |
This parameter is NOT required in the first request. If the
response includes a To retrieve the remaining records, include this parameter
with the value of |
order | No | String | Define the display order. Valid value:
|
Response Parameters
Parameter | Type | Description |
---|---|---|
data | Object<Device_Info> | Detailed information of the queried device. |
status | String | The result of the API request.
|
requestId | String | The unique ID of the request, which can be used to quickly locate the request. |
- Device_Info
-
Parameter Type Description list Array List of the device properties reporting records. ts Integer The timestamp of the reporting time. properties JSON Details of the reported data. pageSize Integer The number of records displayed on each page. nextPageKey String The key for the next page of records. Use this value in the next API request to retrieve data of the next page.
Examples
- Request example
- Query the data reported by the device with device ID "1739930666380779522" from the last one day if data storage is enabled.
- Response example
-
HTTP/1.1 200 OK { "data":{ "list":[ { "ts": "1703046615852" "properties":{ "temperature": 24, "humidity": 84, "pir": true, "illumiance":0, "co2":573, "tvoc":100, "barometric_pressure":10231, "pm2_5":8, "pm10":8 } }, { "ts": "170304553283" "properties":{ "temperature": 26, "humidity": 72, "pir": true, "illumiance":0, "co2":411, "tvoc":100, "barometric_pressure":10193, "pm2_5":7, "pm10":8 } } ] } "status": "Success", "requestId": "4c446ddf993fd3643f5e076498a992b5" }