Tài liệu API để tích hợp MMO Agency vào hệ thống của bạn. Tất cả các endpoint đều yêu cầu authentication (trừ đăng ký/đăng nhập).
/api/register
Đăng ký tài khoản mới
{
"username": "string (required, unique)",
"email": "string (required, unique, valid email)",
"password": "string (required, min 6 characters)"
}
{
"message": "Registration successful",
"user_id": 1
}
{
"error": "Username or email already exists"
}
/api/login
Đăng nhập vào hệ thống
{
"username": "string (username or email)",
"password": "string"
}
{
"message": "Login successful",
"user": {
"id": 1,
"username": "user123",
"balance": 100.00
}
}
{
"error": "Invalid credentials"
}
/api/logout
Đăng xuất khỏi hệ thống
{
"message": "Logout successful"
}
/api/user
Lấy thông tin người dùng hiện tại (yêu cầu đăng nhập)
{
"id": 1,
"username": "user123",
"email": "user@example.com",
"balance": 100.00
}
/api/products
Lấy danh sách sản phẩm (có phân trang)
category (optional): Lọc theo danh mục (Gmail, X-Account, Short-term Mail, Trusted Mail, hoặc 'all')page (optional, default: 1): Số trangper_page (optional, default: 15): Số sản phẩm mỗi trangGET /api/products?category=Gmail&page=1&per_page=15
{
"products": [
{
"id": 1,
"category": "Gmail",
"name": "Gmail Account",
"live_time": "3-6 months",
"stock": 100,
"price": 5.00,
"description": "Gmail account with full access"
}
],
"pagination": {
"page": 1,
"per_page": 15,
"total": 100,
"total_pages": 7,
"has_next": true,
"has_prev": false
}
}
/api/products/{product_id}
Lấy thông tin chi tiết một sản phẩm
{
"id": 1,
"category": "Gmail",
"name": "Gmail Account",
"live_time": "3-6 months",
"stock": 100,
"price": 5.00,
"description": "Gmail account with full access"
}
/api/deposit
Nạp tiền vào tài khoản (yêu cầu đăng nhập)
{
"amount": 100.00
}
{
"message": "Deposit successful",
"new_balance": 200.00
}
/api/purchase
Mua sản phẩm (yêu cầu đăng nhập)
{
"product_id": 1,
"quantity": 2
}
{
"message": "Purchase successful",
"new_balance": 90.00,
"product": { ... },
"quantity": 2,
"total": 10.00
}
{
"error": "Insufficient balance" // hoặc "Insufficient stock"
}
/api/transactions
Lấy lịch sử giao dịch (yêu cầu đăng nhập)
[
{
"id": 1,
"user_id": 1,
"product_id": 1,
"transaction_type": "purchase",
"amount": 10.00,
"description": "Purchased 2x Gmail Account",
"created_at": "2024-01-01 12:00:00",
"product_name": "Gmail Account"
},
{
"id": 2,
"user_id": 1,
"product_id": null,
"transaction_type": "deposit",
"amount": 100.00,
"description": "Deposit $100.00",
"created_at": "2024-01-01 11:00:00",
"product_name": null
}
]
Để sử dụng các endpoint yêu cầu đăng nhập, bạn cần:
// Login
fetch('/api/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
credentials: 'include',
body: JSON.stringify({ username: 'user', password: 'pass' })
});
// Authenticated request
fetch('/api/user', {
credentials: 'include'
});