หน้านี้ยังไม่พร้อมใช้งานในภาษาท้องถิ่นของคุณ เรากำลังพยายามอย่างหนักเพื่อเพิ่มเวอร์ชันภาษาอื่น ๆ เพิ่มเติม ขอบคุณสำหรับการสนับสนุนเสมอมา

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
Software Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Query Device List Flexibly

Updated on 2024-12-02 GMT+08:00

Function

API description

This API is used by an application to query a desired device list using SQL statements.

Constraints

  • This API is supported only by standard and enterprise editions.

  • Maximum TPS for an account to call this API: 1 (one request per second).

SQL-like syntax description

SQL-like statements include select, from, where (optional), order by (optional), and limit clauses (optional). The maximum length is 400 characters. The content in the clause is case sensitive, but keywords in SQL statements are case insensitive.

Example:

select * from device where device_id = 'as********' limit 0,5

SELECT clause

select [field]/[count(*)/count(1)] from device

field indicates the parameter to be obtained. Replace it with the response parameter name. You can also enter an asterisk (*) to obtain all parameters.

To obtain the number of queried devices, use count(*) or count(1).

FROM clause

from device

The parameter following from indicates the name of the resource to be queried. Currently, device is supported.

WHERE clause (optional)

WHERE [condition1] AND [condition2]

Up to five conditions are supported. Conditions cannot be nested. For details about the parameters that support query, see Description of query condition parameters and Supported operators.

AND and OR are supported. For details about the priority, see the standard SQL syntax. By default, the priority of AND is higher than that of OR.

LIMIT clause (optional)

limit [offset,] rows

offset indicates the query offset. rows indicates the maximum number of rows in the query result. Examples:

  • limit n ; Example: (select * from device limit 10)

Up to n records can be returned.

  • limit m,n; Example: (select * from device limit 20,10)

    The query offset is m. Up to n records can be returned.

Constraints

The maximum value of offset is 500, and the maximum value of rows is 50. If the limit clause is not specified, limit 10 is used by default.

ORDER BY clause (optional)

This clause is used for customizing sorting. Currently, the marker parameter supports custom sorting.

order by marker [asc]/[desc]

If the clause is not specified, random sorting is used by default.

Description of query condition parameters

