> ## Documentation Index
> Fetch the complete documentation index at: https://hoalulab.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Gọi request đầu tiên trong 5 phút — không cần HMAC signing.

Hướng dẫn nhanh cách gọi endpoint Tier 1 đầu tiên — chỉ cần 1 header `X-FH-APIKEY`. Sau khi quen, bạn có thể chuyển sang Tier 2 với HMAC signing đầy đủ ở [Authentication](/vi/fhsc/authentication).

<Steps>
  <Step title="Lấy API key">
    Đăng nhập tài khoản Finhay rồi truy cập trang [Quản lý API](https://invest.fhsc.com.vn/quan-ly-api) để tạo cặp `FINHAY_API_KEY` và `FINHAY_API_SECRET`. API key Tier 1 không cần secret — chỉ dùng để gọi các endpoint dữ liệu thị trường.

    Lưu key vào biến môi trường:

    ```bash theme={null}
    export FINHAY_API_KEY="<key của bạn>"
    ```
  </Step>

  <Step title="Gọi request đầu tiên">
    Lấy giá realtime của cổ phiếu VNM:

    <CodeGroup>
      ```bash cURL theme={null}
      curl -H "X-FH-APIKEY: $FINHAY_API_KEY" \
        "https://open-api.fhsc.com.vn/market/quotes/stocks/VNM"
      ```

      ```typescript TypeScript theme={null}
      const res = await fetch(
        "https://open-api.fhsc.com.vn/market/quotes/stocks/VNM",
        { headers: { "X-FH-APIKEY": process.env.FINHAY_API_KEY! } }
      );
      const json = await res.json();
      console.log(json.data);
      ```

      ```python Python theme={null}
      import os, requests

      res = requests.get(
          "https://open-api.fhsc.com.vn/market/quotes/stocks/VNM",
          headers={"X-FH-APIKEY": os.environ["FINHAY_API_KEY"]},
      )
      print(res.json()["data"])
      ```
    </CodeGroup>
  </Step>

  <Step title="Đọc response">
    Response trả về theo envelope chuẩn `{ error_code, message, data }`:

    ```json theme={null}
    {
      "error_code": "0",
      "message": "success",
      "data": {
        "symbol": "VNM",
        "name": "Vinamilk",
        "exchange": "HOSE",
        "currency": "VND",
        "price": 68500,
        "change": 300,
        "change_percent": 0.44,
        "ceiling": 72900,
        "floor": 63500,
        "volume": 1284500
      }
    }
    ```

    `error_code: "0"` nghĩa là thành công. Mọi mã khác `"0"` là lỗi — xem [Errors](/vi/fhsc/errors).

    <Note>
      Nhóm endpoint dữ liệu thị trường trả kết quả trong `data`; nhóm tài khoản / giao dịch (Tier 2) vẫn trả trong `result`.
    </Note>
  </Step>

  <Step title="Khám phá thêm">
    <CardGroup cols={2}>
      <Card title="Thêm endpoint Tier 1" icon="chart-line" href="/vi/fhsc/api-reference/v0/">
        Sổ lệnh, lịch sử OHLCV, chỉ số / forex / crypto / hàng hoá / quỹ mở / trái phiếu / ETF, tin tức, vĩ mô, lịch sự kiện kinh tế.
      </Card>

      <Card title="Truy cập tài khoản" icon="key" href="/vi/fhsc/authentication">
        Tier 2 với HMAC signing — đọc số dư, danh mục, sổ lệnh.
      </Card>
    </CardGroup>
  </Step>
</Steps>

## Bước tiếp

* Nếu chỉ dùng dữ liệu thị trường công khai → tiếp tục với các endpoint trong [API Reference](/vi/fhsc/api-reference/v0/) thuộc các tag *Bảng giá thị trường*, *Phân tích cơ bản*, *Tin tức-sự kiện*, *Kinh tế vĩ mô*.
* Nếu cần truy cập tài khoản user → đọc [Authentication](/vi/fhsc/authentication) để setup HMAC signing, sau đó chạy [Bootstrap flow](/vi/fhsc/bootstrap-flow) để lấy `userId` + `subAccountId`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.