Queries the devices of a product.
Description
The QueryDevice operation can return up to one million devices each time you call the operation.
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 Alibaba Cloud account.
If the product of the value of the CurrentPage parameter and the value of the PageSize parameter is greater than or equal to 100,000, the queries per second (QPS) of this operation decreases.
In this case, you can call this API operation up to two times per second per account.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | QueryDevice | The operation that you want to perform. Set the value to QueryDevice. |
ProductKey | String | Yes | a1BwAGV**** | The ProductKey of the product to which the device belongs. |
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. |
CurrentPage | Integer | No | 1 | The number of the page to return. Default value: 1. |
NextToken | String | No | TGlzdFJlc291cm*** | The token that is used to retrieve the next page of the query results. The first time you perform a query operation, you do not need to configure this parameter. You must specify the token that is obtained from the previous query for the NextToken parameter. If the product of the value of the PageSize parameter and the value of the CurrentPage parameter is greater than 10,000, you must configure the NextToken parameter. Otherwise, data cannot be returned. Important If you configure the NextToken parameter, the product of the value of the PageSize parameter and the value of the CurrentPage parameter must be less than 1,000,000. Otherwise, data cannot be returned. |
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
Parameter | Type | Example | Description |
---|---|---|---|
Code | String | iot.system.SystemException | The error code returned if the call fails. For more information, see Error codes. |
Data | Array of DeviceInfo | The device information returned if the call is successful. The details of the devices are included in the DeviceInfo parameter. Note The returned device information is sorted in reverse chronological order based on the time when the devices were created. | |
DeviceInfo | |||
DeviceId | String | dwnS41bhNxjslDAI**** | The ID of the device. Note This parameter is deprecated. Do not use this parameter to identify a device. You can use the IotId parameter or a combination of the ProductKey and DeviceName parameters to identify a device. |
DeviceName | String | light | The name of the device. |
DeviceSecret | String | sLefbFmN9SYfnWLJTePG893XNuRV**** | The DeviceSecret of the device. |
DeviceStatus | String | ONLINE | The status of the device. Valid values:
|
DeviceType | String | Lighting | The category of the product to which the device belongs. Note This parameter is not returned. |
GmtCreate | String | Wed, 20-Feb-2019 02:16:09 GMT | The time when the device was created. The time is in the GMT format. |
GmtModified | String | Wed, 20-Feb-2019 02:16:09 GMT | The time when the device information was last updated. The time is in the GMT format. |
IotId | String | Q7uOhVRdZRRlDnTLv****00100 | The ID of the device. The ID is a unique identifier that is issued by IoT Platform to the device. |
Nickname | String | Smart light | The alias of the device. |
ProductKey | String | a1BwAGV**** | The ProductKey of the product to which the device belongs. |
UtcCreate | String | 2019-02-20T02:16:09.000Z | The time when the device was created. The time is displayed in UTC. |
UtcModified | String | 2019-02-20T02:16:09.000Z | The time when the device information was last updated. The time is displayed in UTC. |
ErrorMessage | String | A system exception occurred. | The error message returned if the call fails. |
NextToken | String | TGlzdFJlc291cm*** | The token that is used to retrieve the subsequent page of the query results. You can specify this parameter in the subsequent query to obtain the next page of results. If the NextToken parameter is empty, no subsequent page exists. |
Page | Integer | 1 | The page number of the returned page. |
PageCount | Integer | 1 | The total number of pages returned. |
PageSize | Integer | 10 | The number of entries returned per page. |
RequestId | String | E55E50B7-40EE-4B6B-8BBE-D3ED55CCF565 | The ID of the request. |
Success | Boolean | true | Indicates whether the call was successful. Valid values:
|
Total | Integer | 2 | The total number of devices. |
Examples
Sample requests
https://iot.cn-shanghai.aliyuncs.com/?Action=QueryDevice
&ProductKey=aldafD****
&PageSize=10
&CurrentPage=1
&<Common request parameters>
Sample success responses
XML
format
<QueryDeviceResponse>
<PageCount>1</PageCount>
<NextToken>TGlzdFJlc291cm***</NextToken>
<Data>
<DeviceInfo>
<DeviceId>Av8NGHGtwPrH9BYG****</DeviceId>
<DeviceName>Av8NGHGtwPrH9BYGLMBi</DeviceName>
<ProductKey>a1dafDE****</ProductKey>
<DeviceSecret>d7GYhf5hfcPHDe1bXSd3n9MjO1G3****</DeviceSecret>
<UtcModified>2019-02-20T02:16:09.000Z</UtcModified>
<GmtCreate>Wed, 20-Feb-2019 02:16:09 GMT</GmtCreate>
<UtcCreate>2019-02-20T02:16:09.000Z</UtcCreate>
<GmtModified>Wed, 20-Feb-2019 02:16:09 GMT</GmtModified>
<IotId>Av8NGHGtwPrH9BYGLMBi00****</IotId>
<DeviceStatus>UNACTIVE</DeviceStatus>
<Nickname>SensorInShanghai</Nickname>
</DeviceInfo>
<DeviceInfo>
<DeviceId>zNIcSmWQ9BPJlmkj****</DeviceId>
<DeviceName>zNIcSmWQ9BPJlmkjn3H1</DeviceName>
<ProductKey>a1dafDE****</ProductKey>
<DeviceSecret>C27XXmC18yLIEDXvUj6FSlvgO7ag****</DeviceSecret>
<UtcModified>2019-02-20T02:16:09.000Z</UtcModified>
<GmtCreate>Wed, 20-Feb-2019 02:16:09 GMT</GmtCreate>
<UtcCreate>2019-02-20T02:16:09.000Z</UtcCreate>
<GmtModified>Wed, 20-Feb-2019 02:16:09 GMT</GmtModified>
<IotId>zNIcSmWQ9BPJlmkjn3H100****</IotId>
<DeviceStatus>UNACTIVE</DeviceStatus>
<Nickname>DriverInShanghai</Nickname>
</DeviceInfo>
</Data>
<Page>1</Page>
<PageSize>10</PageSize>
<RequestId>CD9E5F99-A095-4A05-9256-D924EA3075E8</RequestId>
<Success>true</Success>
<Total>2</Total>
</QueryDeviceResponse>
JSON
format
{
"PageCount": 1,
"NextToken":"TGlzdFJlc291cm***",
"Data": {
"DeviceInfo": [
{
"DeviceId": "Av8NGHGtwPrH9BYG****",
"DeviceName": "Av8NGHGtwPrH9BYGLMBi",
"ProductKey": "a1dafDE****",
"DeviceSecret": "d7GYhf5hfcPHDe1bXSd3n9MjO1G3****",
"UtcModified": "2019-02-20T02:16:09.000Z",
"GmtCreate": "Wed, 20-Feb-2019 02:16:09 GMT",
"UtcCreate": "2019-02-20T02:16:09.000Z",
"GmtModified": "Wed, 20-Feb-2019 02:16:09 GMT",
"IotId": "Av8NGHGtwPrH9BYGLMBi00****",
"DeviceStatus": "UNACTIVE",
"Nickname": "SensorInShanghai"
},
{
"DeviceId": "zNIcSmWQ9BPJlmkj****",
"DeviceName": "zNIcSmWQ9BPJlmkjn3H1",
"ProductKey": "a1dafDE****",
"DeviceSecret": "C27XXmC18yLIEDXvUj6FSlvgO7ag****",
"UtcModified": "2019-02-20T02:16:09.000Z",
"GmtCreate": "Wed, 20-Feb-2019 02:16:09 GMT",
"UtcCreate": "2019-02-20T02:16:09.000Z",
"GmtModified": "Wed, 20-Feb-2019 02:16:09 GMT",
"IotId": "zNIcSmWQ9BPJlmkjn3H100****",
"DeviceStatus": "UNACTIVE",
"Nickname": "DriverInShanghai"
}
]
},
"Page": 1,
"PageSize": 10,
"RequestId": "CD9E5F99-A095-4A05-9256-D924EA3075E8",
"Success": true,
"Total": 2
}
Error codes
For a list of error codes, see Service error codes.