Anxinyun API

欢迎使用 Anxinyun API ,这些 API 提供了访问 Anxinyun 基本的数据接口。

通用说明

返回状态说明

状态码 名称 含义
200 OK 请求成功
204 No Content 服务器成功处理了请求,但不返回任何实体内容
400 BAD REQUEST POST请求失败或GET请求参数有误
401 UNAUTHORIZED 未授权:接口请求缺少token或者token无效
403 FORBIDDEN 禁止访问:请求的资源被服务器拒绝
404 NOT FOUND 请求的资源不存在
500 INTERNAL SERVER ERROR 内部服务器错误

认证

Anxinyun API 主要面向开发者的 APP 应用,因此认证是针对开发者的 APP 应用。实现上基于 OAuth 2 规范的 客户端授权 流程。

术语/关键字段

术语 描述 说明
App ID 系统为开发者创建的应用所分配的ID
App Secret 系统为开发者创建的应用所分配的Secret 与App ID组合(编码后)作为认证接口中所需的 Authorization;开发者根据项目获得独立的App ID及App Secret
grant_type OAuth2中规定的授权模式 客户端授权流程中主要有两类:client_credentials / refresh_token
token API接口访问令牌 Anxinyun API 为通过认证的应用分配的访问凭证
Authorization 需要在请求认证接口的Headers中提供的凭证 得到访问令牌前,一般由 App ID / App Secret组后(编码后)构成;得到访问令牌后,一般填写访问令牌

注意

虽流程上参考 OAuth2,但 Anxinyun 中通过认证的 APP 应用等同于用户本身,权限很高,使用上需保障 App ID / App Secret 的严格保密。同时,必须使用HTTPS访问 Anxinyun API,包括认证接口。

流程

在访问 Anxinyun API 时,除去一些静态资源接口,都必须通过认证,主要流程:

  1. 获取访问令牌 接口进行认证,并得到系统返回的访问令牌;

  2. 然后通过携带 访问令牌 来发起请求;

  3. 默认情况下,为了减少 访问令牌 的危险窗口期,访问令牌的超时时间是30天,访问令牌过期后(过期前亦可),应用可通过 更新访问令牌 接口来重新获得 访问令牌,因此,为了保证应用的长时间运行,应用应有一定 访问令牌 更新策略;

  4. 同时,应用也可以通过 作废访问令牌 接口来废弃 访问令牌。

POST https://openapi.anxinyun.cn/api/v1/oauth2/token
Requestsexample 1
Headers
POST: /oauth2/token HTTP/1.1
Host: openapi.anxinyun.cn
Authorization: Basic MzVjMmFjYTVkYjY2YmQ4NzFiNWY5YThkN2VjM2FlZDkwOTQ1M2I5YTpkMDMzZTIyYWUzNDhhZWI1NjYwZmMyMTQwYWVjMzU4NTBjNGRhOTk3
Content-Type: application/x-www-form-urlencoded;charset=UTF-8
Body
grant_type=client_credentials
Responses200400
Headers
Content-Type: application/json; charset=utf-8
Content-Encoding: gzipd
Body
{
  "token": "a5dfe02f-162b-4267-9046-44039ffba709",
  "expires_in": "2017-10-24T16:00:00.000Z"
}
Headers
Content-Type: application/json
Body
{
  "name": "RequestError",
  "message": "访问令牌获取失败"
}

获取访问令牌
POST/oauth2/token

编码 App ID / App Secret

将应用程序的 App ID 和 App Secret 编码为一组凭据,以获取访问令牌:

  1. 根据RFC 1738对 App ID 和 App Secret 进行编码。通常情况下,系统生成的 App ID / App Secret 没有特殊字符,编码前后没有变化;

  2. 将编码后的 App ID 与 App Secret 通过":“连接为一个字符串;

  3. 使用Base64对上一步中的字符串进行编码。

样例

