Queries devices by status.

Limits

  • After the status of a device changes, the new status is applied within 10 seconds. After the new status is applied, you can search for the device by using the new status. Before the new status is applied, you can search for the device by using the previous status.
  • 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 QueryDeviceByStatus

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

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

The instance ID. This parameter is not required for public instances. However, the parameter is required for the instances that you have purchased.

ProductKey String No a1BwAGV****

The key of the product to which devices belong.

Status Integer No 1

The status of devices. Valid values:

  • 0: inactive
  • 1: online
  • 3: offline
  • 8: disabled
CurrentPage Integer No 1

The number of the page to return.

PageSize Integer No 10

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

BizTenantId String No wdpznyrgac****

The ID of the tenant.

ResourceGroupId String No rg-acfm4l5tcwd***

The ID of the resource group to which the product belongs. You can view the resource group ID in the IoT Platform console.

Note If you specify this parameter, the system returns devices of the specified status in the resource group. If you do not specify this parameter, the system returns all devices of the specified status in the current account.

In addition to the preceding operation-specific request parameters, you must specify common request parameters when you call this API 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 SimpleDeviceInfo

The device list information returned if the call succeeds. The SimpleDeviceInfo parameter includes the details of the devices.

SimpleDeviceInfo
DeviceName String light

The name of each device.

DeviceSecret String sLefbFmN9SYfnWLJTePG893XNuRV****

The secret of the device.

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 modified. The time is in the GMT format.

IotId String Av8NGHGtwPrH9BYGLMBi00****

The ID of the device.

Nickname String SensorInShanghai

The alias of the device.

ProductKey String a1BwAGV****

The key of the product to which the device belongs.

Status String ONLINE

The status of the device. Valid values:

  • UNACTIVE: The device is not activated.
  • ONLINE: The device is online.
  • OFFLINE: The device is offline.
  • DISABLE: The device is disabled.
UtcCreate String 2019-02-20T02:16:09.000Z

The time when the device was created. The time is in the UTC format.

UtcModified String 2019-02-20T02:16:09.000Z

The time when the device information was last modified. The time is in the UTC format.

ErrorMessage String A system exception occurred.

The error message returned if the call fails.

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 succeeds.

  • true: The call succeeded.
  • false: The call failed.
Total Integer 2

The total number of devices returned.

Examples

Sample requests

https://iot.cn-shanghai.aliyuncs.com/?Action=QueryDeviceByStatus
&ProductKey=aldafD****
&Status=0
&PageSize=10
&CurrentPage=1
&<Common request parameters>

Sample success responses

XML format

<QueryDeviceByStatusResponse>
      <RequestId>CD9E5F99-A095-4A05-9256-D924EA3075E8</RequestId>
      <Success>true</Success>
      <CurrentPage>1</CurrentPage>
      <PageSize>10</PageSize>
      <TotalPageCount>1</TotalPageCount>
      <TotalCount>2</TotalCount>
      <Data>
            <SimpleDeviceInfo>
                  <IotId>Av8NGHGtwPrH9BYGLMBi00****</IotId>
                  <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>
                  <Status>UNACTIVE</Status>
                  <Nickname>SensorInShanghai</Nickname>
            </SimpleDeviceInfo>
            <SimpleDeviceInfo>
                  <IotId>zNIcSmWQ9BPJlmkjn3H100****</IotId>
                  <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>
                  <DeviceStatus>UNACTIVE</DeviceStatus>
                  <Nickname>DriverInShanghai</Nickname>
            </SimpleDeviceInfo>
      </Data>
</QueryDeviceByStatusResponse>

JSON format

{
  "RequestId": "CD9E5F99-A095-4A05-9256-D924EA3075E8", 
  "Success": true,  
  "CurrentPage": 1, 
  "PageSize": 10, 
  "TotalPageCount": 1,
  "TotalCount": 2,
  "Data": {
    "SimpleDeviceInfo": [
      {
        "IotId": "Av8NGHGtwPrH9BYGLMBi00****", 
        "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", 
        "Status": "UNACTIVE", 
        "Nickname": "SensorInShanghai"
      }, 
      {
        "IotId": "zNIcSmWQ9BPJlmkjn3H100****", 
        "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", 
        "DeviceStatus": "UNACTIVE", 
        "Nickname": "DriverInShanghai"
      }
    ]
  }  
}

Error codes

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