Tài liệu API
Dùng token để gọi API lấy dữ liệu key một cách an toàn.
Base URL & Xác thực
Base URLhttps://manager.quanghuynopro.com/api/v1
Định dạngJSON (UTF-8)
HeaderAuthorization: Bearer <token>
Token lấy tại trang API Token.
Chấp nhận: Personal Access Token (scope read / read write),
JWT access token (web tự lưu ở localStorage), hoặc cookie phiên
cùng origin. Thao tác ghi bằng cookie phải kèm header X-CSRF-Token;
bằng Bearer thì không cần.
Scopes
| Scope | Quyền |
|---|---|
| read | Đọc dữ liệu (key, hoá đơn, tài khoản) |
| write | Thao tác thay đổi (reset HWID, đổi redeem, mua, token…) |
| admin | Endpoint quản trị (chỉ token admin) |
Đối tượng Key
| Field | Kiểu | Mô tả |
|---|---|---|
| id | int | ID nội bộ của key |
| key | string | Chuỗi key |
| limit_hwid | int | Số HWID tối đa |
| used_hwid | int | Số HWID đã đăng ký |
| expiration | int (unix) | Thời điểm hết hạn (epoch giây) |
| is_unlimited | bool | Key vĩnh viễn |
| expired | bool | Đã hết hạn |
| last_reset | int (unix) | Lần reset HWID gần nhất |
| cooldown_remaining | int (giây) | Giây còn lại trước khi reset được (0 = reset ngay) |
| can_reset | bool | Có thể reset ngay không |
Endpoints
| Method | Path | Scope | Body / Params | Mô tả |
|---|---|---|---|---|
| GET | /me | read | — | Thông tin tài khoản |
| GET | /price | read | — | Giá cơ bản VND/USD |
| GET | /session/token | read (cookie) | — | Lấy access token hiện tại (để lưu localStorage) |
| GET | /keys | read | — | Danh sách key + cooldown |
| GET | /keys/{key} | read | path: key | Chi tiết 1 key |
| POST | /keys/reset | write | {key_id | key} | Reset HWID (cooldown 30′) |
| GET | /invoices | read | — | Lịch sử hoá đơn |
| POST | /redeem | write | {code} | Đổi mã redeem → key premium |
| POST | /buy | write | {quantity,hwid,month,redeem?} | Tạo hoá đơn → trả code + redirect |
| POST | /tokens/create | write | {name,scope} | Tạo PAT (trả token 1 lần) |
| POST | /tokens/revoke | write | {id} | Thu hồi PAT |
| POST | /sessions/revoke | write | {id} | Thu hồi 1 phiên |
| POST | /sessions/logout-all | write | — | Đăng xuất mọi thiết bị |
| GET | /admin/stats | admin | — | Thống kê |
| GET | /admin/user/{discord_id} | admin | path | Key theo Discord ID |
| POST | /admin/user/update | admin | {id,do} | ban/unban/seller/admin (do) |
| POST | /admin/keys/add | admin | {discord_id,quantity,hwid,month} | Whitelist key thủ công |
| POST | /admin/keys/delete | admin | {id} | Xoá key |
| POST | /admin/keys/reset | admin | {key_id | discord_id} | Force reset HWID |
| POST | /admin/settings | admin | {price_vnd,price_usd} | Đổi giá |
Response mẫu
GET /keys
{
"success": true, "count": 1,
"keys": [{
"id": 42, "key": "QuangHuy-Premium-AB12-CD34-EF56-GH78",
"limit_hwid": 2, "used_hwid": 1,
"expiration": 1786500000, "is_unlimited": false, "expired": false,
"last_reset": 1784100000, "cooldown_remaining": 0, "can_reset": true
}]
}
POST /keys/reset khi đang cooldown
{ "success": false, "error": "reset_failed",
"msg": "Bạn vừa reset gần đây, thử lại sau 24 phút.", "retry_after": 1440 }
Mã lỗi
| HTTP | error | Ý nghĩa |
|---|---|---|
| 401 | invalid_token | Token sai / hết hạn / bị thu hồi |
| 403 | insufficient_scope | Token thiếu quyền (write/admin) |
| 419 | csrf | Thiếu/sai X-CSRF-Token (khi ghi bằng cookie) |
| 404 | not_found | Key / endpoint không tồn tại |
| 400 | reset_failed / redeem_failed / buy_failed | Thao tác thất bại (kèm msg) |
Ví dụ
curl -H "Authorization: Bearer qh_xxx" https://manager.quanghuynopro.com/api/v1/keys
curl -X POST https://manager.quanghuynopro.com/api/v1/keys/reset \
-H "Authorization: Bearer qh_xxx" -H "Content-Type: application/json" \
-d '{"key_id":42}'