字段
App ID 35c2aca5db66bd871b5f9a8d7ec3aed909453b9a
App Secret d033e22ae348aeb5660fc2140aec35850c4da997
RFC 1738 编码App ID 35c2aca5db66bd871b5f9a8d7ec3aed909453b9a
RFC 1738 编码App Secret d033e22ae348aeb5660fc2140aec35850c4da997
Authorization 35c2aca5db66bd871b5f9a8d7ec3aed909453b9a:d033e22ae348aeb5660fc2140aec35850c4da997
Base64 编码 Authorization MzVjMmFjYTVkYjY2YmQ4NzFiNWY5YThkN2VjM2FlZDkwOTQ1M2I5YTpkMDMzZTIyYWUzNDhhZWI1NjYwZmMyMTQwYWVjMzU4NTBjNGRhOTk3

认证

使用编码后的 Authorization 通过认证接口获取访问令牌:

HTTP Request

POST /api/v1/oauth2/token

接口要求:

  1. 请求必须是HTTP POST请求

  2. Headers 中包含 Authorization 信息, Authorization : Basic <编码后的 Authorization>

  3. Content-Type = application/x-www-form-urlencoded;charset=UTF-8

  4. 请求正文为:grant_type=client_credentials

注意

每次调用都会产生一个新的访问令牌。


GET https://openapi.anxinyun.cn/api/v1/structures?token=a5dfe02f-162b-4267-9046-44039ffba709
Responses200400
Headers
Content-Type: application/json
Body
[
    {
        "id": 1, // {number} 结构物id
        "name": "xxx结构物", // {string} 结构物名称
        "type": { // {object} 结构物类型
            "id": 1, // {number} 类型id
            "name": "桥梁" // {string} 类型名称
        },
        "latitude": 100.345, // {number} 纬度
        "longitude": 103.231, // {number} 经度
        "portrait": "xxx.png", // {string} 结构物图片
        "projects": [  // {array[object] || empty} 结构物归属的项目列表,如果结构物未配置到任何项目下,则该属性值为 []
            {
                "id": 1, // {number} 项目id
                "name": "xxx健康监测平台" // {string} 项目名称
            }
        ]
    }
]
Headers
Content-Type: application/json
Body
{
  "name": "FindError",
  "message": "全部结构物获取失败"
}

通过令牌发起请求
GET/structures{?token}

获取访问令牌后,即可访问 Anxinyun API。以 查询所有结构物API 为例:

URI Parameters
HideShow
token
uuid (required) Example: a5dfe02f-162b-4267-9046-44039ffba709

访问令牌


POST https://openapi.anxinyun.cn/api/v1/oauth2/token/refresh
Requestsexample 1
Headers
POST: /oauth2/token/refresh HTTP/1.1
Host: openapi.anxinyun.cn
Authorization: Basic MzVjMmFjYTVkYjY2YmQ4NzFiNWY5YThkN2VjM2FlZDkwOTQ1M2I5YTpkMDMzZTIyYWUzNDhhZWI1NjYwZmMyMTQwYWVjMzU4NTBjNGRhOTk3
Content-Type: application/x-www-form-urlencoded;charset=UTF-8
Body
grant_type=refresh_token&token=a5dfe02f-162b-4267-9046-44039ffba709
Responses200400
Headers
Content-Type: application/json; charset=utf-8
Content-Encoding: gzipd
Body
{
  "token": "b6fd7509-e3f2-439e-98d5-cb5cc42ba15c",
  "expires_in": "2017-11-23T16:00:00.000Z"
}
Headers
Content-Type: application/json
Body
{
  "name": "RequestError",
  "message": "访问令牌刷新失败"
}

刷新访问令牌
POST/oauth2/token/refresh

当令牌过期或其他原因失效时,需应用主动更新令牌:

HTTP Request

POST /api/v1/oauth2/token/refresh

接口要求:

  1. 请求必须是HTTP POST请求

  2. Headers 中包含 Authorization 信息, Authorization : Basic <编码后的 Authorization>

  3. Content-Type = application/x-www-form-urlencoded;charset=UTF-8

  4. 请求正文为:grant_type=refresh_token&token=a5dfe02f-162b-4267-9046-44039ffba709

注意

