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 RAM users of an Alibaba Cloud account share the quota of the account.

Debugging

Alibaba Cloud provides OpenAPI Explorer to simplify API usage. 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 ID of the instance. You can view the instance ID on the Overview page in the IoT Platform console.

Notice
  • If your instance has an ID, you must configure this parameter. If you do not set this parameter, the call fails.
  • If your instance has no Overview page or ID, you do not need to set this parameter.

For more information, see Overview.

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. Maximum value: 50. Default value: 10.

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 SimpleDeviceInfo

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

SimpleDeviceInfo
DeviceName String light1

The DeviceName of the 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 ProductKey of the product to which the device belongs.

ProductName String lamp

The name of the product.

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.

PageSize Integer 10

The number of entries returned on each 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 1

The total number of records.

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.