API Documentation
XongNgay REST API — Tích hợp tăng tương tác Facebook, TikTok, Shopee vào ứng dụng của bạn.
🔐 Xác thực (Authentication)
Có 2 cách xác thực API:
Cách 1: Bearer Token (JWT)
Lấy token từ API login, sau đó gửi trong header Authorization: Bearer {token}.
curl -X POST https://xn.theanhlive.com/api/auth/login \
-H "Content-Type: application/json" \
-d '{"username":"your_username","password":"your_password"}'
# Response:
# {"ok":true,"user":{...},"token":"eyJ...","refresh_token":"eyJ..."}
# Dùng token cho các request sau:
curl https://xn.theanhlive.com/api/me \
-H "Authorization: Bearer eyJ..."
Cách 2: API Key (X-Api-Key)
Tạo API key trong trang Tài khoản, sau đó gửi trong header X-Api-Key. Key chỉ hiển thị 1 lần, hãy lưu lại ngay.
curl https://xn.theanhlive.com/api/me \
-H "X-Api-Key: xn_a1b2c3d4e5f6g7h8"
📋 Danh mục dịch vụ
GET/api/catalog/categories
Danh sách danh mục dịch vụ (Facebook, TikTok, Shopee).
curl https://xn.theanhlive.com/api/catalog/categories
GET/api/catalog/services?category_id={id}
Danh sách dịch vụ, lọc theo
category_id (tùy chọn).curl https://xn.theanhlive.com/api/catalog/services
curl "https://xn.theanhlive.com/api/catalog/services?category_id=1"
GET/api/catalog/services/{slug}
Chi tiết 1 dịch vụ kèm danh sách server + giá (nếu có auth, giá theo cấp độ thành viên).
curl https://xn.theanhlive.com/api/catalog/services/tang-mat-livestream-facebook-theo-gio \
-H "Authorization: Bearer {token}"
📦 Đơn hàng
POST/api/me/orders
Tạo đơn hàng mới. Yêu cầu auth (JWT hoặc API Key).
curl -X POST https://xn.theanhlive.com/api/me/orders \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{
"service_id": 5,
"server_id": 30,
"target_link": "https://www.facebook.com/example/posts/123",
"quantity": 100,
"duration_minutes": 30
}'
# Response: {"ok":true,"order":{"order_number":"...","status":"submitted","price_vnd":12000}}
GET/api/me/orders?status={status}&limit={limit}
Danh sách đơn hàng. Lọc theo status: submitted, held, hub_failed, cancelled.
curl https://xn.theanhlive.com/api/me/orders?status=submitted&limit=20 \
-H "Authorization: Bearer {token}"
GET/api/me/orders/stats
Thống kê đơn hàng theo trạng thái.
💰 Ví & Nạp tiền
GET/api/me/wallet
Xem số dư tài khoản.
curl https://xn.theanhlive.com/api/me/wallet \
-H "Authorization: Bearer {token}"
# Response: {"ok":true,"balance":1250000,"total_deposit":2000000,"updated_at":"..."}
GET/api/me/wallet/ledger?type={type}
Lịch sử giao dịch. type: TOPUP, ORDER_HOLD, ORDER_DEBIT, REFUND, ADJUSTMENT.
POST/api/me/topup
Gửi yêu cầu nạp tiền (chuyển khoản ngân hàng).
curl -X POST https://xn.theanhlive.com/api/me/topup \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{"amount":100000,"method":"bank_transfer"}'
👤 Tài khoản
GET/api/me
Thông tin tài khoản (username, email, phone, role, member_level, balance).
POST/api/me/password
Đổi mật khẩu. Body: {"old_password":"...","new_password":"..."}
GET/api/me/api-key
Xem trạng thái API key (chỉ hiện prefix).
POST/api/me/api-key/rotate
Tạo API key mới (key cũ bị vô hiệu hóa). Key chỉ hiển thị 1 lần.
⏱ Rate Limits
Mặc định: 60 requests/phút cho API Key, không giới hạn cho JWT. Liên hệ admin để tăng limit.