刷新访问令牌的作用在需要用户授权的 OAuth2 场景下更有意义(避免用户再次授权)。为了保持完备性而实现。


POST https://openapi.anxinyun.cn/api/v1/oauth2/token/invalidate
Requestsexample 1
Headers
POST: /oauth2/token/invalidate HTTP/1.1
Host: openapi.anxinyun.cn
Authorization: Basic MzVjMmFjYTVkYjY2YmQ4NzFiNWY5YThkN2VjM2FlZDkwOTQ1M2I5YTpkMDMzZTIyYWUzNDhhZWI1NjYwZmMyMTQwYWVjMzU4NTBjNGRhOTk3
Content-Type: application/x-www-form-urlencoded;charset=UTF-8
Body
token=a5dfe02f-162b-4267-9046-44039ffba709
Responses204400
Headers
Content-Type: application/json
Headers
Content-Type: application/json
Body
{
  "name": "RequestError",
  "message": "访问令牌作废失败"
}

作废访问令牌
POST/oauth2/token/invalidate

某些情况下,应用需要主动作废访问令牌,可通过以下接口:

HTTP Request POST /api/v1/oauth2/token/invalidate


结构物

结构物部分的资源集合

获取结构物

GET https://openapi.anxinyun.cn/api/v1/structures
Responses200400
Headers
Content-Type: application/json
Body
[
    {
        "id": 1, // {number} 结构物id
        "name": "xxx结构物", // {string} 结构物名称
        "type": { // {object} 结构物类型
            "id": 1, // {number} 类型id
            "name": "桥梁" // {string} 类型名称
        },
        "latitude": 100.345, // {number} 纬度
        "longitude": 103.231, // {number} 经度
        "portrait": "xxx.png", // {string} 结构物图片
        "projects": [  // {array[object] || empty} 结构物归属的项目列表,如果结构物未配置到任何项目下,则该属性值为 []
            {
                "id": 1, // {number} 项目id
                "name": "xxx健康监测平台" // {string} 项目名称
            }
        ]
    }
]
Headers
Content-Type: application/json
Body
{
  "name": "FindError",
  "message": "结构物获取失败"
}

获取结构物
GET/structures

获取全部结构物


监测因素

监测因素部分的资源集合

获取结构物下监测因素

GET https://openapi.anxinyun.cn/api/v1/structures/1/factors?display
Responses200400
Headers
Content-Type: application/json
Body
[
    {
        "id": 1, // {number} 监测因素id
        "name": "温湿度监测", // {string} 监测因素名称
        "items": [ // {array[object]} 监测项数组
            {
                "index": 0, // {number} 监测项index,从“0”开始
                "name": "温度", // {string} 监测项名称
                "unit": "℃", // {string} 监测项单位
                "precision": 0.1 // {decimal} 精度
            }
        ],
        "checked": true, // {boolean, optional(display格式时缺省)} 结构物是否已配置该监测因素,{true:已配置, false:未配置}
        "timeDivision": true // {boolean, optional(display格式时可见)} 是否可配置分时阈值
    }
]
Headers
Content-Type: application/json
Body
{
    "name": 'FindError',
    "message": "结构物下监测因素获取失败"
}

获取结构物下监测因素
GET/structures/{structureId}/factors?display

URI Parameters
HideShow
structureId
number (required) Example: 1

结构物id

display
boolean (optional) Example: ``

只展示已配置因素


测点

测点部分的资源集合

获取结构物下测点

GET https://openapi.anxinyun.cn/api/v1/structures/1/stations?factorId=1
Responses200400
Headers
Content-Type: application/json
Body
[
    {
        "factorId": 1, // {number} 监测因素id
        "factorName": "内部位移监测", // {string} 监测因素名称
        "groups": [ // {array[object]} 测点分组
            {
                "id": 1, // {number} 分组id
                "name": "测斜分组", // {string} 分组名称
                      "typeId": "101", // {string} 分组类型id
                      "params": {}, // {object} 分组参数定义
                "stations": [ // {array[object]} 测点集合
                    {
                        "id": 1, // {number} 测点id
                        "name": "CX-1", // {string} 测点名称
                        "portrait": "xxx.png", // {string} 测点图片
                        "labels": ["向阳", "向阴"], // {array[string]} 测点标签
                        "groupParams": { // {object} 测点的参数值
                            "distance": 100
                        },
                        "multiParams": { // {object, optional} 存在组合时提供
                            "E": 0.001,
                            "μ": 0.34,
                            "shape": "三片直角形"
                        }
                    }
                ]
            }
        ]
    }
]
Headers
Content-Type: application/json
Body
{
  "name": "FindError",
  "message": "结构物下测点获取失败"
}

