3x-ui3x-ui
参考API 参考

身份验证

支持两种身份验证模式。UI 会话使用登录端点设置的 Cookie。程序化客户端(机器人、脚本、远程面板)则使用从“设置 → 安全 → API Token”获取的 Bearer token 进行身份验证。两者都适用于 /panel/api/* 下的所有端点。

POST
/login

Authorization

AuthorizationBearer <token>

API token from Settings → Security → API Token. Send as Authorization: Bearer <token>.

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

curl -X POST "https://example.com/login" \  -H "Content-Type: application/json" \  -d '{    "username": "admin",    "password": "admin",    "twoFactorCode": "123456"  }'
{  "success": true,  "msg": "Logged in successfully"}
{  "success": false,  "msg": "Wrong username or password"}
POST
/logout

Authorization

AuthorizationBearer <token>

API token from Settings → Security → API Token. Send as Authorization: Bearer <token>.

In: header

Response Body

application/json

curl -X POST "https://example.com/logout"
{  "success": true}
GET
/csrf-token

Authorization

AuthorizationBearer <token>

API token from Settings → Security → API Token. Send as Authorization: Bearer <token>.

In: header

Response Body

application/json

curl -X GET "https://example.com/csrf-token"
{  "success": true,  "obj": "csrf-token-string"}
POST
/getTwoFactorEnable

Authorization

AuthorizationBearer <token>

API token from Settings → Security → API Token. Send as Authorization: Bearer <token>.

In: header

Response Body

application/json

curl -X POST "https://example.com/getTwoFactorEnable"
{  "success": true,  "obj": false}