Queries the data of a property in a device or a digital twin node within a specified period of time.

Usage notes

If a device or a digital twin node has multiple properties, you can call this operation to query the data of the properties multiple times. You must specify a value for the Identifier parameter each time you call the operation. You can also call the QueryDevicePropertiesData operation and specify multiple values for the Identifier parameter to query the data of the properties.

Limits

You can query only property data that is generated within the previous 30 days.

Note The data of a property is stored from the day when the data is generated.

QPS limits

Each Alibaba Cloud account can run up to 50 queries per second (QPS).

Note The RAM users of an Alibaba Cloud account share the quota of the Alibaba Cloud account.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes QueryDevicePropertyData

The operation that you want to perform. Set the value to QueryDevicePropertyData.

EndTime Long Yes 1579249499000

The end of the time range to query. The value of the EndTime parameter must be greater than the value of the StartTime parameter. The value is a timestamp in milliseconds, for example, 1579249499000.

Asc Integer Yes 0

The order in which you want to sort the property records that are returned. Valid values:

  • 0: reverse chronological order
  • 1: chronological order
Identifier String Yes temperature

The identifier of the property that you want to query.

You can view the property identifier on the Define Feature tab of the Product Details page in the IoT Platform console. You can also call the QueryThingModel operation and view the property identifier in the returned TSL data.

Note If a property named temperature belongs to a custom module named testFb, set this parameter to testFb:temperature. The custom module is not the default module.
PageSize Integer Yes 10

The number of entries to return on each page. Valid values: 1 to 50.

StartTime Long Yes 1579249499000

The start of the time range to query. The value of the StartTime parameter must be less than the value of the EndTime parameter. The value is a timestamp in milliseconds, for example, 1579249499000.

IotInstanceId String No iot-cn-0pp1n8t****

The ID of the instance. You can view the instance ID on the Overview page in the IoT Platform console.

Notice
  • If your instance has an ID, you must configure this parameter. If you do not configure this parameter, the call fails.
  • If your instance has no Overview page or ID, you do not need to configure this parameter.

For more information, see Overview.

IotId String No Q7uOhVRdZRRlDnTLv****00100

The ID of the device to which the property belongs.:

You can call the QueryDeviceInfo operation to query the ID of the device.

Notice

If you specify a value for this parameter, you do not need to specify a value for the ProductKey or DeviceName parameter. The IotId parameter specifies a globally unique identifier (GUID) for the device. The value of the IotId parameter corresponds to a combination of the values of the ProductKey and DeviceName parameters. If you specify a value for the IotId parameter and values for the ProductKey and DeviceName parameters, the value of the IotId parameter takes precedence.

ProductKey String No a1BwAGV****

The ProductKey of the product to which the device belongs.

Notice

If you specify a value for this parameter, you must also specify a value for the DeviceName parameter.

DeviceName String No airconditioning

The name of the device.

Notice

If you specify a value for this parameter, you must also specify a value for the ProductKey parameter.

In addition to the preceding operation-specific request parameters, you must specify common request parameters when you call this operation. For more information, see Common request parameters.

Response parameters

Parameter Type Example Description
Code String iot.system.SystemException

The error code returned if the call fails. For more information, see Error codes.

Data Struct

The property data returned if the call is successful.

List Array of PropertyInfo

The list of property records.

PropertyInfo
Time String 1516541885630

The time when the property was modified.

Value String 2

The value of the property.

NextTime Long 1579249499000

The start time of the property records on the next page.

  • If the Asc parameter is set to 0, you can specify this value for the EndTime parameter when you call this operation again to query the next page of property records.
  • If the Asc parameter is set to 1, you can specify this value for the StartTime parameter when you call this operation again to query the next page of property records.
NextValid Boolean true

Indicates whether the next page exists.

  • true: The next page exists. If the return value of the NextValid parameter is true, the value of the NextTime parameter is returned. For more information, see the description of the NextTime parameter in this topic.
  • false: The next page does not exist.
ErrorMessage String A system exception occurred.

The error message returned if the call fails.

RequestId String E55E50B7-40EE-4B6B-8BBE-D3ED55CCF565

The ID of the request.

Success Boolean true

Indicates whether the call was successful.

  • true: The call was successful.
  • false: The call failed.

Examples

Sample requests

https://iot.cn-shanghai.aliyuncs.com/?Action=QueryDevicePropertyData
&ProductKey=a1BwAGV****
&DeviceName=device1
&Identifier=lightLevel
&StartTime=1516538300303
&EndTime=1516541900303
&PageSize=10
&Asc=1
&<Common request parameters>

Sample responses

XML format

<QueryDevicePropertyDataResponse>
  <Data>
        <NextValid>false</NextValid>
        <NextTime>1579249151177</NextTime>
        <List>
              <PropertyInfo>
                    <Value>32.46</Value>
                    <Time>1579249151178</Time>
              </PropertyInfo>
        </List>
  </Data>
  <RequestId>45391E10-446B-4986-863E-1BA8CC44748F</RequestId>
  <Success>true</Success>
</QueryDevicePropertyDataResponse>

JSON format

{
  "Data": {
    "NextValid": false, 
    "NextTime": 1579249151177, 
    "List": {
      "PropertyInfo": [
        {
          "Value": "32.46", 
          "Time": 1579249151178
        }
      ]
    }
  }, 
  "RequestId": "45391E10-446B-4986-863E-1BA8CC44748F", 
  "Success": true
}