Parameter Type Description Value Range
app_id string Resource space ID. The value can contain a maximum of 36 characters. Only letters, digits, underscores (_), and hyphens (-) are allowed.
device_id string Device ID. The value can contain a maximum of 128 characters. Only letters, digits, underscores (_), and hyphens (-) are allowed.
gateway_id string Gateway ID. The value can contain a maximum of 128 characters. Only letters, digits, underscores (_), and hyphens (-) are allowed.
product_id string ID of the product associated with the device. The value can contain a maximum of 36 characters. Only letters, digits, underscores (_), and hyphens (-) are allowed.
device_name string Device name. The value can contain a maximum of 256 characters. Only letters, digits, and special characters (_?'#(),&%@!-) are allowed.
node_id string Node ID. The value can contain a maximum of 64 characters. Only letters, digits, underscores (_), and hyphens (-) are allowed.
status string Device status. ONLINE, OFFLINE, ABNORMAL, INACTIVE, and FROZEN
node_type string Device node type. GATEWAY (directly connected device or gateway) and ENDPOINT (indirectly connected device)
tag_key string Tag key. The value can contain a maximum of 64 characters. Only letters, digits, underscores (_), periods (.), and hyphens (-) are allowed.
tag_value string Tag value. The value can contain a maximum of 128 characters. Only letters, digits, underscores (_), periods (.), and hyphens (-) are allowed.
sw_version string Software version. The value can contain a maximum of 64 characters. Only letters, digits, underscores (_), periods (.), and hyphens (-) are allowed.
fw_version string Firmware version. The value can contain a maximum of 64 characters. Only letters, digits, underscores (_), periods (.), and hyphens (-) are allowed.
group_id string Group ID. The value can contain a maximum of 36 characters. Only hexadecimal characters and hyphens (-) are allowed.
create_time string Device registration time. Format: yyyy-MM-dd'T'HH:mm:ss.SSS'Z'. Example: 2015-06-06T12:10:10.000Z
connection_status_update_time string Time when the device connection status last changed. Format: yyyy-MM-dd'T'HH:mm:ss.SSS'Z', for example, 2015-06-06T12:10:10.000Z
marker string Result record ID. The value is a string of 24 hexadecimal characters. Example: ffffffffffffffffffffffff

Supported operators

Operator Parameter that Support the Operator
= All
!= All
> create_time, marker, connection_status_update_time
< create_time, marker, connection_status_update_time
like device_name, node_id, tag_key, and tag_value
in Fields except tag_key and tag_value
not in Fields except tag_key and tag_value

SQL restrictions

  • like: Only prefix match is supported. Suffix match or wildcard match is not supported. At least four characters must be contained for prefix match. Special characters cannot be contained. Only letters, digits, underscores (_), and hyphens (-) are allowed. The prefix must end with percent signs (%).

  • Only count(*) or count(1) is supported.

  • Other SQL statements, such as nested SQL statements, union, join, and alias, are not supported.

  • The SQL statement can contain up to 400 characters. Up to five request conditions are supported.

  • The condition value cannot be null or an empty string.

Debugging

You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.

URI

POST /v5/iot/{project_id}/search/query-devices

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Parameter description: project ID. For details about how to obtain the project ID, see Obtaining a Project ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

No

String

Parameter description: user token. You can obtain the token by calling the IAM API Obtaining a User Token Through Password Authentication. X-Subject-Token in the response header returned by the API is the desired user token. For details about how to obtain the token, see Token Authentication.

Instance-Id

No

String

Parameter description: instance ID. Unique identifier of each instance in the physical multi-tenant scenario. Mandatory for professional editions and recommended in other cases. Log in to the IoTDA console and choose Overview in the navigation pane to view the instance ID. For details, see Viewing Instance Details.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

sql

Yes

String

SQL statement. For details, see the SQL-like syntax description.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

devices

Array of SearchDevice objects

Device query result list.

count

Long

Total number of records that meet query conditions. This parameter is returned only when select count(*)/count(1) is used.

Table 5 SearchDevice

Parameter

Type

Description

app_id

String

Resource space ID.

app_name

String

Resource space name.

device_id

String

Device ID, used to uniquely identify a device. The value of this parameter is specified during device registration or allocated by the platform. If the value is allocated by the platform, the value is in the format of [product_id]_[node_id].

node_id

String

Device identifier. This parameter is set to the IMEI, MAC address, or serial number.

gateway_id

String

Gateway ID, which is the device ID of the parent device. The gateway ID is the same as the device ID if the device is a directly connected device. If the device is an indirectly connected device, the gateway ID is the device ID of the directly connected device with which it associates.

device_name

String

Device name.

node_type

String

Device node type.

  • ENDPOINT: an indirectly connected device.

  • GATEWAY: a directly connected device or gateway.

  • UNKNOWN: The device node type is unknown.

fw_version

String

Firmware version of the device.

sw_version

String

Software version of the device.

device_sdk_version

String

Device SDK information.

product_id

String

Unique ID of the product associated with the device.

product_name

String

Name of the product associated with the device.

groups

Object

Device group list.

status

String

Device status.

  • ONLINE: The device is online.

  • OFFLINE: The device is offline.

  • ABNORMAL: The device is abnormal.

  • INACTIVE: The device is not activated.

  • FROZEN: The device is frozen.

tags

Object

List of device tags.

marker

String

Query result record ID.

Example Requests

Runs the SQL statement to query all devices.

POST https://{endpoint}/v5/iot/{project_id}/search/query-devices

{
  "sql" : "select * from device"
}

Example Responses

Status code: 200

OK

{
  "devices" : [ {
    "app_id" : "jeQDJQZltU8iKgFFoW060F5SGZka",
    "marker" : "5c8f3d2d3df1f10d803adbda",
    "device_id" : "d4922d8a-6c8e-4396-852c-164aefa6638f",
    "node_id" : "ABC123456789",
    "gateway_id" : "d4922d8a-6c8e-4396-852c-164aefa6638f",
    "device_name" : "dianadevice",
    "node_type" : "ENDPOINT",
    "fw_version" : "1.1.0",
    "sw_version" : "1.1.0",
    "device_sdk_version" : "1.1.0",
    "product_id" : "b640f4c203b7910fc3cbd446ed437cbd",
    "status" : "ONLINE",
    "tags" : [ {
      "tag_key" : "testTagName",
      "tag_value" : "testTagValue"
    } ]
  } ]
}

Status Codes

Status Code

Description

200

OK

400

Bad Request

401

Unauthorized

403

Forbidden

500

Internal Server Error

Error Codes

See Error Codes.

เราใช้คุกกี้เพื่อปรับปรุงไซต์และประสบการณ์การใช้ของคุณ การเรียกดูเว็บไซต์ของเราต่อแสดงว่าคุณยอมรับนโยบายคุกกี้ของเรา เรียนรู้เพิ่มเติม

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback