jdeip/API.md

186 lines
3.9 KiB
Markdown
Raw Permalink 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.

## EIP API 文档
**Base URL**: `https://smart.jdbox.xyz:58001`
### 鉴权
- **名称**: API 鉴权
- **方法**: POST
- **路径**: `/client/auth`
- **请求头**:
- `Content-Type: application/json`
- **请求体**:
```json
{
"username": "<你的用户名>",
"password": "<你的密码>"
}
```
- **说明**: 成功后返回 Token请在后续请求中以 `X-Token` 头部携带。
---
### 代理链路节点 - 获取城市列表
- **名称**: 获取代理链路节点
- **方法**: GET
- **路径**: `/edge/city`
- **请求头**:
- `X-Token: <你的Token>`
- `Accept: application/json`
- **说明**: 返回可用城市(或区域)节点信息列表。
---
### 代理链路节点 - 按 cityhash 查询设备
- **名称**: cityhash获取代理链路节点信息
- **方法**: POST
- **路径**: `/edge/device`
- **请求头**:
- `X-Token: <你的Token>`
- `Content-Type: application/json`
- **请求体**:
```json
{
"geo": "<cityhash>",
"offset": 0,
"num": 200
}
```
- **参数说明**:
- `geo`: 城市哈希cityhash
- `offset`: 起始偏移
- `num`: 返回数量上限
---
### 代理链路节点 - 指定城市、数量查询
- **名称**: 查询指定城市、指定数量代理信息
- **方法**: POST
- **路径**: `/edge/device`
- **请求头**:
- `X-Token: <你的Token>`
- `Content-Type: application/json`
- **请求体**:
```json
{
"geo": "<cityhash>",
"offset": 0,
"num": 5
}
```
- **说明**: 与上一个接口一致,按 `num` 控制返回的设备数量。
---
### 网关 - 获取账户下已授权网关
- **名称**: 获取账户下已授权EIP网关信息
- **方法**: GET
- **路径**: `/gateway/list`
- **请求头**:
- `X-Token: <你的Token>`
- `Accept: application/json`
---
### 网关 - 获取网关配置
- **名称**: 获取网关配置
- **方法**: POST
- **路径**: `/gateway/config/get`
- **请求头**:
- `X-Token: <你的Token>`
- `Content-Type: application/json`
- `Accept: application/json`
- **请求体**:
```json
{
"macaddr": "<网关MAC地址>"
}
```
---
### 网关 - 设置网关代理链路
- **名称**: 配置网关代理链路
- **方法**: POST
- **路径**: `/gateway/config/set`
- **请求头**:
- `X-Token: <你的Token>`
- `Content-Type: application/json`
- `Accept: application/json`
- **请求体示例**:
```json
{
"macaddr": "<网关MAC地址>",
"config": {
"id": 1,
"rules": [
{
"table": 1,
"enable": true,
"edge": ["<设备ID1>"] ,
"network": ["<内网IP>"] ,
"cityhash": "<cityhash>"
}
]
}
}
```
- **字段说明**:
- `id`: 配置版本或规则集标识
- `rules[*].table`: 规则表编号
- `rules[*].enable`: 是否启用
- `rules[*].edge`: 目标边缘设备ID列表
- `rules[*].network`: 需要走代理的内网网段或IP列表
- `rules[*].cityhash`: 目标城市哈希
---
### 网关 - 清空网关配置链路
- **名称**: 清空网关配置的链路
- **方法**: POST
- **路径**: `/gateway/config/set`
- **请求头**:
- `X-Token: <你的Token>`
- `Content-Type: application/json`
- **请求体示例**:
```json
{
"macaddr": "<网关MAC地址>",
"config": {
"id": 1002,
"rules": [
{
"table": 1,
"enable": false,
"edge": ["", "", "", ""],
"network": [],
"cityhash": ""
}
]
}
}
```
- **说明**: 通过禁用规则并清空 `edge/network/cityhash` 实现清空配置。
---
### 网关 - 获取运行状态
- **名称**: 获取网关运行状态
- **方法**: POST
- **路径**: `/gateway/status`
- **请求头**:
- `X-Token: <你的Token>`
- `Content-Type: application/json`
- **请求体**:
```json
{ "macaddr": "<网关MAC地址>" }
```
---
### 通用说明
- **认证**: 除 `/client/auth` 外,其余接口均需在请求头添加 `X-Token`
- **内容类型**: JSON 请求统一使用 `Content-Type: application/json`
- **响应**: 均返回 JSON具体字段以实际接口返回为准。