获取结构物下测点
GET/structures/{structureId}/stations{?factorId}

获取结构物下测点

URI Parameters
HideShow
structureId
number (required) Example: 1

结构物id

factorId
number (optional) Example: 1

监测因素id


监测数据

监测数据部分的资源集合

获取监测因素数据

GET https://openapi.anxinyun.cn/api/v1/stations/theme/data?stations=2,3,4&startTime=2017-06-01 15:15:15&endTime=2017-06-02 15:15:15&limit=50
Responses200400
Headers
Content-Type: application/json
Body
{
    "items": { // {object} 主题监测项集合
        "temperature": { // {object} 监测项
            "name": "温度", // {string} 监测项显示名称
            "unit": "℃" // {string} 监测项数据单位
        },
        "humidity": { // {object} 监测项
            "name": "湿度", // {string} 监测项显示名称
            "unit": "%RH" // {string} 监测项数据单位
        }
    },
    "stations": [{ // {array[object]} 测点集合
        "id": 2, // {number} 测点id
        "name": "TH-02", // {string} 测点显示名称
        "data": [{ // {array[object]} 数据集合
            "temperature": 10.34, // {decimal} 监测项数值
            "humidity": 68.4582 // {decimal} 监测项数值
            "time": "2017-08-28 10:15:15" // {datetimeString} 主题数据采集时间
        }]
    }, {
        "id": 3, // {number} 测点id
        "name": "TH-03", // {string} 测点显示名称
        "data": [{ // {array[object]} 数据集合
            "temperature": 10.34, // {decimal} 监测项数值
            "humidity": 68.4582 // {decimal} 监测项数值
            "time": "2017-08-28 10:15:15" // {datetimeString} 主题数据采集时间
        }]
    }, {
        "id": 4, // {number} 测点id
        "name": "TH-04", // {string} 测点显示名称
        "data": [{ // {array[object]} 数据集合
            "temperature": 10.34, // {decimal} 监测项数值
            "humidity": 68.4582 // {decimal} 监测项数值
            "time": "2017-08-28 10:15:15" // {datetimeString} 主题数据采集时间
        }]
    }]
}
Headers
Content-Type: application/json
Body
{
  "name": "FindError",
  "message": "数据查询失败"
}

获取监测因素数据
GET/stations/theme/data?stations={stations}&startTime={startTime}&endTime={endTime}&limit={limit}

URI Parameters
HideShow
stations
string (required) Example: 2,3,4

测点id数组,逗号分开

startTime
datetimeString (required) Example: 2017-06-01 15:15:15

查询起始时间

endTime
datetimeString (required) Example: 2017-06-02 15:15:15

查询截止时间

limit
number (optional) Example: 50

每个测点取时间倒序的前limit条, :::设置limit参数时, 可以缺省startTime(以endTime倒序取limit)或endTime(全部数据倒序取limit):::


根据测点查询主题数据和原始数据

