Queries the service call records of a specified device.

Limits

  • You can query only the service call records that are generated in the last 30 days.
    Note The storage period of a service call record is calculated from the day when the service is called.
  • Each Alibaba Cloud account can run a maximum of 500 queries per second (QPS).
    Note RAM users of an Alibaba Cloud account share the quota of the 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 QueryDeviceServiceData

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

EndTime Long Yes 1579249499000

The end of the time range to query. The value is a timestamp in milliseconds, such as 1579249499000.

StartTime Long Yes 1579249499000

The beginning of the time range to query. The value is a timestamp in milliseconds, such as 1579249499000.

IotInstanceId String No iot_instc_pu****_c*-v64********

The ID of the instance. This parameter is not required for public instances. However, the parameter is required for the instances that you have purchased.

IotId String No Q7uOhVRdZRRlDnTLv****00100

The ID of the device. The device ID is issued by IoT Platform.

Note If you specify this parameter, you do not need to specify the ProductKey or DeviceName parameter. The IotId parameter is a globally unique identifier (GUID), and corresponds to a combination of the ProductKey and DeviceName parameters. If you specify the IotId parameter and a combination of the ProductKey and DeviceName parameters at the same time, the IotId parameter is used.
ProductKey String No a1BwAGV****

The ProductKey of the product to which the device belongs.

Note If you specify this parameter, you must also specify the DeviceName parameter.
DeviceName String No light

The name of the device.

Note If you specify this parameter, you must also specify the ProductKey parameter.
Identifier String No Set

The identifier of the service. You can view the service identifier on the Define Feature tab of the IoT Platform console. You can also call the QueryThingModel operation to view the service identifier.

Asc Integer No 0

The sorting order of the returned service call records. Valid values:

  • 0: descending
  • 1: ascending
PageSize Integer No 10

The number of entries to return on each page. Maximum value: 50.

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 service call records returned if the call is successful.

List Array of ServiceInfo

The array of service call records. Each element represents a service call record.

ServiceInfo
Identifier String Set

The identifier of the service.

InputData String {\"code\":200,\"data\":{},\"id\":\"100686\",\"message\":\"success\",\"version\":\"1.0\"}

The input parameter of the service. The value is a string in the MAP format. Syntax: key:value.

Name String Set_Temperature

The name of the service.

OutputData String {\"LightAdjustLevel\":123}

The output parameter of the service. The value is a string in the MAP format. Syntax: key:value.

Time String 1579249499000

The time when the service was called.

NextTime Long 1579335899000

The start time of service call records on the next page.

If you call the QueryDeviceServiceData operation to query the service call records on the next page, you must set the StartTime parameter to the value of this parameter.

NextValid Boolean true

Indicates whether the next page exists.

  • true: The next page exists.
  • false: The next page does not exist.

If the return value of the NextValid parameter is true, you can use the value of the NextTime parameter as the value of the StartTime parameter when you query the next page of results.

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=QueryDeviceServiceData
&ProductKey=a1BwAGV****
&DeviceName=device1
&Identifier=set
&StartTime=1516538300303
&EndTime=1516541900303
&PageSize=10
&Asc=1
&<Common request parameters>

Sample success responses

XML format

<QueryDeviceServiceDataResponse>
  <Data>
        <NextValid>true</NextValid>
        <NextTime>1517315865197</NextTime>
        <List>
              <ServiceInfo>
                    <Name>set</Name>
                    <Time>1517315865198</Time>
                    <OutputData>{"code":200,"data":{},"id":"100686","message":"success","version":"1.0"}</OutputData>
                    <InputData>{"LightAdjustLevel":123}</InputData>
                    <Identifier>set</Identifier>
              </ServiceInfo>
        </List>
  </Data>
  <RequestId>A44C818E-FA7F-4765-B1E7-01D14AE01C6A</RequestId>
  <Success>true</Success>
</QueryDeviceServiceDataResponse>

JSON format

{
  "Data": {
    "NextValid": true, 
    "NextTime": 1517315865197, 
    "List": {
      "ServiceInfo": [
        {
          "Name": "set", 
          "Time": 1517315865198, 
          "OutputData": "{\"code\":200,\"data\":{},\"id\":\"100686\",\"message\":\"success\",\"version\":\"1.0\"}", 
          "InputData": "{\"LightAdjustLevel\":123}", 
          "Identifier": "set"
        }
      ]
    }
  }, 
  "RequestId": "A44C818E-FA7F-4765-B1E7-01D14AE01C6A", 
  "Success": true
}

Error codes

For a list of error codes, visit the API Error Center.