Queries all the devices of a product.

Limits

  • Each Alibaba Cloud account can run a maximum of 50 queries per second (QPS).
    Note RAM users of an Alibaba Cloud account share the quota of the account.
  • If the value of the CurrentPage parameter multiplied by the value of the PageSize parameter equals a value greater than or equal to 100,000, the QPS of this operation decreases.

    In this case, each Alibaba Cloud account can run a maximum of 2 QPS.

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 a sample code of the operation for different SDKs.

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 do not need to specify this parameter.

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 results. You do not need to specify this parameter for the first query. You must specify the token that is obtained from the previous query as the value of the NextToken parameter.

If the value of the PageSize parameter multipled by the value of the CurrentPage parameter is greater than 10,000, you must specify the NextToken parameter. Otherwise, data cannot be returned.

Notice

If you specify the NextToken parameter, the value of the PageSize parameter multipled by the value of the CurrentPage parameter must be less than 500,000. Otherwise, data cannot be returned.

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 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 (expired).

Note This parameter is no longer used. 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 DeviceName of the device.

DeviceSecret String sLefbFmN9SYfnWLJTePG893XNuRV****

The DeviceSecret of the device.

DeviceStatus String ONLINE

The status of the device. Valid values:

  • ONLINE: The device is online.
  • OFFLINE: The device is offline.
  • UNACTIVE: The device is not activated.
  • DISABLE: The device is disabled.
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 displayed in UTC.

GmtModified String Wed, 20-Feb-2019 02:16:09 GMT

The last time when the device information was updated. The time is displayed in UTC.

IotId String Q7uOhVRdZRRlDnTLv****00100

The ID of the device. The device ID is the unique identifier that IoT Platform generated for 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 next page of results. You can specify this parameter in the next query to obtain the next page of results.

If the NextToken parameter is empty, no next page exists.

Page Integer 1

The page number of the returned page.

PageCount Integer 1

The total number of pages.

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.

  • true: The call was successful.
  • false: The call failed.
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 response

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, visit the API Error Center.