Queries the event records of a specified device.
Usage notes
You can query only the event records that are generated in the previous 30 days.
QPS limits
Each Alibaba Cloud account can run up to 50 queries per second (QPS).
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | QueryDeviceEventData | The operation that you want to perform. Set the value to QueryDeviceEventData. |
EndTime | Long | Yes | 1516541900303 | The end of the time range to query. The value is a 13-digit timestamp in milliseconds. Example: 1516541900303. |
StartTime | Long | Yes | 1516541900303 | The beginning of the time range to query. The value is a 13-digit timestamp in milliseconds. Example: 1516538300303. Note You can query the event data only of the most recent 30 days. |
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. Important
For more information, see Overview. |
PageSize | Integer | No | 10 | The number of entries to return on each page. Valid values: 1 to 50. Default value: 10. |
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 | PowerOff | The identifier of the event that you want to query. You can view the event identifier on the Define Feature tab of the Product Details page in the IoT Platform console. You can also call the QueryThingModel operation and view the event identifier in the returned TSL data. Note If the PowerOff event belongs to a custom module named testFb, this parameter is set to testFb:PowerOff. If you do not specify this parameter, the system queries all event data of the default module. |
EventType | String | No | info | The type of the event that you want to query. Valid values:
|
Asc | Integer | No | 0 | The order in which you want to sort the returned event records. Valid values:
Note If you do not configure this parameter, the default value 0 is used. The system sorts the returned event records in reverse chronological order. |
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. |
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 event records returned if the call succeeds. | |
List | Array of EventInfo | The array of events. Each element represents an event. | |
EventInfo | |||
EventType | String | info | The type of the event. Valid values:
|
Identifier | String | PowerOff | The identifier of the event. |
Name | String | Device shutdown | The name of the event. |
OutputData | String | null | 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 timestamp in milliseconds. |
NextTime | Long | 1579163099000 | The start time of the event records on the next page. The value is a timestamp in milliseconds.
|
NextValid | Boolean | true | Indicates whether the next page exists.
|
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.
|
Examples
Sample requests
https://iot.cn-shanghai.aliyuncs.com/?Action=QueryDeviceEventData
&IotId=abcdef1234567************
&ProductKey=al**********
&DeviceName=device1
&EventType=info
&Identifier=lightLevel
&StartTime=1516538300303
&EndTime=1516541900303
&PageSize=10
&Asc=1
&<Common request parameters>
Sample success responses
XML
format
<QueryDeviceEventDataResponse>
<Data>
<NextValid>false</NextValid>
<NextTime>1579249151177</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>
</QueryDeviceEventDataResponse>
JSON
format
{
"Data": {
"NextValid": false,
"NextTime": 1579249151177,
"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.