Skip to content

设备管理

设备创建

请求URL

https://www.thingshub.com.cn/openapi/v2/device/save

方法

POST

Content-Type

application/www-x-form-urlencoded

请求参数

参数 数据类型 必填 说明
productKey string ProductKey
deviceName string DeviceName
originalDeviceCode string 厂商给设备的编码
remark string 备注名称
longitude string 位置经度
latitude string 位置纬度
addr string 部署位置
meta string 描述设备的元数据 json格式
username string 连接username
secret string 连接密钥
clientId string 连接Clientid

响应参数

参数 数据类型 必填 说明
code int 返回码
msg string 返回消息
data object 返回数据
+id int 设备ID
+productId int 产品ID
+productKey string ProductKey
+deviceName string DeviceName
+clientId string 连接MQTT需要clientId
+username string 连接MQTT需要username
+deviceSecret string 连接MQTT需要password
+status string 设备状态

响应样例

{
  "code": 200,
  "msg": "success",
  "data": {
    "id": 0,
    "productKey": "",
    "productId": 0,
    "deviceName": "",
    "clientId": "",
    "deviceSecret": "",
    "status": "INACTIVE",
    "username": ""
  }
}

设备列表查询

请求URL

https://www.thingshub.com.cn/openapi/v2/device/list

方法

GET

Content-Type

application/x-www-form-urlencoded

请求参数

参数 数据类型 必填 说明
pageNumber int 页号
pageSize int 页大小
productKey string ProductKey
deviceName string DeviceName
remark string 备注名
projectId int 项目ID

响应参数

参数 数据类型 必填 说明
code int 返回码
msg string 返回消息
data object 返回数据
+total int 总记录数
+records array 设备列表
++projectId int 项目ID
++projectName string 项目名称
++productId int 产品ID
++productKey string ProductKey
++productName string 产品名称
++deviceId int 设备ID
++deviceName string DeviceName
++status string 设备在线状态
++lastTime string 状态变更时间
++nodeType string 节点类型
++username string MQTT username
++clientId string MQTT clientid
++deviceSecret string MQTT password
++createTime string 创建时间
++remark string 备注名称

样例

{
  "code": 200,
  "msg": "success",
  "data": {
    "total": 18,
    "records": [
      {
        "deviceId": 0,
        "deviceName": "gateway001",
        "createTime": "2019-06-19 15:17:29",
        "remark": "测试软网关",
        "deviceSecret": "",
        "status": "ONLINE",
        "lastTime": "2025-06-12 10:18:38",
        "productId": 0,
        "productKey": "",
        "productName": "智慧办公嵌入式网关",
        "userId": "",
        "projectId": 0,
        "projectName": "",
        "nodeType": "网关",
        "username": "",
        "clientId": "",
        "subDeviceCount": 1
      },
      {
        "deviceId": 0,
        "deviceName": "",
        "createTime": "2024-07-24 08:46:03",
        "remark": "电灯1005",
        "deviceSecret": "",
        "status": "OFFLINE",
        "lastTime": "2025-03-04 11:37:46",
        "productId": 0,
        "productKey": "",
        "productName": "智能电灯",
        "userId": "",
        "projectId": 0,
        "projectName": "",
        "nodeType": "设备",
        "username": "",
        "clientId": "",
        "subDeviceCount": 0
      }
    ]
  }
}

设备详情查询

请求URL

https://www.thingshub.com.cn/openapi/v2/device/detail

方法

GET

请求参数

参数 数据类型 必填 备注
productKey string ProductKey
deviceName string DeviceName

响应参数

参数 数据类型 必填 备注
code int 返回码
msg string 返回消息
data object 返回数据
+deviceId int 设备ID
+deviceName string DeviceName
+createTime string 创建时间
+remark string 备注名称
+status string 设备状态
+lastTime string 状态变更时间
+productKey string ProductKey
+productName string 产品名称
+nodeType string 节点类型。0 = 设备;1 = 网关
+username string mqtt username
+clientId string mqtt clientId
+secret string mqtt password

