3x-ui3x-ui
مرجعمرجع API

احراز هویت

دو حالت احراز هویت پشتیبانی می‌شود. نشست‌های UI از یک کوکی استفاده می‌کنند که توسط نقطه‌پایانی ورود تنظیم می‌شود. کلاینت‌های برنامه‌نویسی‌شده (ربات‌ها، اسکریپت‌ها، پنل‌های راه دور) با یک توکن Bearer که از مسیر Settings → Security → API Token گرفته می‌شود احراز هویت می‌کنند. هر دو روش برای همهٔ نقاط‌پایانی زیر /panel/api/* کار می‌کنند.

POST
/login

Authorization

headerAuthorizationBearer <token>

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

Request Body

application/json
  1. body
username*string

Panel admin username.

password*string

Panel admin password.

twoFactorCode?string

OTP code when 2FA is enabled. Omit otherwise.

Response Body

Successful response

application/json
  1. response
success?boolean
msg?string
obj?unknown
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"}
POST
/logout

Authorization

headerAuthorizationBearer <token>

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

Response Body

Successful response

application/json
  1. response
success?boolean
msg?string
obj?unknown
curl -X POST "https://example.com/logout"
{  "success": true}
GET
/csrf-token

Authorization

headerAuthorizationBearer <token>

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

Response Body

Successful response

application/json
  1. response
success?boolean
msg?string
obj?unknown
curl -X GET "https://example.com/csrf-token"
{  "success": true,  "obj": "csrf-token-string"}
POST
/getTwoFactorEnable

Authorization

headerAuthorizationBearer <token>

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

Response Body

Successful response

application/json
  1. response
success?boolean
msg?string
obj?unknown
curl -X POST "https://example.com/getTwoFactorEnable"
{  "success": true,  "obj": false}