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

You can call this API operation up to 50 times per second per account.

Note The 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 for different SDKs.

Request parameters

ParameterTypeRequiredExampleDescription
ActionStringYesQueryDeviceServiceData

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

EndTimeLongYes1579249499000

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

StartTimeLongYes1579249499000

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

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

Important
  • 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.

IotIdStringNoQ7uOhVRdZRRlDnTLv****00100

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

Important The IotId parameter specifies a GUID for the device. The value of the IotId parameter is equivalent to a combination of the values of the ProductKey and DeviceName parameters. If you specify a value for this parameter, you do not need to configure the ProductKey or DeviceName parameter. If you specify values for the IotId, ProductKey, and DeviceName parameters, the value of the IotId parameter takes precedence.
ProductKeyStringNoa1BwAGV****

The ProductKey of the product to which the device belongs.

Important If you specify a value for this parameter, you must configure the DeviceName parameter.
DeviceNameStringNolight

The DeviceName of the device.

Important If you specify a value for this parameter, you must configure the ProductKey parameter.
IdentifierStringNoSet

The identifier of the service. The identifier of the service that is called. You can view the service identifier on the Define Feature tab in 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.

AscIntegerNo.0

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

  • 0: reverse chronological order
  • 1: chronological order
PageSizeIntegerNo10

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 about common request parameters, see Common parameters.

Response parameters

ParameterTypeExampleDescription
CodeStringiot.system.SystemException

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

DataStruct

The service call records returned if the call is successful.

ListArray of ServiceInfo

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

ServiceInfo
IdentifierStringSet

The identifier of the service.

InputDataString{\"LightAdjustLevel\":123}

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

NameStringSet_Temperature

The name of the service.

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

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

TimeString1579249499000

The time when the service was called.

NextTimeLong1579335899000

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.

NextValidBooleantrue

Indicates whether the next page exists.

  • true
  • false

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.

ErrorMessageStringA system exception occurred.

The error message that is returned if the call fails.

RequestIdStringE55E50B7-40EE-4B6B-8BBE-D3ED55CCF565

The ID of the request. The ID uniquely identifies the request.

SuccessBooleantrue

Indicates whether the call was successful. Valid values:

  • 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, see Service error codes.