Queries the event records that are submitted by a specified device. These records include events that are verified and not verified by a specified Thing Specification Language (TSL) model.

Limits

  • You can query only the event records that are generated in the last 30 days.
Note The storage period of an event record is calculated from the day when the record is generated.
  • Each Alibaba Cloud account can run a maximum of 50 queries per second (QPS).
    Note Resource Access Management (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 QueryDeviceOriginalEventData

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

Asc Integer Yes 0

The sorting order of the returned event records. Value values:

  • 0: descending.
  • 1: ascending.
EndTime Long Yes 1516541900303

The end of the time range to query. The value is a 13-digit timestamp in milliseconds.

Identifier String Yes PowerOff

The event identifier that you want to query.

  • If low-level verification is applied, you can perform the following steps to view the Identifier of a device event: Log on to the IoT Platform console and go to the Define Feature tab of the Product Details page. You can also call the QueryThingModel operation and view the service identifier in the returned TSL data.
  • If no verification is applied, the value must be the same as the value of the custom identifier that is submitted by the device.
PageSize Integer Yes 10

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

StartTime Long Yes 1516538300303

The start of the time range to query. The value is a 13-digit timestamp in milliseconds.

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

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 set this parameter, the call fails.
  • If your instance has no Overview page or ID, you do not need to set this parameter.

For more information, see Overview.

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.
NextPageToken String No Bo***x44Qx

The identifier of the next page. If the next page exists, this parameter is returned. In this case, you must add the value of the parameter to the next request.

IotId String No Q7uOhVRdZRRlDnTLv****00100

The ID of the device. It is the unique identifier that IoT Platform generated for the device.

Note If you specify this parameter, you do not need to specify the ProductKey or DeviceName parameter. The IotId parameter specifies a unique identifier for the device, and corresponds to a combination of the ProductKey and DeviceName parameters. If you specify the IotId parameter and the combination of the ProductKey and DeviceName parameters at the same time, only the IotId parameter is used.

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

Response parameters

Parameter Type Example Description
Code String iot.device.InvalidIoTId

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

Data Struct

The event records returned if the call succeeds.

List Array of EventInfo

The array of events. Each element represents an event. For more information about the details of the event, see the parameters of the EventInfo parameter.

EventInfo
EventType String info

The type of the event. Valid values:

  • info: information.
  • alert: alert.
  • error: error.
Identifier String PowerOff

The identifier of the event.

Name String Device shutdown

The name of the event.

OutputData String {"structArgs":{"structchildFLOATf71c20e":1.23}}

The output parameter of the event. The value is a string in the MAP format.

Time String 1579163099000

The time when the event occurred. The value is a 13-digit timestamp in milliseconds.

NextPageToken String Bo***x44Qx

The identifier of the next page.

NextValid Boolean true

Indicates whether the next page exists.

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

If the value true is returned, you can add the value of the NextPageToken parameter to the next request. This allows you to query the data that is not included in the current query.

ErrorMessage String A system exception has 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 succeeds.

  • true: The call succeeded.
  • false: The call failed.

Examples

Sample requests

http(s)://iot.cn-shanghai.aliyuncs.com/? Action=QueryDeviceOriginalEventData
&Asc=0
&EndTime=1516541900303
&Identifier=PowerOff
&PageSize=10
&StartTime=1516538300303
&<Common request parameters>

Sample success responses

XML format

<QueryDeviceOriginalEventDataResponse>
  <Data>
        <NextValid>false</NextValid>
        <NextTime>Bo***x44Qx</NextTime>
        <List>
              <EventInfo>
                    <Name>testEventInfoName</Name>
                    <Time>1516517974638</Time>
                    <OutputData>{"structArgs":{"structchildFLOATf71c20e":1.23,"structchildINT6b6b626":3,"structchildDATE663436a":"1516517966152","structchildDOUBLE08d0f74":1.23,"structchildTEXTdc764f9":"07b68264b0ba42c18e5f","structchildBOOLd260729":0,"structchildENUMbe62590":1},"enumArgs":0,"boolArgs":0,"floatArgs":2.3,"dateArgs":"1516517966152","intArgs":1,"doubleArgs":2.3,"textArgs":"dV56zbkzjBjw1Ti1dA52"}</OutputData>
                    <EventType>info</EventType>
                    <Identifier>testEventInfo</Identifier>
              </EventInfo>
        </List>
  </Data>
  <RequestId>45391E10-446B-4986-863E-1BA8CC44748F</RequestId>
  <Success>true</Success>
</QueryDeviceOriginalEventDataResponse>

JSON format

{
  "Data": {
    "NextValid": false, 
    "NextPageToken": "Bo***x44Qx", 
    "List": {
      "EventInfo": [
        {
          "Name": "testEventInfoName", 
          "Time": 1516517974638, 
          "OutputData": "{\"structArgs\":{\"structchildFLOATf71c20e\":1.23,\"structchildINT6b6b626\":3,\"structchildDATE663436a\":\"1516517966152\",\"structchildDOUBLE08d0f74\":1.23,\"structchildTEXTdc764f9\":\"07b68264b0ba42c18e5f\",\"structchildBOOLd260729\":0,\"structchildENUMbe62590\":1},\"enumArgs\":0,\"boolArgs\":0,\"floatArgs\":2.3,\"dateArgs\":\"1516517966152\",\"intArgs\":1,\"doubleArgs\":2.3,\"textArgs\":\"dV56zbkzjBjw1Ti1dA52\"}", 
          "EventType": "info", 
          "Identifier": "testEventInfo"
        }
      ]
    }
  }, 
  "RequestId": "45391E10-446B-4986-863E-1BA8CC44748F", 
  "Success": true
}

Error codes

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