POST https://openapi.anxinyun.cn/api/v1/structures/1/factors/2/stations/data?startTime=2017-06-01 15:15:15&endTime=2017-06-02 15:15:15
Requestsexample 1
Headers
Content-Type: application/json
Body
{
    "stations": [1, 2] // {array[int]} 多个测点id
}
Responses200400
Headers
Content-Type: application/json
Body
{
    "theme": { // {object} 主题数据
        "items": { // {object} 主题监测项集合
            "temperature": { // {object} 监测项
                "name": "温度", // {string} 监测项显示名称
                "unit": "℃" // {string} 监测项数据单位
            },
            "humidity": { // {object} 监测项
                "name": "湿度", // {string} 监测项显示名称
                "unit": "%RH" // {string} 监测项数据单位
            }
        },
        "stations": [{ // 测点集合
            "id": 1, // {number} 测点id
            "name": "TH-01", // {string} 测点显示名称
            "data": [{ // 主题数据集合
                "values": { // {object} 主题数据
                    "temperature": 10.34, // {decimal} 监测项数值
                    "humidity": 68.4582 // {decimal} 监测项数值
                },
                "time": "2017-08-28 10:15:15" // {datetimeString} 主题数据采集时间
            }]
        }]
    },
    "raw": { // {object} 原始数据
        "items": { // {object} 原始监测项集合
            "temperature": {
                "name": "温度",  // {string} 监测项显示名称
                "unit": "℃" // {string} 监测项数据单位
            },
            "humidity": {
                "name": "湿度", // {string} 监测项显示名称
                "unit": "%RH" // {string} 监测项数据单位
            }
        },
        "sensors": [{ // 传感器集合
            "id": "7526b571-2f37-4647-a46c-723eca475440", // {uuid} 传感器的iota_uuid
            "name": "xxx传感器", // {string} 传感器显示名称
            "data": [{ // 原始数据集合
                "values": { // {object} 原始数据
                    "temperature": 10.34, // {decimal} 监测项数值
                    "humidity": 68.4582 // {decimal} 监测项数值
                },
                "time": "2017-08-28 10:15:15" // {datetimeString} 原始数据采集时间
            }]
        }]
    }
}
Headers
Content-Type: application/json
Body
{
  "name": "FindError",
  "message": "主题数据和原始数据查询失败"
}

根据测点查询主题数据和原始数据
POST/structures/{structureId}/factors/{factorId}/stations/data{?startTime}{&endTime}

查询测点的主题数据,以及该测点对应设备的原始数据

URI Parameters
HideShow
structureId
number (required) Example: 1

结构物id

factorId
number (required) Example: 2

监测因素id

startTime
datetimeString (required) Example: 2017-06-01 15:15:15

查询起始时间

endTime
datetimeString (required) Example: 2017-06-02 15:15:15

查询截止时间


获取车流量信息

GET https://openapi.anxinyun.cn/api/v1/structures/1/traffic-flow?startTime=2017-06-01 15:15:15&endTime=2017-06-01 15:15:15&overload=true&license=京A00001&loadFloor=10
Responses200400
Headers
Content-Type: application/json
Body
{
    "items": {
        "license": {
            "name": "车牌", // {string} 显示名称
        },
        "time": {
            "name": "时间", // {string} 显示名称
        },
        "lane": {
            "name": "车道", // {string} 显示名称
        },
        "direction": {
            "name": "方向", // {string} 显示名称
        },
        "axleCount": {
            "name": "轴数", // {string} 显示名称
        },
        "load": {
            "name": "车重", // {string} 显示名称
            "unit": "吨" // {string} 单位
        },
        "axleLoad": {
            "name": "轴重", // {string} 显示名称
            "unit": "吨" // {string} 单位
        },
        "overload": {
            "name": "超载", // {string} 显示名称
        }
    },
    "data": [{ // {array[object]} 数据集合
        "license": "京A00001", // {string} 车牌号
        "time": "2017-06-01 15:15:15", // {datetimeString} 采集时间
        "lane": "", // {string} 车道
        "direction": 0, // {integer} 车道方向,{0:上桥方向, 1:下桥方向}
        "axleCount": 4, // {integer} 车轴数
        "load": 3.4, // {decimal} 载荷
        "axleLoad": "", // {string} 轴重描述
        "overload": true // {boolean} 是否超载,{true:超载, false:未超载}
    }]
}
Headers
Content-Type: application/json
Body
{
  "name": "FindError",
  "message": "车流量信息获取失败"
}

获取车流量信息
GET/structures/{structureId}/traffic-flow?startTime={startTime}&endTime={endTime}&overload={overload}&license={license}&loadFloor={loadFloor}

