Source game thương mại Bàn giao riêng tư Hỗ trợ cài đặt 8:00 - 22:00 Hotline 0868905021
API Reseller Center

Reseller API Center V2

Tài liệu API cho website đại lý

Base URL: https://huong.store/api/v1

Xác thực

Header bắt buộc

Dùng HMAC SHA256 với chuỗi: timestamp + request_path + raw_body. Timestamp lệch tối đa 5 phút.

X-API-KEY: api_key
X-API-TIMESTAMP: 1710000000
X-API-SIGNATURE: hmac_sha256(timestamp + "/api/v1/products" + raw_body, api_secret)

Ví dụ PHP

Tạo signature và gọi API

$apiKey = 'YOUR_API_KEY';
$apiSecret = 'YOUR_API_SECRET';
$body = json_encode(['product_id' => 1, 'quantity' => 1, 'request_id' => 'partner_123']);
$path = '/api/v1/orders';
$timestamp = time();
$signature = hash_hmac('sha256', $timestamp . $path . $body, $apiSecret);

$ch = curl_init('https://huong.store' . $path);
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POSTFIELDS => $body,
    CURLOPT_HTTPHEADER => [
        'Content-Type: application/json',
        'X-API-KEY: ' . $apiKey,
        'X-API-TIMESTAMP: ' . $timestamp,
        'X-API-SIGNATURE: ' . $signature,
    ],
]);
$response = curl_exec($ch);

Ví dụ NodeJS

Gọi danh sách sản phẩm

import crypto from 'crypto';

const apiKey = 'YOUR_API_KEY';
const apiSecret = 'YOUR_API_SECRET';
const path = '/api/v1/products';
const body = '';
const timestamp = Math.floor(Date.now() / 1000).toString();
const signature = crypto.createHmac('sha256', apiSecret).update(timestamp + path + body).digest('hex');

const res = await fetch('https://huong.store' + path, {
  headers: {
    'X-API-KEY': apiKey,
    'X-API-TIMESTAMP': timestamp,
    'X-API-SIGNATURE': signature,
  },
});
console.log(await res.json());

Endpoint

Danh sách API

GET /api/v1/account/balance

Lấy số dư đại lý.

GET /api/v1/categories

Lấy danh mục đang export API.

GET /api/v1/products?module_type=source&keyword=ninja

Lấy sản phẩm active, còn hàng và không thuộc risk high.

GET /api/v1/products/{id}

Lấy chi tiết một sản phẩm.

POST /api/v1/orders

Body: {"product_id":1,"quantity":1,"request_id":"partner_unique_id"}. Với dịch vụ MXH thêm trường link.

GET /api/v1/orders/{id}

Kiểm tra trạng thái đơn.

GET /api/v1/orders?status=completed

Lịch sử đơn của API client hiện tại.

Mã lỗi

Chuẩn response lỗi

{"success":false,"error":{"code":"ERROR_CODE","message":"Thông báo lỗi tiếng Việt"}}

UNAUTHORIZED
INVALID_SIGNATURE
IP_NOT_ALLOWED
RATE_LIMITED
VALIDATION_ERROR
PRODUCT_NOT_FOUND
PRODUCT_INACTIVE
OUT_OF_STOCK
INSUFFICIENT_BALANCE
DUPLICATE_REQUEST
MODULE_PROCESSOR_NOT_CONFIGURED
ORDER_FAILED
SERVER_ERROR