Skip to content

REST API

ByteInternetHK edited this page Dec 1, 2021 · 14 revisions

全部接口GET请求参数均为url params 参数, & 拼接, POST请求均以json格式传输
参数均以小驼峰方式命名
对接的节点key需携带在header中的key字段


获取节点信息接口

此接口需根据具体后端节点类型去请求对应类型的接口

GET /api/node

参数名称 参数类型 是否必须 备注
type string true 节点类型,类型见下方
nodeId number true 节点id

type为以下值

  • ss
  • v2ray
  • trojan

请求参数格式参考如下

?type=ss&nodeId=1

返回值根据具体的节点类型有不同字段返回值,分别返回如下格式

ss

{
    "ret": 200,
    "data": {
        "method": "aes-256-gcm",
        "id": 1,
        "name": "test_ss",
        "outServer": "test.ss.com",
        "outPort": 8080,
        "subServer": "test.ss.com",
        "subPort": 8080,
        "trafficRate": 1.0,
        "clazz": 1,
        "speedlimit": 0,
        "heartbeat": "2021-07-30 21:15:23",
        "flag": true
    }
}

v2ray

{
    "ret": 200,
    "data": {
        "alterId": 2,
        "network": "ws",
        "security": "none",
        "host": "www.iqiyi.com",
        "path": "/video",
        "id": 1,
        "name": "test_v2ray",
        "outServer": "test.v2ray.com",
        "outPort": 443,
        "subServer": "test.v2ray.com",
        "subPort": 443,
        "trafficRate": 1.0,
        "clazz": 1,
        "speedlimit": 0,
        "heartbeat": "2021-07-25 22:10:19",
        "flag": true
    }
}

trojan

{
    "ret": 200,
    "data": {
        "grpc": false,
        "id": 1,
        "name": "test_trojan",
        "outServer": "test.trojan.com",
        "outPort": 443,
        "subServer": "test.trojan.com",
        "subPort": 443,
        "trafficRate": 1.0,
        "clazz": 1,
        "speedlimit": 0,
        "heartbeat": "2021-07-30 20:38:53",
        "flag": true
    }
}

获取用户接口

GET /api/users

参数名称 参数类型 是否必须 备注
type string true 节点类型
nodeId number true 节点id

请求参数格式参考如下

?type=trojan&nodeId=1

返回参数格式参考如下

{
    "ret": 200,
    "data": [
        {
            "id":1,
            "clazz":5,
            "enable":true,
            "expireIn":"2031-08-31 23:59:59",
            "t":1633683659,
            "u":6516995017,
            "d":73620303942,
            "p":78014010057,
            "transferEnable":1099511627776,
            "passwd":"a1516dd5-45b3-347b-a2f8-c49cb9236add",
            "nodeSpeedlimit":500,
            "nodeConnector":0,
            "nodeGroup":0,
            "lastUsedDate":"2021-10-08 17:01:00",
            "isAdmin":1
        },
        {
            "id":2,
            "clazz":3,
            "enable":true,
            "expireIn":"2030-03-31 23:59:59",
            "t":1632398085,
            "u":29706689376,
            "d":878866551121,
            "p":906980301676,
            "transferEnable":10737417166258176,
            "passwd":"f296be52-0bbd-3114-b44c-51d4c37baf54",
            "nodeSpeedlimit":0,
            "nodeConnector":0,
            "nodeGroup":0,
            "lastUsedDate":"2021-09-23 19:54:46",
            "isAdmin":0
        }
    ]
}

获取节点审计规则接口

GET /api/rules

参数名称 参数类型 是否必须 备注
type string true 节点类型
nodeId number true 节点id

请求参数格式参考如下

?type=ss&nodeId=1

返回参数格式参考如下

{
    "ret": 200,
    "data": [
        {
            "id": 1,
            "name": "test1",
            "regex": "test1",
            "type": 1
        },
        {
            "id": 2,
            "name": "test2",
            "regex": "test2",
            "type": 1
        }
    ]
}

上报流量接口

此接口需根据具体后端去请求对应类型的接口

POST /api/traffic

参数名称 参数类型 是否必须 备注
type string true 节点类型,类型见下方
nodeId number true 节点id
users list true 本次用户流量,类型见下方

type为以下值

  • ss
  • v2ray
  • trojan

users的json为以下格式

参数名称 参数类型 是否必须 备注
id number true 用户id
up number true 本次上传流量
down number true 本次下载流量
ip string true 本次连接ip

请求参数格式参考如下

{
    "type": "ss",
    "nodeId": 1,
    "users": [
        {
            "id": 1,
            "up": 1024,
            "down": 1024,
            "ip": "1.1.1.1"
        }
    ]
}

返回参数参考如下

{
    "ret": 200,
    "data": {}
}

上报在线IP接口

POST /api/online

参数名称 参数类型 是否必须 备注
type string true 节点类型,类型见下方
nodeId number true 节点id
onlines list true 本次用户在线ip,类型见下方

type为以下值

  • ss
  • v2ray
  • trojan

onlines的json为以下格式

参数名称 参数类型 是否必须 备注
user_id number true 用户id
ip string true 本次连接ip

请求参数格式参考如下

{
    "type": "ss",
    "nodeId": 1,
    "onlines": [
        {
            "user_id": 1,
            "ip": "1.1.1.1"
        }
    ]
}

返回参数参考如下

{
    "ret": 200,
    "data": {}
}