SearchThings

更新时间: 2024-05-13 11:39:02

使用该接口,按指定过滤条件搜索设备。

请求语法

POST /2020-04-30/things/search HTTP/1.1
Cookie: Cookie

Payload
重要 其中,2020-04-30是边缘端OpenAPI的版本号,请勿修改。

请求参数

参数名称类型是否必选描述
CookieString调用CreateAuthCookie接口创建的认证Cookie。
PayloadJSONJSON格式字符串。当前仅支持按标签搜索设备,可设置多个标签,搜索同时满足所有标签的设备。

格式请见表格下方请求Payload格式。

请求Payload格式如下所示。

{
  "Tags": {
    "Key1": "value1",
    "Key2": "value2"
    ...
  }
}

返回语法

HTTP/1.1 StatusCode
Content-Type: application/json

Payload

返回参数

参数名称类型描述
StatusCodeNumberHTTP状态码。返回200表示成功,返回其它状态码表示失败。错误码详情,请参见状态码
PayloadJSON搜索到的设备信息。

返回Payload格式如下所示。

{   
    "Data": {
      "Things": [{
        "ProductName": "string",
        "ProductKey": "string",
        "DeviceName": "string",
        "DriverId": "string",
        "DriverName": "string",
        "Tags": [{"Key1": "Value1"}],
        "Status": "Inactivated|Failed|Online|Offline",
        "Connected": true|false,
        "ConnectTime": "string"
      }]
    }
  }

完整示例

$ curl -i -b token.cookie -d '{"Tags":{"Name":"LightSensor"}}' -k -X POST https://127.0.0.1:9999/2020-04-30/things/search

HTTP/1.1 200 OK
Server: openresty/1.13.6.2
Date: Wed, 22 Apr 2020 15:18:16 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive

{"Data":{"Things":[{"DriverName":"LightSensor","Status":"Online","NickName":"","DriverId":"e0bb1b48964e4519b4a52f9b****1dd3","ProductKey":"a1t****n42K","Connected":true,"ConnectTime":"1587526047107","DeviceName":"test","ProductName":"","Tags":{"Name":"LightSensor"}}]}}
上一篇: ListThings 下一篇: GetThingProperties
阿里云首页 物联网边缘计算 相关技术圈