Queries the service call records of a specified device.

Usage notes

You can query only the service call records of the previous 30 days.

Note The storage period of a service call record is calculated from the day when the service is called.

QPS limits

Each Alibaba Cloud account can run up to 500 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 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. Unit: milliseconds. Example: 1579249499000.

StartTime Long Yes 1579249499000

The beginning of the time range to query. The value is a timestamp. Unit: milliseconds. Example: 1579249499000.

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

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

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

For more information, see Overview.

IotId String No Q7uOhVRdZRRlDnTLv****00100

The ID of the device. The ID is a unique identifier that is issued by IoT Platform to the device.

Note 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.

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

The DeviceName of the device.

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

The identifier of the service. The identifier of the service that is called. 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.

Note If a service named testService belongs to a custom module named testFb, you can set this parameter to testFb:testService. The custom module is not the default module.

If you do not specify a value for this parameter, the system queries all service data of the default module and custom modules.

Asc Integer No 0

The order in which the returned service call records are sorted. Valid values:

  • 0: reverse chronological order
  • 1: chronological order
PageSize Integer No 10

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

In addition to the preceding operation-specific request parameters, you must configure 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 succeeds.

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 request 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
}