Tài liệu API DucVietStore

API dành cho đối tác đấu nối web/tool bán hàng tự động.

Base URL: https://api.ducvietstore.site

1. Lấy API key

Vào bot Telegram, bấm API. Bot sẽ hiển thị API key riêng của tài khoản. API này trừ trực tiếp vào số dư ví trên bot.

Không gửi API key cho người lạ. Nếu lộ key, bấm Đổi key trong bot để vô hiệu key cũ.

2. Xác thực

Tất cả endpoint đối tác cần gửi header:

X-API-Key: psk_xxxxxxxxxxxxxxxxx

3. Endpoint

MethodĐường dẫnMục đích
GET/partner/productsXem danh sách sản phẩm, giá và tồn kho.
GET/partner/balanceXem số dư ví/API.
POST/partner/ordersTạo đơn, trừ số dư và nhận tài khoản.
GET/partner/orders/{orderCode}Xem lại đơn đã tạo.

4. Ví dụ request

Xem sản phẩm:

curl -H "X-API-Key: psk_xxx" \
  https://api.ducvietstore.site/partner/products

Tạo đơn:

curl -X POST https://api.ducvietstore.site/partner/orders \
  -H "Content-Type: application/json" \
  -H "X-API-Key: psk_xxx" \
  -d '{"productId":0,"qty":1,"shopOrderId":"WEB-1001"}'

5. Response mẫu

{
  "ok": true,
  "order": {
    "orderCode": "PT123456789",
    "product": "Tên sản phẩm",
    "qty": 1,
    "price": 10000,
    "total": 10000,
    "status": "completed",
    "balanceAfter": 90000,
    "accounts": ["account|password"]
  }
}

6. Mã lỗi thường gặp

401 Unauthorized

Thiếu hoặc sai API key.

402 Insufficient balance

Số dư ví không đủ để tạo đơn.

400 Insufficient stock

Sản phẩm không đủ tồn kho.

404 Product not found

Sai productId hoặc tên sản phẩm.