Node API

V2RaySocks's API uses query strings to complete verification and pull and push resources

Example:

https://yourdomain.com/web_api/?token=thisistoken&node_id=4&node_type=v2ray&act=user

Among them, token=thisistoken&node_id=4&node_type=v2ray is required. If any one of them is missing, an error will be returned

node_type

node_type indicates the type of node

Acceptable values Corresponding protocol
v2ray Vmess, VLESS
trojan trojan
shadowsocks shadowsocks-AEAD, shadowsocks-2022
hysteria2 hysteria2

act

act indicates the behavior of the node, the following values ​​are supported

config

Get the config of the node, the API returns a json data, supports ETag

In principle, a standard Xray configuration file will be returned

{
    "api": {
        "services": [
            "HandlerService",
            "StatsService"
        ],
        "tag": "api"
    },
    "dns": [],
    "stats": {},
    "inbounds": [
        {
            "port": 36082,
            "protocol": "vmess",
            "settings": {
                "clients": []
            },
            "sniffing": {
                "enabled": true,
                "destOverride": [
                    "http",
                    "tls"
                ]
            },
            "streamSettings": {
                "network": "ws",
                "security": "tls",
                "tlsSettings": {
                    "certificates": [
                        {
                            "certificateFile": "/root/.cert/server.crt",
                            "keyFile": "/root/.cert/server.key"
                        }
                    ]
                },
                "wsSettings": {
                    "path": "/speedtest"
                }
            },
            "tag": "proxy"
        },
        {
            "listen": "127.0.0.1",
            "port": 1,
            "protocol": "dokodemo-door",
            "settings": {
                "address": "0.0.0.0"
            },
            "tag": "api"
        }
    ],
    "outbounds": [
        {
            "protocol": "freedom",
            "settings": {
                "domainStrategy": "UseIP"
            }
        },
        {
            "protocol": "blackhole",
            "tag": "block"
        }
    ],
    "routing": {
        "rules": [
            {
                "type": "field",
                "inboundTag": "api",
                "outboundTag": "api"
            },
            {
                "type": "field",
                "domain": [],
                "outboundTag": "block"
            },
            {
                "type": "field",
                "protocol": [],
                "outboundTag": "block"
            }
        ]
    },
    "policy": {
        "levels": {
            "0": {
                "handshake": 4,
                "connIdle": 300,
                "uplinkOnly": 5,
                "downlinkOnly": 30,
                "statsUserUplink": true,
                "statsUserDownlink": true
            }
        }
    }
}

The 0th {} of inbounds will be used as the node configuration, and the same, the 0th {} of the streamSettings, wsSettings, etc. (related to transport) are used as node configurations.

Please refer to XrayR , the implementation method is very simple

user

Get the user list of the node, the API returns a json data, supports ETag

v2ray and hysteria2

{
    "msg": "ok",
    "data": [
        {
            "id": 12,
            "uuid": "21DE8081-81E4-4525-A226-DCA408C4D603",
            "dt": 10,
            "st": 1
        },
        {
            "id": 13,
            "uuid": "EAF06CBA-4047-4A01-A4B5-02E15CD5E718",
            "dt": 10,
            "st": 1
        }
    ]
}

shadowsocks

{
    "msg": "ok",
    "data": [
        {
            "id": 12,
            "secret": "21DE8081-81E4-4525-A226-DCA408C4D603",
            "dt": 10,
            "st": 1
        },
        {
            "id": 13,
            "secret": "EAF06CBA-4047-4A01-A4B5-02E15CD5E718",
            "dt": 10,
            "st": 1
        }
    ]
}

trojan

{
    "msg": "ok",
    "data": [
        {
            "id": 12,
            "password": "21DE8081-81E4-4525-A226-DCA408C4D603",
            "dt": 10,
            "st": 1
        },
        {
            "id": 13,
            "password": "EAF06CBA-4047-4A01-A4B5-02E15CD5E718",
            "dt": 10,
            "st": 1
        }
    ]
}

dt indicates the device quantity limit, st indicates the speed limit (Mbps)

submit

Submit traffic usage data to V2RaySocks, accept a post request with json data

[
    {
        "uid": 1453,
        "u": 189773,
        "d": 52108028
    },
    {
        "uid": 2122,
        "u": 24518,
        "d": 46877
    },
    {
        "uid": 2379,
        "u": 591,
        "d": 5350
    },
    {
        "uid": 2392,
        "u": 2222,
        "d": 1207
    }
]

onlineusers

Submit the online user's IP to V2RaySocks, accept a post request with json data

Due to design issues, internal data can be duplicated

[
    {
        "uid": 1165323,
        "ip": "116.202.118.150"
    },
    {
        "uid": 1144103,
        "ip": "27.45.47.47"
    },
    {
        "uid": 1137593,
        "ip": "117.61.24.234"
    }
]

nodestatus

Submit node status data to V2RaySocks, accept a post request with json data

{
    "cpu": "0%",
    "mem": "13%",
    "net": "",
    "disk": "7%",
    "uptime": 4183063
}

illegal

Submit users who violated the rules to access the banned domain name to V2RaySocks, accept a post request with json data

Due to design issues, internal data can be duplicated

[
    {
        "uid": 1165985
    },
    {
        "uid": 1165985
    },
    {
        "uid": 1158653
    }
]

get_certificate

Get the node certificate stored in V2RaySocks

get_key

Get the node private key stored in V2RaySocks

Confirm post

All post requests will receive the following response indicating that the post has been successfully executed

{"msg":"ok","ret":200}

Or an error occurs

{"msg":"error","ret":500}