Use this operation to query the event records of a specified device.

Limits

You can query event data that was generated within the last 30 days.

Note The data of an event is stored from the day the event data was generated. Data that was generated more than 30 days ago is no longer stored.

Request parameters

Parameter Type Required Description
Action String Yes The operation that you want to perform. Set the value to QueryDeviceEventData.
IotId String No

The identifier of the device whose event records you want to query.

Note If you specify this parameter, ProductKey and DeviceName are not required. IotId is the globally unique identifier (GUID) of a device, and corresponds to the combination of ProductKey and DeviceName. If you specify both IotId and the combination of ProductKeyand DeviceName, the system follows IotId.
ProductKey String No

The product key of the device whose event records you want to query.

Note If you use this parameter, DeviceName is required.
DeviceName String No

The name of the device whose service records you want to query.

Note If you specify this parameter, you must also specify ProductKey.
EventType String No

The type of the event that you want to query. Options:

info: Information.

alert: Alert.

error: Error.

Identifier String Yes The identifier of the event. You can view the Identifier values of events in the TSL of the product on the Define Feature page in the IoT Platform console.
StartTime Long Yes The start time of event records that you want to query. The value is a 13 digit timestamp.
Note You can query event data that was generated within the last 30 days.
EndTime Long Yes The end time of event records that you want to query. The value is a 13 digit timestamp.
PageSize Integer No The number of records per page in the response. The maximum limit is 50.
Asc Integer No

The sorting order of the property records in returned results. Value options:

  • 0: In reverse chronological order.

  • 1: In chronological order.

The default value is 1.

Common request parameters - Yes See Common parameters.

Response parameters

Parameter Type Description
RequestId String The globally unique ID generated by Alibaba Cloud for the request.
Success Boolean Indicates whether the call is successful. A value of true indicates that the call is successful. A value of false indicates that the call has failed.
ErrorMessage String The error message returned when the call fails.
Code String The error code returned when the call fails. For more information about error codes, see Error codes.
Data Data The device event record returned when the call is successful. See the following table Data.
Table 1. Data
Parameter Type Description
List List<EventInfo> The collection of events. Each element represents an event. See EventInfo for element descriptions.
NextValid Boolean Indicates whether there is a next page of records. A value of true indicates there is a next page of event records, and you can call this operation again using the value of NextTime as the StartTime to query the records. A value of false indicates there is not a next page.
NextTime Long The start time of event records on the next page.
Table 2. EventInfo
Parameter Type Description
Name String Event name.
Time Long The time when the event occurred.
OutputData String The output parameters of the event. For more information about the data elements, see OutputData.
EventType String The event type.
Identifier String The event identifier.
Table 3. OutputData
Parameter Type Description
Key String Identifier of a output parameter.
Value Long Value of a output parameter.

Examples

Request example

https://iot.cn-shanghai.aliyuncs.com/?Action=QueryDeviceEventData
&IotId=abcdef1234567************
&ProductKey=al**********
&DeviceName=device1
&EventType=info
&Identifier=lightLevel
&StartTime=1516538300303L
&EndTime=1516541900303L
&PageSize=10
&Asc=1
&Common request parameters

Response example

  • JSON format

    {
      "RequestId":"57b144cf-09fc-4916-a272-a62902d5b207",
      "Success": true,
      "Data": {
        "NextValid": false,
        "NextTime": 1516449221253,
        "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"
            },
            {
              "Name": "testEventInfoName",
              "Time": "1516449221254",
              "OutputData": "{\"structArgs\":{\"structchildFLOATf71c20e\":1.23,\"structchildINT6b6b626\":3,\"structchildDATE663436a\":\"1516449212507\",\"structchildDOUBLE08d0f74\":1.23,\"structchildTEXTdc764f9\":\"a1f3583dde3944289639\",\"structchildBOOLd260729\":0,\"structchildENUMbe62590\":1},\"enumArgs\":0,\"boolArgs\":0,\"floatArgs\":2.3,\"dateArgs\":\"1516449212507\",\"intArgs\":1,\"doubleArgs\":2.3,\"textArgs\":\"1z4XNBvvA7eZw8XViaJp\"}",
              "EventType": "info",
              "Identifier": "testEventInfo"
            }
          ]
        }
      }
    }
  • XML format

    <? xml version='1.0' encoding='utf-8'? >
    <QueryDeviceEventDataResponse>
        <RequestId>57b144cf-09fc-4916-a272-a62902d5b207</RequestId>
        <Success>true</Success>
        <Data>
            <NextValid>false</NextValid>
            <NextTime>1516449221253</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>
                <EventInfo>
                    <Name>testEventInfoName</Name>
                    <Time>1516449221254</Time>
                    <OutputData>{"structArgs":{"structchildFLOATf71c20e":1.23,"structchildINT6b6b626":3,"structchildDATE663436a":"1516449212507","structchildDOUBLE08d0f74":1.23,"structchildTEXTdc764f9":"a1f3583dde3944289639","structchildBOOLd260729":0,"structchildENUMbe62590":1},"enumArgs":0,"boolArgs":0,"floatArgs":2.3,"dateArgs":"1516449212507","intArgs":1,"doubleArgs":2.3,"textArgs":"1z4XNBvvA7eZw8XViaJp"}</OutputData>
                    <EventType>info</EventType>
                    <Identifier>testEventInfo</Identifier>
                </EventInfo>
            </List>
        </Data>
    </QueryDeviceEventDataResponse>