Skip to main content

Documentation Index

Fetch the complete documentation index at: https://developers.fhsc.com.vn/llms.txt

Use this file to discover all available pages before exploring further.

2 endpoint dưới tag Khởi tạo là 2 lệnh gọi tối thiểu cần thực hiện để lấy userIdsubAccountId — 2 giá trị dùng làm path parameter cho hầu hết endpoint user-scoped. Gọi 1 lần khi khởi tạo client, cache kết quả, rồi truyền vào các endpoint phía sau.
Cả 2 call bootstrap đều thuộc Tier 2 nên phải HMAC sign. Xem Authentication để setup signing trước khi chạy bootstrap.
1

Lấy userId

GET /users/v1/users/me
Response:
{
  "error_code": "0",
  "message": "success",
  "data": {
    "user_id": 123456
  }
}
Lưu data.user_id làm userId cho mọi endpoint user-scoped (assets summary, pnl-today, …).
2

Lấy subAccountId

GET /users/v1/users/{userId}/sub-accounts
Response:
{
  "error_code": "0",
  "message": "success",
  "result": [
    {
      "id": "0001234567",
      "cust_id": "0001234500",
      "name": "Nguyễn Văn A",
      "depository_number": "120C001234",
      "product_type_name": ".1",
      "sub_account_ext": "120C001234.1",
      "type": "Normal"
    },
    {
      "id": "0001234568",
      "cust_id": "0001234500",
      "name": "Nguyễn Văn A",
      "depository_number": "120C001234",
      "product_type_name": ".6",
      "sub_account_ext": "120C001234.6",
      "type": "Margin"
    }
  ]
}
Chọn entry có type đúng nhu cầu — Normal cho tài khoản thường, Margin cho tài khoản ký quỹ — rồi lấy id làm subAccountId.

Chiến lược cache

Cả userIdsubAccountId đều khá static (không đổi trong vòng đời client):
  • Lưu vào memory ngay sau bootstrap.
  • Re-fetch khi nhận 401 từ endpoint user-scoped (tài khoản có thể bị disable / rotate).
  • Không cần TTL ngắn — chỉ invalidate khi user đăng xuất hoặc chuyển tài khoản.

Sử dụng tiếp

Sau khi có userId + subAccountId, truy cập được các nhóm endpoint sau trong API Reference:

Tổng tài sản

Giá trị net asset value, breakdown theo product, cash, debt, PnL.

Tiểu khoản

Số dư, margin, dư nợ và ngân hàng liên kết.

Danh mục đầu tư

Stock đang nắm giữ kèm giá realtime và PnL theo vị thế.

Sổ lệnh

Lệnh trong ngày, full list hoặc detail theo orderId.

Lãi/lỗ

PnL trong ngày tổng hợp qua mọi tiểu khoản.

Quyền cổ đông

Cổ tức, quyền mua, bỏ phiếu — của tiểu khoản.