URI Parameters
HideShow
structureId
number (required) Example: 1

结构物id

startTime
datetimeString (required) Example: 2017-06-01 15:15:15

起始时间

endTime
datetimeString (required) Example: 2017-06-01 15:15:15

结束时间

overload
boolean (optional) Example: true

是否超重

license
string (optional) Example: 京A00001

车牌号

loadFloor
number (optional) Example: 10

车重下限


振动数据

collectTime 获取说明

以下两个接口中的 collectTime 表示振动触发时刻:

  • 获取振动原始数据 GET /stations/{stationId}/vibration/raw?collectTime={collectTime}

  • 获取振动频谱数据 GET /stations/{stationId}/vibration/fft?collectTime={collectTime}

获取方式如下:

  1. 通过 获取监测因素数据 GET /stations/theme/data?stations={stations}&startTime={startTime}&endTime={endTime}&limit={limit} 接口查询,获取到测点的振动触发时刻:stations -> data -> time 属性值
  2. time 带入振动数据查询接口参数 collectTime,查询某个振动触发时刻(也称“振动批次”)的振动数据
GET https://openapi.anxinyun.cn/api/v1/stations/1/vibration/raw?collectTime=2017-06-01 15:15:15
Responses200400
Headers
Content-Type: application/json
Body
{
    "config": {
        "unit": "m/s", // {string} 单位
        "sampleFreq": "1024Hz", // {string} 采样频率
        "count": 1024, // {number} 采样点数
    },
    "data": [{ // {array[object]} 振动幅值
        "value": "0.23", // {string} 幅值
        "time": "1" // {string} 相对振动触发时刻,监测数据点的序号,从“1”开始
    }]
}
Headers
Content-Type: application/json
Body
{
  "name": "FindError",
  "message": "数据查询失败"
}

获取振动原始数据
GET/stations/{stationId}/vibration/raw?collectTime={collectTime}

URI Parameters
HideShow
stationId
number (required) Example: 1

测点id

collectTime
datetimeString (required) Example: 2017-06-01 15:15:15

采集时间


GET https://openapi.anxinyun.cn/api/v1/stations/1/vibration/fft?collectTime=2017-06-01 15:15:15
Responses200400
Headers
Content-Type: application/json
Body
{
    "config": {
        "unit": "m/s", // {string} 单位
        "sampleFreq": "1024Hz", // {string} 采样频率
        "count": 1024, // {number} 采样点数
    },
    "data": [{ // {array[object]} 振动频率
        "value": "0.23", // {string} 幅值
        "frequency": "0.12" // {string} 频率
    }]
}
Headers
Content-Type: application/json
Body
{
  "name": "FindError",
  "message": "数据查询失败"
}

获取振动频谱数据
GET/stations/{stationId}/vibration/fft?collectTime={collectTime}

URI Parameters
HideShow
stationId
number (required) Example: 1

测点id

collectTime
datetimeString (required) Example: 2017-06-01 15:15:15

采集时间


阈值

阈值配置的资源集合

获取结构物监测因素阈值配置

GET https://openapi.anxinyun.cn/api/v1/structures/1/factors/1/threshold/batches
Responses200400
Headers
Content-Type: application/json
Body
[
    {
        "batchNo": "b0293ce7-ed01-40da-8cf4-8b6844d794c6", // {uuid} 批量配置阈值时的批次号
        "data": {
            "items": [ // {array[object]} 监测因素下各监测项阈值配置
                {
                    "id": 1, // {number} 监测项id
                    "name": "x方向位移", // {string} 监测项名称
                    "unit": "mm", // {string} 监测项单位
                    "timeDivision": false, // {boolean} 监测项是否使用分时阈值配置,{true:使用分时阈值配置, false:不使用分时阈值配置},通常,噪声监测需要进行分时阈值配置
                    "config": [{ // {array[object]} 阈值配置
                        "startTime": null, // {datetimeString | null} 进行分时阈值配置时,某个分时段的起始时间,否则,为空
                        "endTime": null, // {datetimeString | null} 进行分时阈值配置时,某个分时段的截止时间,否则,为空
                        "thresholds": [{ // {array[object]} 配置的阈值
                            "level": 1, // {number} 配置的阈值等级
                            "value": "(-,-0.129);(0.129,+)" // {string} 阈值等级对应的阈值区间
                        }]
                    }]
                }
            ],
            "stations": [ // {array[object]} 测点列表
                {
                    "id": 1, // {number} 测点id
                    "name": "CD-1" // {string} 测点名称
                }
            ]
        },
    }
]
Headers
Content-Type: application/json
Body
{
  "name": "FindError",
  "message": "阈值配置获取失败"
}

