Queries devices by device status.

Request parameters

Parameter Type Required Description
Action String Yes The operation that you want to perform. Set the value to QueryDeviceByStatus.
ProductKey String Yes The key of the product to which the devices belong. It is a unique identifier issued by IoT Platform for the product.
Status Integer Yes The status of the devices. Valid values:
  • 0: inactive
  • 1: online
  • 3: offline
  • 8: disabled
PageSize Integer Yes The number of devices to return on each page. Maximum value: 50.
CurrentPage Integer Yes The page number from which the results are displayed.
IotInstanceId String No The ID of the instance. This parameter is required only for dedicated instances.
Common request parameters N/A Yes For information about common request parameters, 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 was successful. true indicates that the call was successful. false indicates that the call failed.
ErrorMessage String The error message returned if the call failed.
Code String The error code returned if the call failed. For information about error codes, see Error codes.
TotalCount Integer The total number of devices returned.
PageSize Integer The number of devices returned per page.
CurrentPage Integer The current page number.
TotalPageCount Integer The total number of pages returned.
Data Data The device information returned if the call was successful. For more information, see table SimpleDeviceInfo.
Table 1. SimpleDeviceInfo
Parameter Type Description
ProductKey String The key of the product to which the device belongs.
DeviceName String The name of the device.
DeviceSecret String The key of the device.
Nickname String The nickname of the device.
IotId String The globally unique ID issued by IoT Platform to the device.
Status String 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.
GmtCreate String The time when the device was created. The time is displayed in GMT.
GmtModified String The time when the device information was last modified. The time is displayed in GMT.
UtcCreate String The time when the device was created. The time is displayed in UTC.
UtcModified String The time when the device information was last modified. The time is displayed in UTC.

Examples

Sample request

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

Sample responses

  • 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"
          }
        ]
      }  
    }
  • XML format
    <? xml version="1.0" encoding="UTF-8" ? >
    <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>