Skip to content

项目 HTTP API ​

项目 HTTP API 基于当前 OpenAPI 定义生成,用于项目级资源访问、设备管理、设备数据查询、设备控制、告警和规则查询。

准备工作 ​

在正式调用 API 前,请在 ZhiLian.Yun 控制台的项目应用中创建 API 类型应用,获取 appId、accessKey 和 secretKey。除免登录接口外,其他接口需要在请求头中携带访问令牌。

http
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

平台有两类访问令牌,分别用于不同的接口分组,两者不能混用:

令牌类型获取方式适用接口
项目 API 访问令牌POST /api/v1/access_token,使用应用的 appId、accessKey、secretKey 换取设备类型、设备组、设备管理、设备扩展信息、设备数据、设备通信、设备告警、消息规则、设备上下线日志
应用管理员令牌POST /api/v1/app-admin/login,使用项目管理员账号密码换取应用管理员(/api/v1/app-admin/*)、当前应用与项目凭据(/api/v1/project/*)、应用用户(/api/v1/project_customers*)的写操作
无需令牌—服务信息、SaaS 应用公开配置(/api/v1/app-info)、应用管理员登录(/api/v1/app-admin/login)

TIP

这里的项目 API AccessToken 由 /api/v1/access_token 获取,不是设备证书中的 AccessToken,两者不能混用;也不是应用管理员登录返回的 accessToken。

WARNING

应用管理员令牌的载荷中包含 deviceType=saas 与 appId,仅能访问应用管理员相关接口;使用项目 API 访问令牌调用这些接口会返回令牌无效错误。应用用户接口中涉及写操作的部分(修改用户信息、重置用户密码、分配用户设备)还要求应用管理员账号具备对应的权限键(edit_user_info、reset_user_password、assign_user_device),权限键清单见应用管理员登录接口返回的 user.permissionKeys 与「全局定义」。

API 请求代码示例 ​

以获取 API AccessToken 为例,项目 API 通过 HTTP JSON 请求调用。

shell
curl -X POST "https://<endpoint>/api/v1/access_token" \
  -H "Content-Type: application/json" \
  -d '{
    "appId": "APP_ID",
    "accessKey": "ACCESS_KEY",
    "secretKey": "SECRET_KEY"
  }'

获取 API AccessToken ​

服务器获取 AccessToken ​

Request Syntax

http
POST /api/v1/access_token HTTP/1.1
Content-Type: application/json

Request Body

字段类型必填说明
appIdstring否应用ID
accessKeystring否访问KEY
secretKeystring否访问密钥

Request Example

json
{
  "appId": "APP_ID",
  "accessKey": "ACCESS_KEY",
  "secretKey": "SECRET_KEY"
}

Response Data

字段类型说明
accessTokenstring访问令牌
expiresIninteger过期时间

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "accessToken": "ACCESS_TOKEN",
    "expiresIn": 315360000
  },
  "error": null,
  "traceId": "TRACE_ID"
}

接口总览 ​

方法路径说明分组
POST/api/v1/access_token获取访问令牌获取 API AccessToken
POST/api/v1/device_type新增设备类型设备类型
DELETE/api/v1/device_type/:typeKey删除设备类型设备类型
GET/api/v1/device_type/:typeKey获取设备类型指定信息设备类型
GET/api/v1/device_type/:typeKey/extend_infos获取设备类型扩展信息列表设备类型
PUT/api/v1/device_type/:typeKey/info修改设备类型信息设备类型
GET/api/v1/device_types获取设备类型列表设备类型
GET/api/v1/device_groups_tree读取设备组树形列表设备组
PUT/api/v1/device/:deviceCode/group修改设备所属分组设备组
POST/api/v1/device创建设备设备管理
DELETE/api/v1/device/:deviceCode删除设备设备管理
GET/api/v1/device/:deviceCode读取设备信息设备管理
PUT/api/v1/device/:deviceCode/info修改设备基本信息设备管理
GET/api/v1/devices读取设备列表设备管理
GET/api/v1/device_relations读取网关子设备关联列表网关子设备关联
POST/api/v1/device_relation添加子设备到网关网关子设备关联
PUT/api/v1/device_relation/:relId修改网关子设备关联网关子设备关联
DELETE/api/v1/device_relation/:relId移除网关子设备关联网关子设备关联
POST/api/v1/device/:deviceCode/extend_info修改设备扩展信息设备扩展信息
PUT/api/v1/device/:deviceCode/extend_info修改设备扩展信息设备扩展信息
GET/api/v1/device/:deviceCode/extend_infos读取设备扩展信息设备扩展信息
POST/api/v1/control/device/:deviceCode/attribute_acquisition采集设备属性设备数据
POST/api/v1/control/device/:deviceCode/attributes下发设备属性设备数据
GET/api/v1/device/:deviceCode/attribute/:key/aggregate获取设备历史属性聚合设备数据
GET/api/v1/device/:deviceCode/attribute/:key/series获取设备历史属性设备数据
GET/api/v1/device/:deviceCode/attributes获取设备最新属性设备数据
POST/api/v1/device/:deviceCode/attributes_remove删除设备历史属性设备数据
GET/api/v1/device/:deviceCode/device_config获取设备配置信息设备通信
PUT/api/v1/device/:deviceCode/device_config修改单个设备的配置设备通信
GET/api/v1/device_statistic/:deviceCode获取设备消息数设备通信
POST/api/v1/control/device/:deviceCode/command发送指令设备通信
GET/api/v1/alarm_rule/:id获取告警规则指定信息设备告警
GET/api/v1/alarm_rules获取告警规则列表设备告警
GET/api/v1/alarm_log/:id/info获取告警历史指定信息设备告警
PUT/api/v1/alarm_log/:id/maintain_info修改告警历史维护信息设备告警
GET/api/v1/alarm_logs读取所有告警消息设备告警
GET/api/v1/rules获取规则列表消息规则
GET/api/v1/rules/:id获取规则指定信息消息规则
GET/api/v1/device/:deviceCode/online_logs获取设备上下线日志列表设备上下线日志
POST/api/v1/app-admin/login应用管理员登录应用管理员
GET/api/v1/app-admin/me获取当前应用管理员应用管理员
POST/api/v1/app-admin/refresh刷新应用管理员令牌应用管理员
POST/api/v1/app-admin/logout应用管理员退出登录应用管理员
GET/api/v1/app-admin/boards获取应用允许访问的看板应用管理员
GET/api/v1/app-admin/boards/:boardId获取应用看板应用管理员
GET/api/v1/app-admin/boards/:boardId/data获取应用看板数据应用管理员
GET/api/v1/app-info根据应用ID获取SaaS应用公开配置SaaS 应用
GET/api/v1/project/current获取当前应用项目SaaS 应用
GET/api/v1/project/mqtt-credentials获取当前项目MQTT凭据SaaS 应用
GET/api/v1/project_customers获取应用用户列表应用用户
GET/api/v1/project_customers/:id获取应用用户详情应用用户
PUT/api/v1/project_customers/:id修改应用用户信息应用用户
PUT/api/v1/project_customers/:id/password重置应用用户密码应用用户
GET/api/v1/project_customers/:id/devices获取用户关联设备应用用户
POST/api/v1/project_customers/:id/devices添加用户关联设备应用用户
DELETE/api/v1/project_customers/:id/devices移除用户关联设备应用用户
GET/api/v1/info服务信息服务信息

设备类型 ​

获取设备类型列表 ​

Request Syntax

http
GET /api/v1/device_types HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Query Parameters

参数类型必填说明
pageinteger否页码
pageSizeinteger否每页大小
keywordstring否关键字
idinteger否ID
namestring否类型名称
createdAtarray<string>否创建时间
typeKeystring否类型KEY
connTypeinteger否设备接入类型:1 直连设备,2 子设备,3 网关设备。
msgProtocolinteger否设备接入协议:1 内部标准,2 Modbus RTU 透传,3 Modbus TCP 透传,99 其他。
productKeystring否产品识别码
scanTypeKeystring否扫描类型KEY,结合Sort使用
sortstring否排序方式(type_key_asc:类型KEY升序,type_key_desc:类型KEY降序)
typeKeysarray<string>否类型KEY列表

Response Data

字段类型说明
pageinteger
pageSizeinteger
totalinteger
itemsarray<internal.model.XjDeviceTypesListModel>数据列表
items[].idintegerID
items[].namestring类型名称
items[].descrstring类型描述
items[].iconstring类型图标
items[].connProtocolinteger设备通信方式:1 WiFi,2 以太网,3 4G,4 5G,5 NB-IoT,6 RS485,7 RS232,8 RS422,9 LoRa,10 Zigbee,11 BLE,99 其他。
items[].connTypeinteger设备接入类型:1 直连设备,2 子设备,3 网关设备。
items[].msgProtocolinteger设备接入协议:1 内部标准,2 Modbus RTU 透传,3 Modbus TCP 透传,99 其他。
items[].onlineDelayinteger在线超时时间(秒)
items[].activeDelayinteger活跃超时时间(秒)
items[].typeKeystring类型KEY
items[].productKeystring产品识别码
items[].openRuleinteger是否启用规则:0 未开启,1 已开启。
items[].createdAtstring创建时间
items[].deviceCountinteger设备数量

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "page": 1,
    "pageSize": 1,
    "total": 1,
    "items": [
      {
        "id": 1,
        "name": "名称",
        "descr": "描述",
        "icon": "string",
        "connProtocol": 1
      }
    ]
  },
  "error": null,
  "traceId": "TRACE_ID"
}

读取设备类型信息 ​

Request Syntax

http
GET /api/v1/device_type/:typeKey HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
typeKeystring是类型KEY

Query Parameters

参数类型必填说明
idinteger否ID

Response Data

字段类型说明
idintegerID
namestring类型名称
descrstring类型描述
iconstring类型图标
connProtocolinteger设备通信方式:1 WiFi,2 以太网,3 4G,4 5G,5 NB-IoT,6 RS485,7 RS232,8 RS422,9 LoRa,10 Zigbee,11 BLE,99 其他。
connTypeinteger设备接入类型:1 直连设备,2 子设备,3 网关设备。
msgProtocolinteger设备接入协议:1 内部标准,2 Modbus RTU 透传,3 Modbus TCP 透传,99 其他。
onlineDelayinteger在线超时时间(秒)
activeDelayinteger活跃超时时间(秒)
masterModelstring主模型
pluginModelstring插件模型
typeKeystring类型KEY
openAutoCreateinteger是否允许设备自动创建:0 未开启,1 已开启。
openCreateListinteger是否启用设备白名单:0 未开启,1 已开启。
createListApistring设备白名单验证API
openProductKeyinteger是否启用产品识别码:0 未开启,1 已开启。
productKeystring产品识别码
openProductConfiginteger是否启用产品默认配置:0 未开启,1 已开启。
productConfigstring产品默认配置
openRuleinteger是否启用规则:0 未开启,1 已开启。
updateVerinteger更新版本
tenantIdstring租户ID
createdDeptinteger创建部门
createdByinteger创建者
createdAtstring创建时间
updatedByinteger更新者
updatedAtstring更新时间
deviceCountinteger设备数量
panelConfigstring面板配置
userConfigstring用户配置
createDefaultStreamboolean已创建默认自定义数据流。
defaultStreamDataTypestring默认自定义数据流消息格式。
defaultStreamTcpEnabledboolean默认自定义数据流是否支持 TCP 接入。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "id": 1,
    "name": "名称",
    "descr": "描述",
    "icon": "string",
    "connProtocol": 1,
    "connType": 1,
    "msgProtocol": 1,
    "onlineDelay": 1,
    "activeDelay": 1,
    "masterModel": "string",
    "pluginModel": "string",
    "typeKey": "TYPE_KEY"
  },
  "error": null,
  "traceId": "TRACE_ID"
}

读取设备类型扩展信息定义 ​

Request Syntax

http
GET /api/v1/device_type/:typeKey/extend_infos HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
typeKeystring是设备类型KEY

Response Data

字段类型说明
pageinteger
pageSizeinteger
totalinteger
itemsarray<internal.model.XjDevTypeExtendListModel>数据列表
items[].idintegerID
items[].typeKeystring设备类型KEY
items[].namestring名称
items[].descrstring描述
items[].infoTypestring扩展类型。内置值:location 地理坐标。
items[].infoConfigstring配置
items[].enabledinteger是否启用:0 未启用,1 已启用。
items[].createdAtstring创建时间

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "page": 1,
    "pageSize": 1,
    "total": 1,
    "items": [
      {
        "id": 1,
        "typeKey": "TYPE_KEY",
        "name": "名称",
        "descr": "描述",
        "infoType": "string"
      }
    ]
  },
  "error": null,
  "traceId": "TRACE_ID"
}

创建设备类型 ​

Request Syntax

http
POST /api/v1/device_type HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Request Body

字段类型必填说明
idinteger否ID
namestring否类型名称
descrstring否类型描述
iconstring否类型图标
connProtocolinteger否设备通信方式:1 WiFi,2 以太网,3 4G,4 5G,5 NB-IoT,6 RS485,7 RS232,8 RS422,9 LoRa,10 Zigbee,11 BLE,99 其他。
connTypeinteger否设备接入类型:1 直连设备,2 子设备,3 网关设备。
msgProtocolinteger否设备接入协议:1 内部标准,2 Modbus RTU 透传,3 Modbus TCP 透传,99 其他。
onlineDelayinteger否在线超时时间(秒)
activeDelayinteger否活跃超时时间(秒)
masterModelstring否主模型
plugin_modelstring否插件模型
openAutoCreateinteger否是否允许设备自动创建:0 未开启,1 已开启。
openCreateListinteger否是否启用设备白名单:0 未开启,1 已开启。
createListApistring否设备白名单验证API
openProductKeyinteger否是否启用产品识别码:0 未开启,1 已开启。
productKeystring否产品识别码
openProductConfiginteger否是否启用产品默认配置:0 未开启,1 已开启。
productConfigstring否产品默认配置
openRuleinteger否是否启用规则:0 未开启,1 已开启。
createDefaultStreamboolean否是否同时创建默认自定义数据流。
defaultStreamDataTypestring否默认自定义数据流消息格式(JSON / HEX / Plaintext)。
defaultStreamTcpEnabledboolean否默认自定义数据流是否支持 TCP 接入。

Request Example

json
{
  "id": 1,
  "name": "名称",
  "descr": "描述",
  "icon": "string",
  "connProtocol": 1,
  "connType": 1,
  "msgProtocol": 1,
  "onlineDelay": 1,
  "activeDelay": 1,
  "masterModel": "string",
  "plugin_model": "string",
  "openAutoCreate": 1
}

Response Data

字段类型说明
idinteger设备类型ID
typeKeystring设备类型KEY

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "id": 1,
    "typeKey": "TYPE_KEY"
  },
  "error": null,
  "traceId": "TRACE_ID"
}

修改设备类型信息 ​

Request Syntax

http
PUT /api/v1/device_type/:typeKey/info HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
typeKeystring是路径参数

Request Body

字段类型必填说明
idinteger否ID
namestring否类型名称
descrstring否类型描述
iconstring否类型图标
connProtocolinteger否设备通信方式:1 WiFi,2 以太网,3 4G,4 5G,5 NB-IoT,6 RS485,7 RS232,8 RS422,9 LoRa,10 Zigbee,11 BLE,99 其他。
connTypeinteger否设备接入类型:1 直连设备,2 子设备,3 网关设备。
msgProtocolinteger否设备接入协议:1 内部标准,2 Modbus RTU 透传,3 Modbus TCP 透传,99 其他。
onlineDelayinteger否在线超时时间(秒)
activeDelayinteger否活跃超时时间(秒)
masterModelstring否主模型
plugin_modelstring否插件模型
openAutoCreateinteger否是否允许设备自动创建:0 未开启,1 已开启。
openCreateListinteger否是否启用设备白名单:0 未开启,1 已开启。
createListApistring否设备白名单验证API
openProductKeyinteger否是否启用产品识别码:0 未开启,1 已开启。
productKeystring否产品识别码
openProductConfiginteger否是否启用产品默认配置:0 未开启,1 已开启。
productConfigstring否产品默认配置
openRuleinteger否是否启用规则:0 未开启,1 已开启。
createDefaultStreamboolean否是否同时创建默认自定义数据流。
defaultStreamDataTypestring否默认自定义数据流消息格式(JSON / HEX / Plaintext)。
defaultStreamTcpEnabledboolean否默认自定义数据流是否支持 TCP 接入。

Request Example

json
{
  "id": 1,
  "name": "名称",
  "descr": "描述",
  "icon": "string",
  "connProtocol": 1,
  "connType": 1,
  "msgProtocol": 1,
  "onlineDelay": 1,
  "activeDelay": 1,
  "masterModel": "string",
  "plugin_model": "string",
  "openAutoCreate": 1
}

Response Data

字段类型说明
idinteger设备类型ID
typeKeystring设备类型KEY

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "id": 1,
    "typeKey": "TYPE_KEY"
  },
  "error": null,
  "traceId": "TRACE_ID"
}

删除设备类型 ​

Request Syntax

http
DELETE /api/v1/device_type/:typeKey HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
typeKeystring是路径参数

Query Parameters

参数类型必填说明
idinterface否ID

Response Data

无响应业务字段。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {},
  "error": null,
  "traceId": "TRACE_ID"
}

设备组 ​

读取设备组树形列表 ​

Request Syntax

http
GET /api/v1/device_groups_tree HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Response Data

字段类型说明
itemsarray<internal.model.XjGroupsTreeModel>数据列表
items[].idintegerID
items[].namestring名称
items[].groupKeystring分组KEY
items[].descrstring描述
items[].parentKeystring父分组KEY
items[].createdAtstring创建时间
items[].deviceCountinteger设备数量
items[].childCountinteger子分组数量
items[].childrenarray<internal.model.XjGroupsTreeModel>子分组

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "items": [
      {
        "id": 1,
        "name": "名称",
        "groupKey": "string",
        "descr": "描述",
        "parentKey": "string"
      }
    ]
  },
  "error": null,
  "traceId": "TRACE_ID"
}

修改设备所属分组 ​

Request Syntax

http
PUT /api/v1/device/:deviceCode/group HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring是设备码

Request Body

字段类型必填说明
groupKeystring否分组KEY,为空表示移出分组

Request Example

json
{
  "groupKey": "GROUP_KEY"
}

Response Data

无响应业务字段。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {},
  "error": null,
  "traceId": "TRACE_ID"
}

设备管理 ​

读取设备列表 ​

Request Syntax

http
GET /api/v1/devices HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Query Parameters

参数类型必填说明
pageinteger否页码
pageSizeinteger否每页大小
keywordstring否关键字
idinteger否设备ID
namestring否设备名称
deviceCodestring否设备码
statusstring否设备启用状态:0 启用,1 禁用。
typeKeystring否设备类型
onlineStatusinteger否设备在线状态:1 在线,2 离线。
activeStatusinteger否设备列表活跃状态:1 活跃,2 5 分钟内活跃,3 1 小时内活跃,4 1 天内活跃,20 不活跃,21 不活跃超过 1 天,22 不活跃超过 3 天,23 不活跃超过 7 天,30 从未活跃。
debugStatusinteger否设备调试状态:0 未开启,1 已开启。
createdAtarray<string>否创建时间
alarmStatusinteger否设备告警状态:1 未告警,2 告警中,3 普通告警,4 重要告警,5 紧急告警。
connTypeinteger否设备接入类型:1 直连设备,2 子设备,3 网关设备。
msgProtocolinteger否设备接入协议:1 内部标准,2 Modbus RTU 透传,3 Modbus TCP 透传,99 其他。
connTypesstring否设备接入类型列表,逗号分隔(如 2,3)。级联场景下网关下既可挂子设备也可挂网关设备,需要一次筛多个类型;与 connType 同时传入时以本参数为准。
groupNotInstring否设备不在那个分组下(用于设备组筛选)
groupKeystring否设备分组KEY
sortstring否排序方式(last_active_desc:最后活跃,created_asc:最早创建时间,created_desc:最新创建时间,name_asc:名称升序,device_code_asc:设备码升序,device_code_desc:设备码降序)
isNoFatherDeviceboolean否只查未挂到任何网关下的设备。筛选类型含子设备或网关设备时生效(网关设备挂在网关下即为级联)。
scanDeviceCodestring否扫描设备码,结合Sort使用
deviceCodesarray<string>否设备码列表

Response Data

字段类型说明
pageinteger
pageSizeinteger
totalinteger
itemsarray<internal.model.XjDevicesListModel>数据列表
items[].idinteger设备ID
items[].namestring设备名称
items[].descrstring设备描述
items[].typeKeystring设备类型KEY
items[].typeIconstring设备类型图标
items[].deviceKeystring设备唯一标识(嵌入式端)
items[].deviceCodestring设备码
items[].statusstring设备启用状态:0 启用,1 禁用。
items[].onlineStatusinteger设备在线状态:1 在线,2 离线。
items[].activeStatusinteger设备列表活跃状态:1 活跃,2 5 分钟内活跃,3 1 小时内活跃,4 1 天内活跃,20 不活跃,21 不活跃超过 1 天,22 不活跃超过 3 天,23 不活跃超过 7 天,30 从未活跃。
items[].debugStatusinteger设备调试状态:0 未开启,1 已开启。
items[].debugEnableTimeinteger设备调试时间
items[].latnumber设备坐标纬度
items[].lngnumber设备坐标经度
items[].alarmStatusinteger设备告警状态:1 未告警,2 告警中,3 普通告警,4 重要告警,5 紧急告警。
items[].firstLoginAtinteger第一次登录时间戳(毫秒)
items[].lastLoginAtinteger最后登录时间戳(毫秒)
items[].lastActiveAtinteger最后活跃时间戳(毫秒)
items[].typeNamestring设备类型名称
items[].typeOpenRuleinteger设备类型启用规则:0 未开启,1 已开启。
items[].groupobject<string, string>设备分组
items[].otaModulestringOTA模块
items[].otaVersionstringOTA版本
items[].otaModule2stringOTA模块2
items[].otaVersion2stringOTA版本2
items[].otaModule3stringOTA模块3
items[].otaVersion3stringOTA版本3
items[].otaModule4stringOTA模块4
items[].otaVersion4stringOTA版本4
items[].connTypeinteger设备接入类型:1 直连设备,2 子设备,3 网关设备。
items[].msgProtocolinteger设备接入协议:1 内部标准,2 Modbus RTU 透传,3 Modbus TCP 透传,99 其他。
items[].onlineDelayinteger在线超时时间(秒)
items[].activeDelayinteger活跃超时时间(秒)
items[].updateVerinteger更新版本
items[].iccidstringICCID(冗余)
items[].signalQualityinteger信号强度:0-4,数值越大通常表示信号越好。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "page": 1,
    "pageSize": 1,
    "total": 1,
    "items": [
      {
        "id": 1,
        "name": "名称",
        "descr": "描述",
        "typeKey": "TYPE_KEY",
        "deviceKey": "string"
      }
    ]
  },
  "error": null,
  "traceId": "TRACE_ID"
}

读取设备信息 ​

Request Syntax

http
GET /api/v1/device/:deviceCode HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring是设备码

Query Parameters

参数类型必填说明
idinteger否设备ID

Response Data

字段类型说明
idinteger设备ID
namestring设备名称
descrstring设备描述
typeKeystring设备类型KEY
deviceKeystring设备唯一标识(嵌入式端)
deviceCodestring设备码
statusstring设备启用状态:0 启用,1 禁用。
onlineStatusinteger设备在线状态:1 在线,2 离线。
alarmStatusinteger设备告警状态:1 未告警,2 告警中,3 普通告警,4 重要告警,5 紧急告警。
debugStatusinteger设备调试状态:0 未开启,1 已开启。
debugEnableTimeinteger设备调试时间戳(毫秒)
gatewayDeviceCodestring网关设备码
subDeviceAddrstring子设备地址
gatewayAddTimestring网关添加时间
addressstring设备位置
latnumber设备坐标纬度
lngnumber设备坐标经度
regionCodestring行政区域代码
locationBuildingstring建筑
locationUnitstring单元
locationFloorstring楼层
locationRoomstring房号
deviceSecretstring设备密钥
firstLoginAtinteger第一次登录时间戳(毫秒)
lastLoginAtinteger最后登录时间戳(毫秒)
lastActiveAtinteger最后活跃时间戳(毫秒)
otaLockintegerOTA 升级锁定状态:0 未锁定,1 已锁定。
otaModulestringOTA模块
otaVersionstringOTA版本
otaModule2stringOTA模块2
otaVersion2stringOTA版本2
otaModule3stringOTA模块3
otaVersion3stringOTA版本3
otaModule4stringOTA模块4
otaVersion4stringOTA版本4
connTypeinteger设备接入类型:1 直连设备,2 子设备,3 网关设备。
msgProtocolinteger设备接入协议:1 内部标准,2 Modbus RTU 透传,3 Modbus TCP 透传,99 其他。
onlineDelayinteger在线超时时间(秒)
activeDelayinteger活跃超时时间(秒)
updateVerinteger更新版本
iccidstringICCID(冗余)
signalQualityinteger信号强度:0-4,数值越大通常表示信号越好。
tenantIdstring租户ID
createdDeptinteger创建部门
createdByinteger创建者
createdAtstring创建时间
updatedByinteger更新者
updatedAtstring更新时间
typeNamestring设备类型名称
typeOpenRuleinteger设备类型启用规则:0 未开启,1 已开启。
masterModelstring物模型
connInfointernal.model.XjDeviceConnInfo设备连接信息
connInfo.deviceCodestring设备码
connInfo.loginTimeMsinteger最后登录时间(毫秒)
connInfo.lastTimeMsinteger最后在线时间(毫秒)
connInfo.onlineDelayinteger在线超时时间(秒)
connInfo.activeDelayinteger活跃超时时间(秒)
connInfo.svrTypeinteger数据服务类型
connInfo.svrCodestring数据服务编号
connInfo.connIdinteger连接ID
connInfo.connStatusinteger连接状态(0:离线 1:在线)
connInfo.gatewayCodestring网关设备码
connInfo.subAddrAllstring子设备地址全路径
connInfo.msgTypeTimeobject<string, integer>消息类型时间(毫秒)
connInfo.isOnlineboolean设备在线状态:1 在线,2 离线。
grouparray<internal.model.Group>设备分组
group[].routerstring
group[].keystring
group[].idinteger
parentDeviceIdinteger网关设备ID
parentDeviceNamestring网关设备名称
safeDeviceCodestring安全设备码(设备码 + 2 位校验码),控制台按"设备码类型=安全设备码"展示。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "id": 1,
    "name": "名称",
    "descr": "描述",
    "typeKey": "TYPE_KEY",
    "deviceKey": "string",
    "deviceCode": "DEVICE_CODE",
    "status": "string",
    "onlineStatus": 1,
    "alarmStatus": 1,
    "debugStatus": 1,
    "debugEnableTime": 1626197189,
    "gatewayDeviceCode": "DEVICE_CODE"
  },
  "error": null,
  "traceId": "TRACE_ID"
}

创建设备 ​

Request Syntax

http
POST /api/v1/device HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Request Body

字段类型必填说明
idinteger否设备ID
namestring否设备名称
descrstring否设备描述
typeKeystring否设备类型KEY
deviceKeystring否设备唯一标识(嵌入式端)
statusstring否设备启用状态:0 启用,1 禁用。
debugStatusinteger否设备调试状态:0 未开启,1 已开启。
debugEnableTimeinteger否设备调试时间
firstLoginAtinteger否第一次登录时间戳(毫秒),即设备激活时间。
otaLockinteger否升级锁定:0 未锁定,1 已锁定。
addressstring否设备位置
latnumber否设备坐标纬度
lngnumber否设备坐标经度
regionCodestring否行政区域代码
locationBuildingstring否建筑
locationUnitstring否单元
locationFloorstring否楼层
locationRoomstring否房号

Request Example

json
{
  "id": 1,
  "name": "名称",
  "descr": "描述",
  "typeKey": "TYPE_KEY",
  "deviceKey": "string",
  "status": "string",
  "debugStatus": 1,
  "debugEnableTime": 1626197189,
  "address": "string",
  "lat": 1.23,
  "lng": 1.23,
  "regionCode": "string"
}

Response Data

字段类型说明
idinteger设备ID
deviceCodestring设备码

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "id": 1,
    "deviceCode": "DEVICE_CODE"
  },
  "error": null,
  "traceId": "TRACE_ID"
}

修改设备基本信息 ​

Request Syntax

http
PUT /api/v1/device/:deviceCode/info HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring是路径参数

Request Body

字段类型必填说明
idinteger否设备ID
namestring否设备名称
descrstring否设备描述
typeKeystring否设备类型KEY
deviceKeystring否设备唯一标识(嵌入式端)
statusstring否设备启用状态:0 启用,1 禁用。
debugStatusinteger否设备调试状态:0 未开启,1 已开启。
debugEnableTimeinteger否设备调试时间
firstLoginAtinteger否第一次登录时间戳(毫秒),即设备激活时间。
otaLockinteger否升级锁定:0 未锁定,1 已锁定。
addressstring否设备位置
latnumber否设备坐标纬度
lngnumber否设备坐标经度
regionCodestring否行政区域代码
locationBuildingstring否建筑
locationUnitstring否单元
locationFloorstring否楼层
locationRoomstring否房号

Request Example

json
{
  "id": 1,
  "name": "名称",
  "descr": "描述",
  "typeKey": "TYPE_KEY",
  "deviceKey": "string",
  "status": "string",
  "debugStatus": 1,
  "debugEnableTime": 1626197189,
  "address": "string",
  "lat": 1.23,
  "lng": 1.23,
  "regionCode": "string"
}

Response Data

字段类型说明
idinteger设备ID
deviceCodestring设备码

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "id": 1,
    "deviceCode": "DEVICE_CODE"
  },
  "error": null,
  "traceId": "TRACE_ID"
}

移除设备 ​

Request Syntax

http
DELETE /api/v1/device/:deviceCode HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring是设备码

Query Parameters

参数类型必填说明
idinterface否设备ID

Response Data

无响应业务字段。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {},
  "error": null,
  "traceId": "TRACE_ID"
}

网关子设备关联 ​

管理网关与子设备的绑定关系,可用于搭建多级网关(网关下再挂网关,子设备地址用 . 分隔层级,详见网关 MQTT 接入的多级网关说明)。

绑定约束:

  • 父设备必须是网关设备(connType=3),被绑定的设备可以是子设备或网关设备(级联)。
  • 父子设备的接入协议(msgProtocol)必须一致。
  • 子设备地址在同一网关下唯一,不能包含 .(. 是层级分隔符)。
  • 不能把设备关联到它自己的下级(防环)。

读取网关子设备关联列表 ​

Request Syntax

http
GET /api/v1/device_relations?parentDeviceCode=GATEWAY_DEVICE_CODE HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Request Parameters

参数类型必填说明
parentDeviceCodestring否网关设备码,传则只返回该网关下的关联
relIdinteger否关联ID
keywordstring否关键字
createdAtarray<string>否创建时间
pageinteger否页码,默认 1
pageSizeinteger否每页数量,默认 20

Response Data

字段类型说明
pageinteger当前页码
totalinteger数据总数
itemsarray<object>数据列表
items[].relIdinteger关联ID
items[].parentDeviceCodestring网关设备码
items[].subDeviceCodestring子设备码
items[].subDeviceAddrstring子设备地址
items[].subDeviceIdinteger子设备ID
items[].namestring子设备名称
items[].onlineStatusinteger子设备在线状态:1 在线,2 离线。
items[].lastActiveAtinteger最后活跃时间戳(毫秒)
items[].alarmStatusinteger子设备告警状态:1 未告警,2 告警中,3 普通告警,4 重要告警,5 紧急告警。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "page": 1,
    "total": 1,
    "items": [
      {
        "relId": 1,
        "parentDeviceCode": "GATEWAY_DEVICE_CODE",
        "subDeviceCode": "SUB_DEVICE_CODE",
        "subDeviceAddr": "1",
        "subDeviceId": 1,
        "name": "子设备名称",
        "onlineStatus": 1,
        "lastActiveAt": 1626197189640,
        "alarmStatus": 1
      }
    ]
  },
  "error": null,
  "traceId": "TRACE_ID"
}

添加子设备到网关 ​

Request Syntax

http
POST /api/v1/device_relation HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Request Body

字段类型必填说明
parentDeviceCodestring是网关设备码
subDeviceCodearray<string>是子设备码列表,可一次绑定多个

Request Example

json
{
  "parentDeviceCode": "GATEWAY_DEVICE_CODE",
  "subDeviceCode": ["SUB_DEVICE_CODE1", "SUB_DEVICE_CODE2"]
}

Response Data

无响应业务字段。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {},
  "error": null,
  "traceId": "TRACE_ID"
}

TIP

新绑定的子设备初始没有子设备地址。网关上报 gateway/connect 前必须先设置地址, 否则平台无法把报文归属到子设备。用下面的「修改网关子设备关联」接口设置。

修改网关子设备关联 ​

当前仅支持修改子设备地址。

Request Syntax

http
PUT /api/v1/device_relation/:relId HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
relIdinteger是关联ID,从列表接口获得

Request Body

字段类型必填说明
subDeviceAddrstring是子设备地址,不能包含 .

Request Example

json
{
  "subDeviceAddr": "1"
}

Response Data

无响应业务字段。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {},
  "error": null,
  "traceId": "TRACE_ID"
}

移除网关子设备关联 ​

解除子设备与网关的绑定,子设备的网关设备码与子设备地址会被清空。

Request Syntax

http
DELETE /api/v1/device_relation/:relId HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
relIdinteger是关联ID

Response Data

无响应业务字段。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {},
  "error": null,
  "traceId": "TRACE_ID"
}

设备扩展信息 ​

读取设备扩展信息 ​

Request Syntax

http
GET /api/v1/device/:deviceCode/extend_infos HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring是设备码

Query Parameters

参数类型必填说明
pageinteger否页码
pageSizeinteger否每页大小
keywordstring否关键字

Response Data

字段类型说明
pageinteger
pageSizeinteger
totalinteger
itemsarray<internal.model.XjDeviceExtendsListModel>数据列表
items[].idintegerID
items[].deviceCodestring设备码
items[].namestring名称
items[].typeExtendIdinteger扩展类型。内置值:location 地理坐标。ID
items[].infoTypestring扩展类型。内置值:location 地理坐标。
items[].extendValuestring扩展数据值
items[].createdDeptinteger创建部门
items[].createdByinteger创建者
items[].createdBySummainternal.library.xgorm.hook.MemberSumma创建者摘要信息
items[].createdAtstring创建时间
items[].updatedByinteger更新者
items[].updatedBySummainternal.library.xgorm.hook.MemberSumma更新者摘要信息
items[].updatedAtstring更新时间

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "page": 1,
    "pageSize": 1,
    "total": 1,
    "items": [
      {
        "id": 1,
        "deviceCode": "DEVICE_CODE",
        "name": "名称",
        "typeExtendId": 1,
        "infoType": "string"
      }
    ]
  },
  "error": null,
  "traceId": "TRACE_ID"
}

修改设备扩展信息(POST) ​

Request Syntax

http
POST /api/v1/device/:deviceCode/extend_info HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring是路径参数

Request Body

字段类型必填说明
idinteger否ID
deviceCodestring否设备码
namestring否名称
typeExtendIdinteger否扩展类型。内置值:location 地理坐标。ID
infoTypestring扩展类型。内置值:location 地理坐标。扩展类型。内置值:location 地理坐标。
extendValuestring否扩展数据值
tenantIdstring否租户ID
createdDeptinteger否创建部门
createdByinteger否创建者
createdAtstring否创建时间
updatedByinteger否更新者
updatedAtstring否更新时间

Request Example

json
{
  "id": 1,
  "deviceCode": "DEVICE_CODE",
  "name": "名称",
  "typeExtendId": 1,
  "infoType": "string",
  "extendValue": "string",
  "tenantId": "string",
  "createdDept": 1,
  "createdBy": 1,
  "createdAt": "string",
  "updatedBy": 1,
  "updatedAt": "string"
}

Response Data

无响应业务字段。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {},
  "error": null,
  "traceId": "TRACE_ID"
}

修改设备扩展信息(PUT) ​

Request Syntax

http
PUT /api/v1/device/:deviceCode/extend_info HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring是路径参数

Request Body

字段类型必填说明
idinteger否ID
deviceCodestring否设备码
namestring否名称
typeExtendIdinteger否扩展类型。内置值:location 地理坐标。ID
infoTypestring扩展类型。内置值:location 地理坐标。扩展类型。内置值:location 地理坐标。
extendValuestring否扩展数据值
tenantIdstring否租户ID
createdDeptinteger否创建部门
createdByinteger否创建者
createdAtstring否创建时间
updatedByinteger否更新者
updatedAtstring否更新时间

Request Example

json
{
  "id": 1,
  "deviceCode": "DEVICE_CODE",
  "name": "名称",
  "typeExtendId": 1,
  "infoType": "string",
  "extendValue": "string",
  "tenantId": "string",
  "createdDept": 1,
  "createdBy": 1,
  "createdAt": "string",
  "updatedBy": 1,
  "updatedAt": "string"
}

Response Data

无响应业务字段。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {},
  "error": null,
  "traceId": "TRACE_ID"
}

设备数据 ​

读取设备当前属性值集合 ​

Request Syntax

http
GET /api/v1/device/:deviceCode/attributes HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring是设备码

Response Data

字段类型说明
deviceCodestring设备码
listarray<git.xiujie.cn.cloud.cloud-public.xjpubmodel.XjDeviceProperty>属性列表
list[].keystring属性标识
list[].namestring属性名称(可空)
list[].typestring属性值类型(可空)
list[].unitstring属性值单位(可空)
list[].vgithub.com.gogf.gf.v2.container.gvar.Var属性值
list[].tsstring时间

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "deviceCode": "DEVICE_CODE",
    "list": [
      {
        "key": "temperature",
        "name": "名称",
        "type": "string",
        "unit": "string",
        "v": {}
      }
    ]
  },
  "error": null,
  "traceId": "TRACE_ID"
}

读取设备属性历史数据 ​

Request Syntax

http
GET /api/v1/device/:deviceCode/attribute/:key/series HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring是设备SN
keystring是属性标识

Query Parameters

参数类型必填说明
versioninteger否物模型版本:0 表示最新版本。
startTimestring否开始时间
endTimestring否结束时间
isAscboolean否是否升序
pageinteger否页码
pageSizeinteger否每页大小
keywordstring否关键字

Response Data

字段类型说明
pageinteger
pageSizeinteger
totalinteger
dataarray<git.xiujie.cn.cloud.cloud-public.xjpubmodel.XjDeviceProperty>
data[].keystring属性标识
data[].namestring属性名称(可空)
data[].typestring属性值类型(可空)
data[].unitstring属性值单位(可空)
data[].vgithub.com.gogf.gf.v2.container.gvar.Var属性值
data[].tsstring时间

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "page": 1,
    "pageSize": 1,
    "total": 1,
    "data": [
      {
        "key": "temperature",
        "name": "名称",
        "type": "string",
        "unit": "string",
        "v": {}
      }
    ]
  },
  "error": null,
  "traceId": "TRACE_ID"
}

读取设备属性聚合统计数据 ​

Request Syntax

http
GET /api/v1/device/:deviceCode/attribute/:key/aggregate HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring是设备SN
keystring是属性标识

Query Parameters

参数类型必填说明
versioninteger否物模型版本:0 表示最新版本。
startTimestring否开始时间
endTimestring否结束时间
isAscboolean否是否升序
aggregateWindowstring否聚合窗口
aggregateFunctionstring否聚合函数
pageinteger否页码
pageSizeinteger否每页大小
keywordstring否关键字

Response Data

字段类型说明
pageinteger
pageSizeinteger
totalinteger
dataarray<git.xiujie.cn.cloud.cloud-public.xjpubmodel.XjDeviceProperty>
data[].keystring属性标识
data[].namestring属性名称(可空)
data[].typestring属性值类型(可空)
data[].unitstring属性值单位(可空)
data[].vgithub.com.gogf.gf.v2.container.gvar.Var属性值
data[].tsstring时间

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "page": 1,
    "pageSize": 1,
    "total": 1,
    "data": [
      {
        "key": "temperature",
        "name": "名称",
        "type": "string",
        "unit": "string",
        "v": {}
      }
    ]
  },
  "error": null,
  "traceId": "TRACE_ID"
}

移除设备属性 ​

Request Syntax

http
POST /api/v1/device/:deviceCode/attributes_remove HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring是路径参数

Request Body

字段类型必填说明
deviceCodestring否设备SN
keysarray<string>否属性标识列表,必填
isRemoveboolean否是否移除属性,true:移除最后属性和历史属性,false:保留最后属性
startTimestring否开始时间,可空
endTimestring否结束时间,可空

Request Example

json
{
  "deviceCode": "DEVICE_CODE",
  "keys": [
    "string"
  ],
  "isRemove": true,
  "startTime": "string",
  "endTime": "string"
}

Response Data

无响应业务字段。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {},
  "error": null,
  "traceId": "TRACE_ID"
}

采集设备属性 ​

Request Syntax

http
POST /api/v1/control/device/:deviceCode/attribute_acquisition HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring是路径参数

Request Body

字段类型必填说明
deviceCodestring否设备SN,必填
keysarray<string>否属性标识列表,可空
isAsyncboolean否是否异步调用,同步:false,异步:true 同步调用等待设备响应
syncTimeoutinteger否同步超时时间秒,默认10秒

Request Example

json
{
  "deviceCode": "DEVICE_CODE",
  "keys": [
    "string"
  ],
  "isAsync": true,
  "syncTimeout": 1626197189
}

Response Data

字段类型说明
deviceCodestring设备SN,必填
codeinteger返回码
messagestring返回消息
outputobject<string, interface>输出参数
outDatastring输出数据原始设备数据,可空
inDatastring输入数据原始设备数据,可空

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "deviceCode": "DEVICE_CODE",
    "code": 1,
    "message": "string",
    "output": {
      "key": {}
    },
    "outData": "string",
    "inData": "string"
  },
  "error": null,
  "traceId": "TRACE_ID"
}

下发设备属性 ​

Request Syntax

http
POST /api/v1/control/device/:deviceCode/attributes HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring是路径参数

Request Body

字段类型必填说明
msgIdinteger否消息ID,可空
deviceCodestring否设备SN,必填
inputobject<string, interface>否输入参数
isAsyncboolean否是否异步调用,同步:false,异步:true 同步调用等待设备响应
syncTimeoutinteger否同步超时时间秒,默认10秒

Request Example

json
{
  "msgId": 1,
  "deviceCode": "DEVICE_CODE",
  "input": {
    "key": {}
  },
  "isAsync": true,
  "syncTimeout": 1626197189
}

Response Data

字段类型说明
msgIdinteger消息ID,可空
deviceCodestring设备SN,必填
codeinteger返回码
messagestring返回消息
outDatastring输出数据原始设备数据,可空
inDatastring输入数据原始设备数据,可空

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "msgId": 1,
    "deviceCode": "DEVICE_CODE",
    "code": 1,
    "message": "string",
    "outData": "string",
    "inData": "string"
  },
  "error": null,
  "traceId": "TRACE_ID"
}

设备通信 ​

下发命令到设备 ​

Request Syntax

http
POST /api/v1/control/device/:deviceCode/command HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring是路径参数

Request Body

字段类型必填说明
msgIdinteger否消息ID,可空
deviceCodestring否设备SN,必填
keystring否指令标识,必填
inputobject<string, interface>否输入参数
isAsyncboolean否是否异步调用,同步:false,异步:true 同步调用等待设备响应
syncTimeoutinteger否同步超时时间秒,默认10秒

Request Example

json
{
  "msgId": 1,
  "deviceCode": "DEVICE_CODE",
  "key": "temperature",
  "input": {
    "key": {}
  },
  "isAsync": true,
  "syncTimeout": 1626197189
}

Response Data

字段类型说明
msgIdinteger消息ID,可空
deviceCodestring设备SN,必填
keystring指令标识,必填
codeinteger返回码
messagestring返回消息
outputobject<string, interface>输出参数
outDatastring输出数据原始设备数据,可空
inDatastring输入数据原始设备数据,可空

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "msgId": 1,
    "deviceCode": "DEVICE_CODE",
    "key": "temperature",
    "code": 1,
    "message": "string",
    "output": {
      "key": {}
    },
    "outData": "string",
    "inData": "string"
  },
  "error": null,
  "traceId": "TRACE_ID"
}

读取设备配置信息 ​

Request Syntax

http
GET /api/v1/device/:deviceCode/device_config HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring是设备码

Response Data

字段类型说明
idintegerID
deviceCodestring设备码
confGroupKeystring配置分组Key
deviceConfIdinteger设备内配置ID
deviceConfVerinteger设备内配置版本
platDevConfVerinteger平台配置设备版本号(无分组)
platDevConfIdinteger平台配置版本ID(无分组)
platGroupConfVerinteger平台分组配置版本号(有分组)
platGroupConfIdinteger平台分组配置版本ID(有分组)
deviceConfAtstring设备端版本更新时间
tenantIdstring租户ID
createdDeptinteger创建部门
createdByinteger创建者
createdAtstring创建时间
updatedByinteger更新者
updatedAtstring更新时间
deviceConfigContentstring设备配置内容
groupConfigContentstring分组配置内容

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "id": 1,
    "deviceCode": "DEVICE_CODE",
    "confGroupKey": "string",
    "deviceConfId": 1,
    "deviceConfVer": 1,
    "platDevConfVer": 1,
    "platDevConfId": 1,
    "platGroupConfVer": 1,
    "platGroupConfId": 1,
    "deviceConfAt": "string",
    "tenantId": "string",
    "createdDept": 1
  },
  "error": null,
  "traceId": "TRACE_ID"
}

修改设备配置 ​

Request Syntax

http
PUT /api/v1/device/:deviceCode/device_config HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring是路径参数

Request Body

字段类型必填说明
deviceCodestring否设备码
configContentstring否配置内容(分组配置、设备配置)
fileUrlstring否文件地址
filePathstring否文件本地路径
fileMd5string否文件md5

Request Example

json
{
  "deviceCode": "DEVICE_CODE",
  "configContent": "string",
  "fileUrl": "string",
  "filePath": "string",
  "fileMd5": "string"
}

Response Data

无响应业务字段。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {},
  "error": null,
  "traceId": "TRACE_ID"
}

读取设备消息统计 ​

Request Syntax

http
GET /api/v1/device_statistic/:deviceCode HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring是设备码

Query Parameters

参数类型必填说明
timestring是统计时间范围,可选值:24h、3d、7d、15d、30d。不传会返回时间参数错误。

Response Data

字段类型说明
timesarray<string>
seriesarray<internal.model.MsgSeries>
series[].typeinteger
series[].namestring
series[].dataarray<integer>
totalarray<integer>

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "times": [
      "string"
    ],
    "series": [
      {
        "type": 1,
        "name": "名称",
        "data": [
          "integer"
        ]
      }
    ],
    "total": [
      1
    ]
  },
  "error": null,
  "traceId": "TRACE_ID"
}

设备告警 ​

读取所有告警消息 ​

Request Syntax

http
GET /api/v1/alarm_logs HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Query Parameters

参数类型必填说明
pageinteger否页码
pageSizeinteger否每页大小
keywordstring否关键字
idinteger否日志ID
alarmStatusinteger否告警状态:0 正常,1 告警中,2 待定。
alarmLevelinteger否告警级别:1 普通告警,2 重要告警,3 紧急告警。
createdAtarray<string>否创建时间
deviceCodestring否设备码
dsTypestring否设备来源类型:device_type 设备类型,device 设备。
dsSourcestring否来源标识
alarmRuleIdinteger否告警规则ID
alarmRuleNamestring否告警规则名称
scanIdinteger否扫描ID,结合Sort使用
sortstring否排序方式(id_asc:ID升序,id_desc:ID降序)

Response Data

字段类型说明
pageinteger
pageSizeinteger
totalinteger
itemsarray<internal.model.XjAlarmLogsListModel>数据列表
items[].idinteger日志ID
items[].alarmRuleIdinteger告警规则ID
items[].alarmRuleNamestring告警规则名称
items[].alarmRuleDescrstring告警规则描述
items[].deviceCodestring设备码
items[].deviceNamestring设备名称
items[].alarmLevelinteger告警级别:1 普通告警,2 重要告警,3 紧急告警。
items[].alarmStatusinteger告警状态:0 正常,1 告警中,2 待定。
items[].alarmInfostring告警信息
items[].triggerInfostring触发信息
items[].snapshotstring设备快照
items[].maintainInfostring维护信息
items[].maintainTsinteger维护更新时间戳秒
items[].maintainerstring维护信息更新用户
items[].recoverAlarmTypeinteger恢复告警类型
items[].recoverAlarmAtstring恢复告警时间
items[].recoverAlarmRuleIdinteger恢复告警规则ID
items[].recoverAlarmRuleNamestring恢复告警规则名称
items[].recoverTriggerInfostring恢复时触发信息
items[].recoverUserTypeinteger恢复告警用户类型
items[].recoverUserIdinteger恢复告警用户ID
items[].tenantIdstring租户ID
items[].createdDeptinteger创建部门
items[].createdByinteger创建者
items[].createdAtstring创建时间
items[].updatedByinteger更新者
items[].updatedAtstring更新时间

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "page": 1,
    "pageSize": 1,
    "total": 1,
    "items": [
      {
        "id": 1,
        "alarmRuleId": 1,
        "alarmRuleName": "名称",
        "alarmRuleDescr": "描述",
        "deviceCode": "DEVICE_CODE"
      }
    ]
  },
  "error": null,
  "traceId": "TRACE_ID"
}

读取告警消息 ​

Request Syntax

http
GET /api/v1/alarm_log/:id/info HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
idinteger是日志ID

Response Data

字段类型说明
idinteger日志ID
alarmRuleIdinteger告警规则ID
alarmRuleNamestring告警规则名称
alarmRuleDescrstring告警规则描述
deviceCodestring设备码
deviceNamestring设备名称
alarmLevelinteger告警级别:1 普通告警,2 重要告警,3 紧急告警。
alarmStatusinteger告警状态:0 正常,1 告警中,2 待定。
alarmInfostring告警信息
triggerInfostring触发信息
snapshotstring设备快照
maintainInfostring维护信息
maintainTsinteger维护更新时间戳秒
maintainerstring维护信息更新用户
recoverAlarmTypeinteger恢复告警类型
recoverAlarmAtstring恢复告警时间
recoverAlarmRuleIdinteger恢复告警规则ID
recoverAlarmRuleNamestring恢复告警规则名称
recoverTriggerInfostring恢复时触发信息
recoverUserTypeinteger恢复告警用户类型
recoverUserIdinteger恢复告警用户ID
tenantIdstring租户ID
createdDeptinteger创建部门
createdByinteger创建者
createdAtstring创建时间
updatedByinteger更新者
updatedAtstring更新时间

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "id": 1,
    "alarmRuleId": 1,
    "alarmRuleName": "名称",
    "alarmRuleDescr": "描述",
    "deviceCode": "DEVICE_CODE",
    "deviceName": "名称",
    "alarmLevel": 1,
    "alarmStatus": 1,
    "alarmInfo": "string",
    "triggerInfo": "string",
    "snapshot": "string",
    "maintainInfo": "string"
  },
  "error": null,
  "traceId": "TRACE_ID"
}

修改告警历史维护信息 ​

Request Syntax

http
PUT /api/v1/alarm_log/:id/maintain_info HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
idstring是路径参数

Request Body

字段类型必填说明
idinteger否日志ID
alarmReasonstring否告警原因
solutionstring否解决方案
remarkstring否其他备注
isRecoverboolean否是否恢复告警

Request Example

json
{
  "id": 1,
  "alarmReason": "string",
  "solution": "string",
  "remark": "string",
  "isRecover": true
}

Response Data

无响应业务字段。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {},
  "error": null,
  "traceId": "TRACE_ID"
}

读取告警规则列表 ​

Request Syntax

http
GET /api/v1/alarm_rules HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Query Parameters

参数类型必填说明
pageinteger否页码
pageSizeinteger否每页大小
keywordstring否关键字
idinteger否规则ID
debugStatusinteger否规则调试状态:0 未开启,1 已开启。
dsTypestring否设备来源类型:device_type 设备类型,device 设备。
dsSourcestring否设备来源。dsType 为 device 时通常为设备码数组;dsType 为 device_type 时通常为设备类型标识数组。Id
triggerTypestring否触发类型:attrs_changed 属性变化,inactive 设备不活跃,event_post 事件上报,online 设备在线,offline 设备离线。
createdAtarray<string>否创建时间
scanIdinteger否扫描ID,结合Sort使用
sortstring否排序方式(id_asc:ID升序,id_desc:ID降序)

Response Data

字段类型说明
pageinteger
pageSizeinteger
totalinteger
itemsarray<internal.model.XjAlarmRulesListModel>数据列表
items[].idinteger规则ID
items[].namestring规则名称
items[].descrstring规则描述
items[].dsTypestring设备来源类型:device_type 设备类型,device 设备。
items[].dsSourcestring设备来源。dsType 为 device 时通常为设备码数组;dsType 为 device_type 时通常为设备类型标识数组。
items[].triggerTypestring触发类型:attrs_changed 属性变化,inactive 设备不活跃,event_post 事件上报,online 设备在线,offline 设备离线。
items[].pendingNuminteger重复次数
items[].pendingTimeinteger重复时间(秒)
items[].silentTimeinteger静默时间(秒)
items[].condsstring过滤条件
items[].devicesDisablestring禁用设备
items[].customTopicIdentifierstring自定义数据流标识符
items[].alarmLevelinteger告警级别:1 普通告警,2 重要告警,3 紧急告警。
items[].notificationConfigstring通知配置 JSON。可包含公众号、短信、电话、App 通知、每日通知次数上限、单设备每日通知次数上限等配置。
items[].enabledinteger是否启用:0 未启用,1 已启用。
items[].enableTimeSpansinteger是否启用有效时段:0 未启用,1 已启用。
items[].validTimeSpansstring有效时段配置 JSON。可包含有效时间段、是否允许解除告警、是否允许用户解除告警、是否允许用户禁用规则等配置。
items[].debugStatusinteger规则调试状态:0 未开启,1 已开启。
items[].debugEnableTimeinteger规则调试时间
items[].isAlarminteger是否处于告警中:0 否,1 是。
items[].isRecoverAlarminteger是否为恢复告警规则:0 否,1 是。
items[].recoverAlarmIdsstring恢复告警规则 ID 列表,JSON 数组格式,如 [1,2,3]。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "page": 1,
    "pageSize": 1,
    "total": 1,
    "items": [
      {
        "id": 1,
        "name": "名称",
        "descr": "描述",
        "dsType": "string",
        "dsSource": "string"
      }
    ]
  },
  "error": null,
  "traceId": "TRACE_ID"
}

读取告警规则信息 ​

Request Syntax

http
GET /api/v1/alarm_rule/:id HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
idinteger是规则ID

Response Data

字段类型说明
idinteger规则ID
namestring规则名称
descrstring规则描述
dsTypestring设备来源类型:device_type 设备类型,device 设备。
dsSourcestring设备来源。dsType 为 device 时通常为设备码数组;dsType 为 device_type 时通常为设备类型标识数组。
triggerTypestring触发类型:attrs_changed 属性变化,inactive 设备不活跃,event_post 事件上报,online 设备在线,offline 设备离线。
pendingNuminteger重复次数
pendingTimeinteger重复时间(秒)
silentTimeinteger静默时间(秒)
condsstring过滤条件
devicesDisablestring禁用设备
customTopicIdentifierstring自定义数据流标识符
alarmLevelinteger告警级别:1 普通告警,2 重要告警,3 紧急告警。
notificationConfigstring通知配置 JSON。可包含公众号、短信、电话、App 通知、每日通知次数上限、单设备每日通知次数上限等配置。
enabledinteger是否启用:0 未启用,1 已启用。
enableTimeSpansinteger是否启用有效时段:0 未启用,1 已启用。
validTimeSpansstring有效时段配置 JSON。可包含有效时间段、是否允许解除告警、是否允许用户解除告警、是否允许用户禁用规则等配置。
debugStatusinteger规则调试状态:0 未开启,1 已开启。
debugEnableTimeinteger规则调试时间
isAlarminteger是否处于告警中:0 否,1 是。
isRecoverAlarminteger是否为恢复告警规则:0 否,1 是。
recoverAlarmIdsstring恢复告警规则 ID 列表,JSON 数组格式,如 [1,2,3]。
tenantIdstring租户ID
createdDeptinteger创建部门
createdByinteger创建者
createdAtstring创建时间
updatedByinteger更新者
updatedAtstring更新时间
dsSourceMapobject<string, string>设备信息

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "id": 1,
    "name": "名称",
    "descr": "描述",
    "dsType": "string",
    "dsSource": "string",
    "triggerType": "string",
    "pendingNum": 1,
    "pendingTime": 1626197189,
    "silentTime": 1626197189,
    "conds": "string",
    "devicesDisable": "string",
    "customTopicIdentifier": "string"
  },
  "error": null,
  "traceId": "TRACE_ID"
}

消息规则 ​

读取规则列表 ​

Request Syntax

http
GET /api/v1/rules HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Query Parameters

参数类型必填说明
pageinteger否页码
pageSizeinteger否每页大小
keywordstring否关键字
idinteger否规则ID
dsTypestring否设备来源类型:device_type 设备类型,device 设备。
ruleTypestring否规则类型
actionTypearray<string>否动作类型
actionTypeNamearray<string>否动作类型名称
deviceCodestring否设备码
enabledinteger否是否启用:0 未启用,1 已启用。
debugStatusinteger否规则调试状态:0 未开启,1 已开启。
createdAtarray<string>否创建时间
scanIdinteger否扫描ID,结合Sort使用
sortstring否排序方式(id_asc:ID升序,id_desc:ID降序)

Response Data

字段类型说明
pageinteger
pageSizeinteger
totalinteger
itemsarray<internal.model.XjRulesListModel>数据列表
items[].idinteger规则ID
items[].namestring规则名称
items[].descrstring规则描述
items[].ruleTypestring规则类型
items[].actionTypearray<string>动作类型
items[].actionTypeNamearray<string>动作类型名称
items[].dsTypestring设备来源类型:device_type 设备类型,device 设备。
items[].customTopicIdentifierstring自定义数据流标识符
items[].enabledinteger是否启用:0 未启用,1 已启用。
items[].debugStatusinteger规则调试状态:0 未开启,1 已开启。
items[].debugEnableTimeinteger规则调试时间
items[].createdAtstring创建时间

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "page": 1,
    "pageSize": 1,
    "total": 1,
    "items": [
      {
        "id": 1,
        "name": "名称",
        "descr": "描述",
        "ruleType": "string",
        "actionType": [
          "string"
        ]
      }
    ]
  },
  "error": null,
  "traceId": "TRACE_ID"
}

读取规则信息 ​

Request Syntax

http
GET /api/v1/rules/:id HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
idinteger是规则ID

Response Data

字段类型说明
idinteger规则ID
namestring规则名称
descrstring规则描述
ruleTypestring规则类型
dsTypestring设备来源类型:device_type 设备类型,device 设备。
dsSourcestring设备来源。dsType 为 device 时通常为设备码数组;dsType 为 device_type 时通常为设备类型标识数组。
msgCondsstring过滤条件
devicesDisablestring禁用设备
customTopicIdentifierstring自定义数据流标识符
eventKeystring事件标识
enabledinteger是否启用:0 未启用,1 已启用。
debugStatusinteger规则调试状态:0 未开启,1 已开启。
debugEnableTimeinteger规则调试时间
tenantIdstring租户ID
createdDeptinteger创建部门
createdByinteger创建者
createdAtstring创建时间
updatedByinteger更新者
updatedAtstring更新时间
dsSourceMapobject<string, string>设备信息
actionsarray<internal.model.XjRuleActionsListModelForRules>规则动作列表
actions[].idinteger动作ID
actions[].ruleIdinteger规则ID
actions[].typestring动作类型
actions[].namestring动作名称
actions[].optionsstring动作配置
actions[].orderNuminteger排序
actions[].createdAtstring创建时间

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "id": 1,
    "name": "名称",
    "descr": "描述",
    "ruleType": "string",
    "dsType": "string",
    "dsSource": "string",
    "msgConds": "string",
    "devicesDisable": "string",
    "customTopicIdentifier": "string",
    "eventKey": "string",
    "enabled": 1,
    "debugStatus": 1
  },
  "error": null,
  "traceId": "TRACE_ID"
}

设备上下线日志 ​

读取设备上下线日志列表 ​

Request Syntax

http
GET /api/v1/device/:deviceCode/online_logs HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
deviceCodestring是设备码

Query Parameters

参数类型必填说明
pageinteger否页码
pageSizeinteger否每页大小
keywordstring否关键字
idinteger否ID
createdAtarray<string>否创建时间

Response Data

字段类型说明
pageinteger
pageSizeinteger
totalinteger
itemsarray<internal.model.XjDeviceOnlineLogsListModel>数据列表
items[].idintegerID
items[].deviceCodestring设备码
items[].logTypeinteger日志类型:14 上线,15 下线。
items[].logReasonstring下线原因
items[].contentstring日志内容
items[].tenantIdstring租户ID
items[].createdAtstring创建时间

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "page": 1,
    "pageSize": 1,
    "total": 1,
    "items": [
      {
        "id": 1,
        "deviceCode": "DEVICE_CODE",
        "logType": 1,
        "logReason": "string",
        "content": "string"
      }
    ]
  },
  "error": null,
  "traceId": "TRACE_ID"
}

应用管理员 ​

应用管理员接口用于项目管理员登录应用并获得应用上下文,令牌载荷中包含 deviceType=saas、appId 与租户信息,除登录接口外均需在请求头携带该令牌。登录账号为项目中 saas_ 前缀(接口会自动补全前缀)的项目管理员账号,且账号需绑定项目管理员权限。

应用管理员登录 ​

Request Syntax

http
POST /api/v1/app-admin/login HTTP/1.1
Content-Type: application/json

Request Body

字段类型必填说明
appIdinteger是应用ID
usernamestring是用户名(项目管理员账号)
passwordstring是密码

Request Example

json
{
  "appId": 1,
  "username": "admin",
  "password": "PASSWORD"
}

Response Data

字段类型说明
accessTokenstring应用管理员令牌
expiresAtstring令牌过期时间
expiresIninteger令牌剩余有效时间(秒)
userinternal.model.AppAdminIdentity应用管理员身份信息
user.userIdinteger用户ID
user.usernamestring用户名
user.nickNamestring昵称
user.avatarstring头像
user.tenantIdstring租户ID
user.appIdinteger应用ID
user.privTypeinteger权限类型:1 超级管理员,2 普通用户。
user.permissionKeysarray<string>权限键列表,超级管理员返回全部权限键
appNamestring应用名称

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "accessToken": "ACCESS_TOKEN",
    "expiresAt": "2026-09-25T12:00:00+08:00",
    "expiresIn": 86400,
    "user": {
      "userId": 1,
      "username": "saas_admin",
      "nickName": "名称",
      "avatar": "string",
      "tenantId": "TENANT_ID",
      "appId": 1,
      "privType": 1,
      "permissionKeys": [
        "operate_device"
      ]
    },
    "appName": "名称"
  },
  "error": null,
  "traceId": "TRACE_ID"
}

获取当前应用管理员 ​

Request Syntax

http
GET /api/v1/app-admin/me HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Response Data

字段类型说明
userIdinteger用户ID
usernamestring用户名
nickNamestring昵称
avatarstring头像
tenantIdstring租户ID
appIdinteger应用ID
privTypeinteger权限类型:1 超级管理员,2 普通用户。
permissionKeysarray<string>权限键列表

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "userId": 1,
    "username": "saas_admin",
    "nickName": "名称",
    "avatar": "string",
    "tenantId": "TENANT_ID",
    "appId": 1,
    "privType": 1,
    "permissionKeys": [
      "operate_device"
    ]
  },
  "error": null,
  "traceId": "TRACE_ID"
}

刷新应用管理员令牌 ​

Request Syntax

http
POST /api/v1/app-admin/refresh HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Response Data

字段类型说明
accessTokenstring应用管理员令牌
expiresAtstring令牌过期时间
expiresIninteger令牌剩余有效时间(秒)
userinternal.model.AppAdminIdentity应用管理员身份信息
user.userIdinteger用户ID
user.usernamestring用户名
user.nickNamestring昵称
user.avatarstring头像
user.tenantIdstring租户ID
user.appIdinteger应用ID
user.privTypeinteger权限类型:1 超级管理员,2 普通用户。
user.permissionKeysarray<string>权限键列表,超级管理员返回全部权限键
appNamestring应用名称

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "accessToken": "ACCESS_TOKEN",
    "expiresAt": "2026-09-26T12:00:00+08:00",
    "expiresIn": 86400,
    "user": {
      "userId": 1,
      "username": "saas_admin",
      "nickName": "名称",
      "avatar": "string",
      "tenantId": "TENANT_ID",
      "appId": 1,
      "privType": 1,
      "permissionKeys": [
        "operate_device"
      ]
    },
    "appName": "名称"
  },
  "error": null,
  "traceId": "TRACE_ID"
}

应用管理员退出登录 ​

Request Syntax

http
POST /api/v1/app-admin/logout HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Response Data

无响应业务字段,服务端会将该令牌加入失效列表。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {},
  "error": null,
  "traceId": "TRACE_ID"
}

获取应用允许访问的看板 ​

Request Syntax

http
GET /api/v1/app-admin/boards HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Response Data

字段类型说明
itemsarray<internal.model.AppAdminBoardListItem>数据列表
items[].boardIdinteger看板ID
items[].namestring看板名称
items[].descriptionstring看板描述
items[].coverUrlstring看板封面地址

TIP

仅返回应用配置 appConfig.allowViews 中授权、且状态为 ACTIVE 的看板,返回顺序与配置顺序一致;未配置授权看板时 items 为空数组。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "items": [
      {
        "boardId": 1,
        "name": "名称",
        "description": "描述",
        "coverUrl": "string"
      }
    ]
  },
  "error": null,
  "traceId": "TRACE_ID"
}

获取应用看板 ​

Request Syntax

http
GET /api/v1/app-admin/boards/:boardId HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
boardIdinteger是看板ID

Response Data

字段类型说明
boardIdinteger看板ID
namestring看板名称
descriptionstring看板描述
layoutModestring布局模式
settingsJsonstring看板设置
languagestring看板语言
componentsarray<internal.model.VisualBoardPublicComponentModel>看板组件列表
components[].componentIdinteger组件ID
components[].componentTypestring组件类型
components[].namestring组件名称
components[].configJsonstring组件配置
components[].dataSourceJsonstring组件数据源配置
components[].posXinteger组件横坐标
components[].posYinteger组件纵坐标
components[].widthinteger组件宽度
components[].heightinteger组件高度
components[].zIndexinteger组件层级

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "boardId": 1,
    "name": "名称",
    "description": "描述",
    "layoutMode": "string",
    "settingsJson": "{}",
    "language": "zh-CN",
    "components": [
      {
        "componentId": 1,
        "componentType": "string",
        "name": "名称",
        "configJson": "{}",
        "dataSourceJson": "[]",
        "posX": 0,
        "posY": 0,
        "width": 0,
        "height": 0,
        "zIndex": 1
      }
    ]
  },
  "error": null,
  "traceId": "TRACE_ID"
}

获取应用看板数据 ​

Request Syntax

http
GET /api/v1/app-admin/boards/:boardId/data HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
boardIdinteger是看板ID

Response Data

字段类型说明
componentsobject<integer, array<internal.model.VisualBoardPublicPoint>>各组件最新数据,键为组件ID
components[].sourceIndexinteger数据源索引
components[].deviceCodestring设备码
components[].keystring属性或事件标识
components[].valueany数据值
components[].tsstring数据时间
errorsobject<integer, string>组件数据获取失败信息,键为组件ID

TIP

这里只返回看板组件已配置数据源中的设备最新值,不是通用的匿名设备查询接口。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "components": {
      "1": [
        {
          "sourceIndex": 0,
          "deviceCode": "DEVICE_CODE",
          "key": "temperature",
          "value": 25.6,
          "ts": "2026-09-25 12:00:00"
        }
      ]
    },
    "errors": {
      "2": "设备离线"
    }
  },
  "error": null,
  "traceId": "TRACE_ID"
}

SaaS 应用 ​

SaaS 应用接口用于获取应用公开配置与当前应用的项目、项目 MQTT 凭据。/api/v1/app-info 免登录,其余接口需要应用管理员令牌。

根据应用ID获取SaaS应用公开配置 ​

Request Syntax

http
GET /api/v1/app-info HTTP/1.1
Content-Type: application/json

Query Parameters

参数类型必填说明
appIdinteger是应用ID

Response Data

字段类型说明
appIdinteger应用ID
appNamestring应用名称
appDescrstring应用描述
appConfiginternal.model.SaasAppConfig应用功能开关配置
appConfig.allowEditDeviceInfoboolean是否允许编辑设备信息
appConfig.allowCreateDeviceboolean是否允许创建设备
appConfig.allowCreateDeviceGroupboolean是否允许创建设备分组
appConfig.allowEditDeviceGroupboolean是否允许编辑设备分组
appConfig.allowRunTaskboolean是否允许运行任务
appConfig.allowChangeTaskDeviceStatusboolean是否允许启停设备定时任务
appConfig.allowEditTaskCronSettingsboolean是否允许编辑任务定时设置
appConfig.allowCreateDeviceAlarmRuleboolean是否允许创建设备告警规则
appConfig.allowPauseDeviceAlarmRuleboolean是否允许启停设备告警规则
appConfig.allowEditDeviceAlarmRuleboolean是否允许编辑设备告警规则
appConfig.allowCreateNotificationGroupboolean是否允许创建通知组
appConfig.allowEditNotificationGroupboolean是否允许编辑通知组
appConfig.allowCreateDeviceAutomateRuleboolean是否允许创建设备自动化规则
appConfig.allowCreateUserboolean是否允许创建用户
appConfig.allowViewsarray<string>允许访问的看板ID列表
styleConfiginternal.model.SaasAppStyleConfig应用样式配置
styleConfig.globalStylePresetstring全局样式预设,固定为 architect
styleConfig.globalFixedHeaderboolean是否固定顶栏
styleConfig.globalFixedSidebarboolean是否固定侧边栏
styleConfig.globalFixedFooterboolean是否固定页脚
styleConfig.globalHeaderBackgroundModestring顶栏背景模式:solid 纯色,gradient 渐变
styleConfig.globalHeaderColorstring顶栏背景色
styleConfig.globalHeaderGradientColorstring顶栏渐变背景色
styleConfig.globalHeaderTextColorstring顶栏文字颜色
styleConfig.globalSidebarBackgroundModestring侧边栏背景模式:solid 纯色,gradient 渐变
styleConfig.globalSidebarColorstring侧边栏背景色
styleConfig.globalSidebarGradientColorstring侧边栏渐变背景色
styleConfig.globalSidebarTextColorstring侧边栏文字颜色
styleConfig.globalNavTabsActiveBackgroundColorstring导航页签选中背景色
styleConfig.globalNavTabsActiveTextColorstring导航页签选中文字颜色
styleConfig.globalNavTabsActiveFontBoldboolean导航页签选中是否加粗
styleConfig.globalPageTabsStylestring页面页签样式:line 线条,shadow 阴影
styleConfig.globalThemeDarkboolean是否使用暗色主题
styleConfig.globalColorPrimarystring主题色
styleConfig.signinShowBgImageboolean登录页是否显示背景图
styleConfig.signinBgImagestring登录页背景图
styleConfig.signinBgImageOpacitynumber登录页背景图透明度
styleConfig.signinDarkboolean登录页是否使用暗色主题
styleConfig.signinLogoImagestring登录页 Logo
styleConfig.signinBtnBgColorstring登录按钮背景色
styleConfig.signinTitleLayoutstring登录页标题布局

TIP

接口仅返回已启用(appStatus=1)且类型为 common_saas 的应用配置;未配置的样式项返回服务端默认值(如 globalPageTabsStyle 非 shadow 时返回 line,背景模式非 gradient 时返回 solid)。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "appId": 1,
    "appName": "名称",
    "appDescr": "描述",
    "appConfig": {
      "allowEditDeviceInfo": true,
      "allowCreateDevice": true,
      "allowCreateDeviceGroup": true,
      "allowEditDeviceGroup": true,
      "allowRunTask": true,
      "allowChangeTaskDeviceStatus": true,
      "allowEditTaskCronSettings": true,
      "allowCreateDeviceAlarmRule": true,
      "allowPauseDeviceAlarmRule": true,
      "allowEditDeviceAlarmRule": true,
      "allowCreateNotificationGroup": true,
      "allowEditNotificationGroup": true,
      "allowCreateDeviceAutomateRule": true,
      "allowCreateUser": true,
      "allowViews": [
        "1"
      ]
    },
    "styleConfig": {
      "globalStylePreset": "architect",
      "globalFixedHeader": true,
      "globalFixedSidebar": true,
      "globalFixedFooter": false,
      "globalHeaderBackgroundMode": "solid",
      "globalHeaderColor": "#ffffff",
      "globalHeaderGradientColor": "#ffffff",
      "globalHeaderTextColor": "#000000",
      "globalSidebarBackgroundMode": "solid",
      "globalSidebarColor": "#ffffff",
      "globalSidebarGradientColor": "#ffffff",
      "globalSidebarTextColor": "#000000",
      "globalNavTabsActiveBackgroundColor": "#ffffff",
      "globalNavTabsActiveTextColor": "#000000",
      "globalNavTabsActiveFontBold": false,
      "globalPageTabsStyle": "line",
      "globalThemeDark": false,
      "globalColorPrimary": "#1677ff",
      "signinShowBgImage": false,
      "signinBgImage": "",
      "signinBgImageOpacity": 1,
      "signinDark": false,
      "signinLogoImage": "",
      "signinBtnBgColor": "#1677ff",
      "signinTitleLayout": "left"
    }
  },
  "error": null,
  "traceId": "TRACE_ID"
}

获取当前应用项目 ​

Request Syntax

http
GET /api/v1/project/current HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Response Data

字段类型说明
idstring项目标识(租户ID)
namestring项目名称
appIdinteger应用ID
appNamestring应用名称
appTypestring应用类型,common_saas 表示通用 SaaS 应用

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "id": "TENANT_ID",
    "name": "名称",
    "appId": 1,
    "appName": "名称",
    "appType": "common_saas"
  },
  "error": null,
  "traceId": "TRACE_ID"
}

获取当前项目MQTT凭据 ​

Request Syntax

http
GET /api/v1/project/mqtt-credentials HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Response Data

字段类型说明
projectViewKeystring项目级 MQTT 订阅用户名
projectViewSecretstring项目级 MQTT 订阅密码

WARNING

该接口返回项目级 MQTT 订阅凭据,响应头带有 Cache-Control: no-store,请勿在客户端缓存或写入日志。项目未配置凭据时接口返回错误。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "projectViewKey": "PROJECT_VIEW_KEY",
    "projectViewSecret": "PROJECT_VIEW_SECRET"
  },
  "error": null,
  "traceId": "TRACE_ID"
}

应用用户 ​

应用用户接口用于管理应用(项目)下的终端用户账号及其设备绑定关系。查询类接口(列表、详情、关联设备)按令牌所属项目过滤数据,使用项目 API 访问令牌或应用管理员令牌均可调用;修改用户信息、重置用户密码、分配用户设备三个写操作要求应用管理员令牌,且管理员需具备对应的权限键(edit_user_info、reset_user_password、assign_user_device)。

获取应用用户列表 ​

Request Syntax

http
GET /api/v1/project_customers HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Query Parameters

参数类型必填说明
pageinteger否页码
pageSizeinteger否每页大小
keywordstring否关键字
idinteger否用户ID
namestring否用户名称
roleNamestring否角色名称
regFromTypeinteger否注册来源类型:1 平台创建,2 用户注册。
statusinteger否用户状态:1 已启用,2 未启用。
createdAtarray<string>否创建时间
sortstring否排序方式(earliest:创建最早,latest:创建最新,recent:最近访问,device_most:设备最多,device_least:设备最少,kanban_most:看板最多,kanban_least:看板最少)

Response Data

字段类型说明
pageinteger
pageSizeinteger
totalinteger
itemsarray<v1.XjProjectCustomersListModel>数据列表
items[].idinteger用户ID
items[].namestring用户名称
items[].descrstring用户描述
items[].accountstring登录名
items[].emailstring邮箱
items[].mobilestring手机
items[].roleIdinteger角色ID
items[].roleNamestring角色名称
items[].roleDescrstring角色描述
items[].roleColorstring角色颜色
items[].emailVerifiedinteger邮箱已验证:0 未验证,1 已验证。
items[].mobileVerifiedinteger手机已验证:0 未验证,1 已验证。
items[].wxBindedinteger微信绑定:0 未绑定,1 已绑定。
items[].lastVisitTimestring最后访问时间
items[].statusinteger用户状态:1 已启用,2 未启用。
items[].regFromTypeinteger注册来源类型:1 平台创建,2 用户注册。
items[].createdAtstring创建时间
items[].deviceCountinteger绑定设备数量

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "page": 1,
    "pageSize": 1,
    "total": 1,
    "items": [
      {
        "id": 1,
        "name": "名称",
        "descr": "描述",
        "account": "string",
        "email": "string",
        "mobile": "string",
        "roleId": 1,
        "roleName": "名称",
        "roleDescr": "描述",
        "roleColor": "string",
        "emailVerified": 1,
        "mobileVerified": 1,
        "wxBinded": 1,
        "lastVisitTime": "2026-09-25 12:00:00",
        "status": 1,
        "regFromType": 1,
        "createdAt": "2026-09-25 12:00:00",
        "deviceCount": 1
      }
    ]
  },
  "error": null,
  "traceId": "TRACE_ID"
}

获取应用用户详情 ​

Request Syntax

http
GET /api/v1/project_customers/:id HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
idinteger是用户ID

Response Data

字段与「获取应用用户列表」的 items[] 一致。用户不存在时返回业务错误。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "id": 1,
    "name": "名称",
    "descr": "描述",
    "account": "string",
    "email": "string",
    "mobile": "string",
    "roleId": 1,
    "roleName": "名称",
    "roleDescr": "描述",
    "roleColor": "string",
    "emailVerified": 1,
    "mobileVerified": 1,
    "wxBinded": 1,
    "lastVisitTime": "2026-09-25 12:00:00",
    "status": 1,
    "regFromType": 1,
    "createdAt": "2026-09-25 12:00:00",
    "deviceCount": 1
  },
  "error": null,
  "traceId": "TRACE_ID"
}

修改应用用户信息 ​

Request Syntax

http
PUT /api/v1/project_customers/:id HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
idinteger是用户ID

Request Body

字段类型必填说明
namestring是用户名称
descrstring否用户描述
emailstring否邮箱
mobilestring否手机

Request Example

json
{
  "name": "名称",
  "descr": "描述",
  "email": "string",
  "mobile": "string"
}

Response Data

字段类型说明
idinteger用户ID
namestring用户名称

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "id": 1,
    "name": "名称"
  },
  "error": null,
  "traceId": "TRACE_ID"
}

重置应用用户密码 ​

Request Syntax

http
PUT /api/v1/project_customers/:id/password HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
idinteger是用户ID

Request Body

字段类型必填说明
passwordstring是新密码
confirmPasswordstring是重复新密码

Request Example

json
{
  "password": "PASSWORD",
  "confirmPassword": "PASSWORD"
}

Response Data

无响应业务字段。两次输入的密码不一致时返回业务错误。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {},
  "error": null,
  "traceId": "TRACE_ID"
}

获取用户关联设备 ​

Request Syntax

http
GET /api/v1/project_customers/:id/devices HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
idinteger是用户ID

Query Parameters

参数类型必填说明
pageinteger否页码,默认 1
pageSizeinteger否每页大小,默认 20,最大 200

Response Data

字段类型说明
pageinteger
pageSizeinteger
totalinteger
itemsarray<v1.XjProjectCustomerDevice>数据列表
items[].idinteger设备关联ID,移除关联时作为 relationIds 传入
items[].deviceIdinteger设备ID
items[].deviceCodestring设备码
items[].deviceNamestring设备名称
items[].deviceTypeKeystring设备类型KEY
items[].deviceTypeNamestring设备类型名称
items[].deviceOnlineStatusstring设备在线状态
items[].deviceActiveAtinteger设备活跃时间
items[].deviceBindTimestring设备关联时间

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "page": 1,
    "pageSize": 20,
    "total": 1,
    "items": [
      {
        "id": 1,
        "deviceId": 1,
        "deviceCode": "DEVICE_CODE",
        "deviceName": "名称",
        "deviceTypeKey": "TYPE_KEY",
        "deviceTypeName": "名称",
        "deviceOnlineStatus": "online",
        "deviceActiveAt": 1626197189,
        "deviceBindTime": "2026-09-25 12:00:00"
      }
    ]
  },
  "error": null,
  "traceId": "TRACE_ID"
}

添加用户关联设备 ​

Request Syntax

http
POST /api/v1/project_customers/:id/devices HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
idinteger是用户ID

Request Body

字段类型必填说明
deviceCodesarray<string>是设备码列表

Request Example

json
{
  "deviceCodes": [
    "DEVICE_CODE"
  ]
}

Response Data

无响应业务字段。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {},
  "error": null,
  "traceId": "TRACE_ID"
}

移除用户关联设备 ​

Request Syntax

http
DELETE /api/v1/project_customers/:id/devices HTTP/1.1
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Path Parameters

参数类型必填说明
idinteger是用户ID

Request Body

字段类型必填说明
relationIdsarray<integer>是设备关联ID列表

Request Example

json
{
  "relationIds": [
    1
  ]
}

Response Data

无响应业务字段。关联ID不属于该用户时返回业务错误。

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {},
  "error": null,
  "traceId": "TRACE_ID"
}

服务信息 ​

服务信息 ​

Request Syntax

http
GET /api/v1/info HTTP/1.1
Content-Type: application/json

Response Data

字段类型说明
typestring
namestring
titlestring
descriptionstring
versionstring
buildstring
commitstring
dataobject<string, interface>

Response Example

json
{
  "code": 200,
  "message": "",
  "data": {
    "type": "string",
    "name": "名称",
    "title": "string",
    "description": "描述",
    "version": "string",
    "build": "string",
    "commit": "string",
    "data": {
      "key": {}
    }
  },
  "error": null,
  "traceId": "TRACE_ID"
}

全局定义 ​

通用响应格式 ​

枚举取值
设备通信方式 connProtocol1 WiFi,2 以太网,3 4G,4 5G,5 NB-IoT,6 RS485,7 RS232,8 RS422,9 LoRa,10 Zigbee,11 BLE,99 其他
设备接入类型 connType1 直连设备,2 子设备,3 网关设备
设备接入协议 msgProtocol1 内部标准,2 Modbus RTU 透传,3 Modbus TCP 透传,99 其他
设备在线状态 onlineStatus1 在线,2 离线
设备告警状态 alarmStatus1 未告警,2 告警中,3 普通告警,4 重要告警,5 紧急告警
设备活跃状态 activeStatus1 活跃,2 5 分钟内活跃,3 1 小时内活跃,4 1 天内活跃,20 不活跃,21 不活跃超过 1 天,22 不活跃超过 3 天,23 不活跃超过 7 天,30 从未活跃
告警级别 alarmLevel1 普通告警,2 重要告警,3 紧急告警
告警规则触发类型 triggerTypeattrs_changed 属性变化,inactive 设备不活跃,event_post 事件上报,online 设备在线,offline 设备离线
设备来源类型 dsTypedevice_type 设备类型,device 设备
数据模型属性类型 attrTypereport 设备上报,push 云端下发,share 设备云端共享,cloud 云端私有
数据模型数据类型 dataTypeinteger 整型,decimal 小数,string 字符串,bool 布尔型,enum 枚举型,array 数组型,object 对象型,map_point 地理坐标,map_circle 地理圆形围栏,map_polygon 地理多边形围栏,coords_point 平面坐标,coords_3d_point 三维坐标,daily_timer 每日定时器,daily_timer_range 每日定时区间
消息日志类型 logType1 属性上报,2 属性上报回复,3 事件上报,4 事件上报回复,5 属性设置,6 属性设置回复,7 功能调用,8 功能调用回复,9 连接事件,10 断开连接事件,11 心跳,12 设备获取平台属性,13 设备获取平台属性回复,14 上线,15 下线,16 属性采集,17 属性采集回复,18 批量上报,19 批量上报回复,20 自定义上报,21 自定义下发回复,22 获取期望值,23 获取期望值回复,24 清除期望值,25 清除期望值回复,26 文件上传,27 文件上传回复

应用侧枚举 ​

枚举取值
应用类型 appTypecommon_saas 通用 SaaS 应用
应用状态 appStatus1 已启用,2 已禁用
应用用户状态 status1 已启用,2 未启用
应用用户注册来源 regFromType1 平台创建,2 用户注册
应用用户邮箱验证 emailVerified0 未验证,1 已验证
应用用户手机验证 mobileVerified0 未验证,1 已验证
应用用户微信绑定 wxBinded0 未绑定,1 已绑定
管理员权限类型 privType1 超级管理员,2 普通用户
管理员权限键 permissionKeysoperate_device 操作设备,view_device_certificate 查看设备证书,edit_device_info 编辑设备信息,edit_device_group 编辑设备分组,change_device_task_status 启用/禁用设备定时任务,change_device_alarm_rule_status 启用/禁用设备告警规则,process_alarm 处理告警,create_user 创建用户,reset_user_password 重设用户密码,assign_user_device 给用户分配设备,edit_user_info 编辑用户信息,change_user_status 编辑用户状态
应用样式预设 globalStylePresetarchitect 建筑师风格(当前固定返回该值)
页面页签样式 globalPageTabsStyleline 线条,shadow 阴影
背景模式 backgroundModesolid 纯色,gradient 渐变
看板状态 statusACTIVE 已启用(仅此类看板可被应用访问)