获取结构物监测因素阈值配置
GET/structures/{structId}/factors/{factorId}/threshold/batches

获取结构物监测因素阈值配置

分时阈值配置

分时阈值配置通常用于噪声监测的阈值配置,比如,参照《中华人民共和国噪音污染防治法》对“夜间”的定义:晚二十二点至晨六点之间的期间,可以对噪声监测的“等效声级(dB)”监测项配置如下阈值:

时间段 一级阈值 说明
0时-6时 (55,+) 在00:00-06:00分时段内(夜间),若等效声级>=55dB,则系统将产生超一级阈值告警
6时-22时 (70,+) 在06:00-22:00分时段内(白昼),若等效声级>=70dB,则系统将产生超一级阈值告警
22时-24时 (55,+) 在22:00-24:00分时段内(夜间),若等效声级>=55dB,则系统将产生超一级阈值告警
URI Parameters
HideShow
structId
number (required) Example: 1

结构物id

factorId
number (required) Example: 1

监测因素id


告警

告警部分的资源集合

告警管理

GET https://openapi.anxinyun.cn/api/v1/users/1/alarms/new/count
Responses200400
Headers
Content-Type: application/json
Body
{
    "count": 100 // {number} 告警总数
}
Headers
Content-Type: application/json
Body
{
  "name": "FindError",
  "message": "告警数获取失败"
}

获取用户告警数量
GET/users/{userId}/alarms/{status}/count

获取用户告警数量

URI Parameters
HideShow
userId
number (required) Example: 1

用户id

status
enum (required) Example: new

告警状态,{“new”:新告警, “history”:历史告警}

Choices: new history


POST https://openapi.anxinyun.cn/api/v1/users/1/alarms?limit=20&offset=0&orderBy=level&orderDirection=asc
Requestsexample 1
Headers
Content-Type: application/json
Body
{
    "structures": [1, 2], // {array[int], optional} 结构物id数组
    "status": "new", // {string, optional} 告警状态,{"new":新告警, "history":历史告警}
    "levels": [1, 2, 3, 4], // {array[int], optional} 告警等级数组
    "types": [1, 2, 3, 4, 5], // {array[int], optional} 告警子类型id数组:{1:数据异常, 2:DTU异常, 3:传感器异常, 4:网关异常, 5:节点异常}
    "startTime": "2017-06-01 08:00:00", // {datetimeString, optional} 查询起始时间
    "endTime": "2017-06-06 10:30:30", // {datetimeString, optional} 查询终止时间
    "keywords": "cx-1", // 告警源和告警内容的关键字搜索
}
Responses200400
Headers
Content-Type: application/json
Body
{
    "count": 100,
    "alarms": [
        {
            "structureId": 1,
            "structureName": "xxx结构物",
            "alarms": [
                {
                    "id": 1, // {number} 告警id
                    "source": { // {object} 产生告警的对象(即,告警源)
                        "id": "58dad687-0ca6-4e63-b644-5316483efc6e", // {string}, 对象id,可以是设备的iota_uuid,也可以是测点id
                        "name": "20120049" // {string} 对象名称
                    },
                    "sourceType": { // {object} 告警源类型,{0:DTU, 1:传感器, 2:测点}
                        "id": 0, // {number} 类型id
                        "name": "DTU" // {string} 类型名称
                    },
                    "alarmTypeCode": "2001", // {string} 告警类型码
                    "level": 1, // {number} 告警等级
                    "content": "DTU下线", // {string} 告警信息
                    "count": 1, // {number} 告警产生的次数
                    "state": 0, // 告警状态,{0:告警新创建, 1:告警重复产生, 2:告警等级提升, 3:告警已自动消除, 4:告警已人工确认}
                    "startTime": "2017-06-13 08:00:00", // {datetimeString} 告警产生时间
                    "endTime": "2017-06-13 18:00:00" // {datetimeString} 告警更新时间
                }
            ]
        }
    ]
}
Headers
Content-Type: application/json
Body
{
  "name": "FindError",
  "message": "告警获取失败"
}

