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.0/devices/{deviceId}/properties/history?{query parameters}

Request parameters

Table 1. Header Parameters
Parameter Required Type Description
Authorization Yes String The valid access token for making API calls.

The format should be Bearer {access_token}.

Table 2. Path parameters
Parameter Required Type Description
deviceId Yes Integer 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.
Table 3. Query parameters
Parameter Required Type Description
startTime No Integer Specify the start time for querying records in the format of Unix timestamp (Unit: Second).
endTime No Integer Specify the end time for querying records in the format of Unix timestamp (Unit: Second).
pageSize Yes Integer Define how many records per page.
pageKey No String

This parameter is NOT required in the first request. If the response includes a nextPageKey, it indicates additional data on the subsequent pages.

To retrieve the remaining records, include this parameter with the value of nextPageKey from previous query result in your subsequent request.

order No String Define the display order.

Valid value:

  • asc: Ascending order.
  • desc: Descending order.
Important: If no query parameters are passed, it will default to return data of all the reported properties within the last three days.

Response parameters

Parameter Type Description
data Object<Device_Info> Detailed information of the queried device.
status String The result of the API request.
  • Success
  • Failed
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 Object 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 three days.
GET /device/openapi/v1.0/devices/1739930666380779522/properties/history
Host: milesight.demo.com
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6InllYXN0b25lLWRlZmF1bHQta2V5LWlkIn0.eyJncmFudF90eXBlIjoiY2xpZW50X2NyZWRlbnRpYWxzIiwic2NvcGUiOlsib3BlbmFwaSJdLCJjbGllbnRfZXh0Ijp7ImFwcF9pZCI6IjE3MzY5NTQ4MDE3MTMzMjgxMzAifSwiZXhwIjoxNzAzMjEzMDk4LCJhdXRob3JpdGllcyI6WyJST0xFX0NMSUVOVCJdLCJqdGkiOiJiYjJjN2U4Yy03NGQwLTQ4NjEtODE3MS1iYTc0NWRlMGY0NmQiLCJjbGllbnRfaWQiOiI4OTNkNzdjNy1mMGNiLTRmMzQtOWNhMS03YzJhNGNmMTEzNDgiLCJ0cyI6MTcwMzIwOTQ5ODMzNH0
Content-Type: application/json
User-Agent: OpenAPI
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"
}