样例

GET https://www.thingshub.com.cn/openapi/v2/device/detail?productKey=vZq7sIf0kT0&deviceName=LB_867713074252867

{
  "code": 200,
  "msg": "success",
  "data": {
    "deviceId": 0,
    "deviceName": "",
    "createTime": "2024-02-29 17:08:34",
    "remark": "",
    "status": "ONLINE",
    "lastTime": "2024-12-26 09:05:20",
    "productKey": "",
    "productName": "喇叭",
    "nodeType": "0",
    "username": "",
    "clientId": "",
    "secret": ""
  }
}

设备服务调用

请求URL

https://www.thingshub.com.cn/openapi/v2/function/InvokeCustomizedService

方法

POST

Content-Type

application/x-www-form-urlencoded

请求参数

参数 数据类型 必填 备注
requestId string 请求标识。唯一标识一次请求
productKey string ProductKey
deviceName string DeviceName
identifier string 服务标识
topic string 服务主题
args string 服务请求参数

响应参数

参数 数据类型 必填 备注
code int 返回码
msg string 返回消息
data object 返回数据

子设备添加

请求URL

https://www.thingshub.com.cn/openapi/v2/subDevice/add

方法

POST

Content-Type

application/x-www-form-urlencoded

请求参数

参数 数据类型 必填 说明
deviceId int 设备ID
gwId int 网关设备ID
remark string 备注

响应参数

参数 数据类型 必填 说明
code int 返回码
msg string 返回消息

样例

{
    "code": 200,
    "msg": "success"
}

从网关移除子设备

请求URL

https://www.thingshub.com.cn/openapi/v2/subDevice/delete

方法

POST

Content-Type

application/x-www-form-urlencoded

请求参数

参数 数据类型 是否可空 说明
deviceId int 设备ID
gwId int 网关设备ID

响应参数

参数 数据类型 是否可空 说明
code int 返回码
msg string 返回消息

样例

{
    "code": 200,
    "msg": "success"
}

网关下子设备列表查询

请求URL

https://www.thingshub.com.cn/openapi/v2/subDevice/list

方法

GET

Content-Type

请求参数

参数 数据类型 必填 说明
pageNumber int 页码。默认:1
pageSize int 页大小。默认:10
gwId int 网关设备ID
deviceName string 网关下子设备的 DeviceName

响应参数

参数 数据类型 必填 说明
code int 返回码
msg string 返回消息
data object
+records array 设备列表
++deviceId int 设备ID
++deviceName string DeviceName
++createTime string 创建时间
++remark string 备注
++deviceSecret string 设备密钥
++status string 设备状态
++productId int 产品ID
++productKey string ProductKey
++productName string 产品名称
++projectId int 项目ID
++projectName string 项目名称
++nodeType string 节点类型
total int 总记录数
size int 页大小
current int 当前页码
pages int 总页数

样例

{
  "code": 200,
  "msg": "success.",
  "data": {
    "records": [
      {
        "deviceId": 0,
        "deviceName": "",
        "createTime": "2024-11-12 17:20:09",
        "remark": "",
        "deviceSecret": "",
        "status": "INACTIVE",
        "productId": 0,
        "productKey": "",
        "productName": "智能空气盒子",
        "projectId": 0,
        "projectName": "智慧办公",
        "nodeType": "0"
      }
    ],
    "total": 1,
    "size": 10,
    "current": 1,
    "pages": 1
  }
}

drc_camera_photo_take## 从网关移除子设备

请求URL

https://www.thingshub.com.cn/openapi/v2/subDevice/delete

方法

POST

Content-Type

application/x-www-form-urlencoded

请求参数

参数 数据类型 是否可空 说明
deviceId int 设备ID
gwId int 网关设备ID

响应参数

参数 数据类型 是否可空 说明
code int 返回码
msg string 返回消息

样例

{
    "code": 200,
    "msg": "success"
}