Queries devices by tag.

Limits

  • You can specify a maximum of 10 tags in a single call.
  • Each Alibaba Cloud account can run a maximum of 5 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 QueryDeviceByTags

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

Tag.N.TagKey String Yes room

The key of the device tag.

Tag.N.TagValue String Yes 101

The value of the device tag.

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.

CurrentPage Integer No 1

The number of the page to return. Default value: 1.

PageSize Integer No 10

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

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 light1

The name of each device.

IotId String Q7uOhVRdZRRlDnTLv****00100

The ID of the device. The ID is the unique identifier that is issued by IoT Platform to the device.

ProductKey String a1BwAGV****

The key of the product to which the device belongs.

ProductName String lamp

The name of the service.

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 1

The total number of entries returned.

Examples

Sample requests

https://iot.cn-shanghai.aliyuncs.com/?Action=QueryDeviceByTags
&CurrentPage=1
&PageSize=10
&Tag.1.TagKey=room
&Tag.1.TagValue=101
&Tag.2.TagKey=city
&Tag.2.TagValue=hangzhou
&<Common request parameters>

Sample success responses

XML format

<QueryDeviceByTags>
  <PageCount>1</PageCount>
  <Data>
        <SimpleDeviceInfo>
              <DeviceName>1102jichu02</DeviceName>
              <ProductKey>a1SM5S1****</ProductKey>
              <IotId>GookTiUcwqRbHosp9Ta10****3a00</IotId>
              <ProductName>TEST</ProductName>
        </SimpleDeviceInfo>
  </Data>
  <PageSize>10</PageSize>
  <Page>1</Page>
  <RequestId>2B5091E4-32D5-4884-A5B2-2E8E713D84AF</RequestId>
  <Success>true</Success>
  <Total>1</Total>
</QueryDeviceByTags>

JSON format

{
    "PageCount": 1,
    "Data": {
        "SimpleDeviceInfo": [
            {
                "DeviceName": "1102jichu02",
                "ProductKey": "a1SM5S1****",
                "IotId": "GookTiUcwqRbHosp9Ta10****3a00",
                "ProductName": "TEST"
            }
        ]
    },
    "PageSize": 10,
    "Page": 1,
    "RequestId": "2B5091E4-32D5-4884-A5B2-2E8E713D84AF",
    "Success": true,
    "Total": 1
}

Error codes

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