获取用户告警信息
POST/users/{userId}/alarms{?limit}{&offset}{&orderBy}{&orderDirection}

获取用户告警信息,支持分页与排序功能

URI Parameters
HideShow
userId
number (required) Example: 1

用户id

limit
number (optional) Default: 20 Example: 20

每页数量

offset
number (optional) Default: 0 Example: 0

在符合条件的记录中偏移的记录数

orderBy
enum (optional) Default: level Example: level

排序字段

Choices: level count startTime endTime

orderDirection
enum (optional) Default: asc Example: asc

排序方向,{“desc”:降序, “asc”:升序}

Choices: desc asc


GET https://openapi.anxinyun.cn/api/v1/alarms/1/details
Responses200400
Headers
Content-Type: application/json
Body
[
    {
        "sponsor": "et", // {string} 告警详情发起者,比如"et",用户确认告警时的`${userId}`
        "alarmCode": "20010001", // {string} 告警码
        "alarmState": 0, // {number} 告警状态: {0:新建, 1:升级(等级不变,次数升级), 2:升级(等级升级), 3:自动消除, 4:手动消除}
        "currentLevel": 1, // {number} 当前告警等级
        "content": "DTU下线", // {string} 告警详情内容
        "time": "2017-06-13 10:00:30" // {datetimeString} 告警详情时间
    }
]
Headers
Content-Type: application/json
Body
{
  "name": "FindError",
  "message": "告警详情获取失败"
}

获取告警详情
GET/alarms/{alarmId}/details

获取一条告警的详细信息

URI Parameters
HideShow
alarmId
number (required) Example: 1

告警id


摄像头

摄像头的资源信息

获取项目下的摄像头

GET https://openapi.anxinyun.cn/api/v1/user/camera/list
Responses200400
Headers
Content-Type: application/json
Body
[
  {
    "id": 576,
    "location": "AZ1696248",
    "serialNo": "AZ1696248",
    "channelNo": 2,
    "hasPTZ": false,
    "type": "yingshi",
    "IPCstructure": 4053
  }
]
Headers
Content-Type: application/json
Body
{
  "name": "FindError",
  "message": "获取项目下的摄像头失败"
}

获取项目下的摄像头
GET/user/camera/list

获取项目下的摄像头信息


获取摄像机播放地址

POST https://openapi.anxinyun.cn/api/v1/camera/info
Responses200400
Headers
Content-Type: application/json
Body
{
  "data": {
    "expireTime": "2025-04-01 16:29:50",
    "hls_url": "https://open.ys7.com/v3/openlive/AB4975345_1_2.m3u8?expire=1743496190&id=827218084543598592&t=6fcb0f99eb723af25cc2239c3d5b9cf037a5eb0901d260a57c2ce6d6e947be5c&ev=100"
  }
}
Headers
Content-Type: application/json
Body
{
  "name": "FindError",
  "message": "获取摄像机播放地址失败"
}

获取摄像机播放地址
POST/camera/info

获取摄像机播放地址信息

  • Body Parameters

    • serialNo: `` (string, required) - 设备序列号
    • channelNo: 1 (number, optional) - 通道号 默认:1
    • protocol: `` (string, required) - 流播放协议 例如:‘hls,rtmp,flv’
    • quality: d (string, optional) - 视频清晰度 例如:h(高清),d(标清) 默认:d
    • expireTime: 1800 (number, optional) - 过期时长 30秒-720天(以秒计数) 默认:1800

Generated by aglio on 01 Apr 2025