map/docs/api/data.md
2024-10-21 09:13:15 +08:00

116 lines
2.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 数据访问接口
## API接口一览表
| 接口分类 | 接口描述 | API接口 | 权限 |
|--------|-------------|------------------------------| ---------------------------- |
| 数据查询 | 实时数据查询 | /api/data/snapshot | |
| | 历史区间数据查询 | /api/data/history | |
| | 历史断面数据查询 | /api/data/history/snapshot | |
## 数据查询接口
### 实时数据查询
POST 请求接口
> /api/data/snapshot
请求参数
```json
[
{
"deviceId":"129476828342323",
"attributes":["power","windSpeed","dailyUsageHours","monthlyUsageHours"]
},
{
"deviceId":"129476828342324",
"attributes":["power","windSpeed","dailyUsageHours","monthlyUsageHours"]
}
......
]
```
入参描述
| 参数名 | 参数类型 | 可选 | 描述 |
| ------------ | -------- | ---- |------|
| deviceId | String | no | 设备ID |
| attributes | StringArray | no | 要查询实时数据的设备属性列表 |
> PS: 当attributes为空时返回所有属性。
返回报文
```json
{
"code": 200,
"msg": "操作成功",
"success": true,
"data": {
"129476828342323":{
"power": 56.2,
"windSpeed": 45.3,
"dailyUsageHours": 20,
"monthlyUsageHours": 78,
....
},
"129476828342324":{
"power": 53.2,
"windSpeed": 35.3,
"dailyUsageHours": 10,
"monthlyUsageHours": 48,
....
}
}
}
```
返参描述
data 中以字典的方式,返回查询的每个设备的属性的实时值。
### 历史区间数据查询
POST 请求接口
> /api/data/history
请求参数
```json
{
"deviceId":"129476828342323",
"attributes":["power","windSpeed","dailyUsageHours","monthlyUsageHours"]
}
```
入参描述
| 参数名 | 参数类型 | 可选 | 描述 |
| ------------ | -------- | ---- |------|
| deviceId | String | no | 设备ID |
| attributes | StringArray | no | 要查询实时数据的设备属性列表 |
返回报文
```json
{
"code": 200,
"msg": "操作成功",
"success": true,
"data": {
"power": 56.2,
"windSpeed": 45.3,
"dailyUsageHours": 20,
"monthlyUsageHours": 78,
....
}
}
```
返参描述
data 中以字典的方式,返回查询的属性的实时值。