curl \
-H "X-FH-APIKEY: $FINHAY_API_KEY" \
-H "X-FH-TIMESTAMP: $TIMESTAMP_MS" \
-H "X-FH-NONCE: $NONCE_UUID" \
-H "X-FH-SIGNATURE: $SIGNATURE_HEX" \
"https://open-api.fhsc.com.vn/users/v1/users/$USER_ID/transactions?type=stock&account=normal"import requests
url = "https://open-api.fhsc.com.vn/users/v1/users/{userId}/transactions"
headers = {
"X-FH-APIKEY": "<api-key>",
"X-FH-TIMESTAMP": "<api-key>",
"X-FH-NONCE": "<api-key>",
"X-FH-SIGNATURE": "<api-key>"
}
response = requests.get(url, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {
'X-FH-APIKEY': '<api-key>',
'X-FH-TIMESTAMP': '<api-key>',
'X-FH-NONCE': '<api-key>',
'X-FH-SIGNATURE': '<api-key>'
}
};
fetch('https://open-api.fhsc.com.vn/users/v1/users/{userId}/transactions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://open-api.fhsc.com.vn/users/v1/users/{userId}/transactions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-FH-APIKEY: <api-key>",
"X-FH-NONCE: <api-key>",
"X-FH-SIGNATURE: <api-key>",
"X-FH-TIMESTAMP: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://open-api.fhsc.com.vn/users/v1/users/{userId}/transactions"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-FH-APIKEY", "<api-key>")
req.Header.Add("X-FH-TIMESTAMP", "<api-key>")
req.Header.Add("X-FH-NONCE", "<api-key>")
req.Header.Add("X-FH-SIGNATURE", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://open-api.fhsc.com.vn/users/v1/users/{userId}/transactions")
.header("X-FH-APIKEY", "<api-key>")
.header("X-FH-TIMESTAMP", "<api-key>")
.header("X-FH-NONCE", "<api-key>")
.header("X-FH-SIGNATURE", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://open-api.fhsc.com.vn/users/v1/users/{userId}/transactions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-FH-APIKEY"] = '<api-key>'
request["X-FH-TIMESTAMP"] = '<api-key>'
request["X-FH-NONCE"] = '<api-key>'
request["X-FH-SIGNATURE"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"error_code": "0",
"message": "success",
"data": {
"type": "stock",
"from": "2026-07-13",
"to": "2026-10-13",
"items": [
{
"product": "stock",
"date": "2026-10-06",
"side": "BUY",
"asset": "MBB",
"quantity": 100,
"price": 78100,
"amount": 0,
"status": "EXPIRED",
"detail": {
"order_id": "8000061026000016",
"sub_account_id": "0001001",
"product": "MBB",
"order_type": "LO",
"created_at": "2026-10-06T09:15:00+07:00"
}
}
],
"next_page": "2"
}
}{
"error_code": "400",
"message": "Invalid parameter"
}{
"error_code": "401",
"message": "Invalid signature"
}{
"error_code": "429",
"message": "Too many requests"
}{
"error_code": "500",
"message": "Internal server error"
}Lịch sử giao dịch theo sản phẩm
Lịch sử giao dịch của người dùng theo từng sản phẩm, chọn bằng type.
type | Nội dung |
|---|---|
stock | Lệnh chứng khoán trên một tiểu khoản (account, bắt buộc); lọc một mã bằng symbol. |
haybond | Lệnh mua/bán HayBond (không gồm HayBond Plus). |
haybond_plus | Lệnh mua/bán HayBond Plus. |
hay0 | Nạp/rút Hay0 và Hay0 Plus; phân biệt bằng product (hay0, hay0_plus). |
fund | Lệnh mua/bán chứng chỉ quỹ mở, gồm lệnh định kỳ; lệnh mascot hiện thành các lệnh quỹ có detail.mascot_id; không gồm Cho Con. |
child_saving | Lệnh Cho Con của mọi hồ sơ con; detail.child_profile (1–3) cho biết hồ sơ. |
ipo | Đăng ký mua cổ phiếu IPO; là đăng ký, không phải lệnh đã khớp. |
Khoảng ngày: bỏ trống from → 3 tháng trước to; bỏ trống to → hôm nay; tối đa 1 năm, bao gồm [from, to].
Kết quả trả theo trang, mới nhất trước. Còn trang sau thì next_page khác null: gọi lại với page = next_page, giữ nguyên các tham số khác. Một trang có thể ít giao dịch hoặc rỗng mà vẫn còn trang sau.
account và symbol chỉ dùng với type=stock. Mỗi tham số chỉ truyền một lần.
Lỗi nghiệp vụ trả trong error_code:
error_code | Khi nào |
|---|---|
INVALID_TRANSACTION_QUERY | from sau to; khoảng ngày quá 1 năm, bao gồm [from, to]; type=stock thiếu account; account/symbol đi với type khác stock. |
SUB_ACCOUNT_NOT_FOUND | Người dùng không có tiểu khoản thuộc loại account. |
TRANSACTION_HISTORY_UNAVAILABLE | Hệ thống của sản phẩm tạm thời không trả được dữ liệu. |
curl \
-H "X-FH-APIKEY: $FINHAY_API_KEY" \
-H "X-FH-TIMESTAMP: $TIMESTAMP_MS" \
-H "X-FH-NONCE: $NONCE_UUID" \
-H "X-FH-SIGNATURE: $SIGNATURE_HEX" \
"https://open-api.fhsc.com.vn/users/v1/users/$USER_ID/transactions?type=stock&account=normal"import requests
url = "https://open-api.fhsc.com.vn/users/v1/users/{userId}/transactions"
headers = {
"X-FH-APIKEY": "<api-key>",
"X-FH-TIMESTAMP": "<api-key>",
"X-FH-NONCE": "<api-key>",
"X-FH-SIGNATURE": "<api-key>"
}
response = requests.get(url, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {
'X-FH-APIKEY': '<api-key>',
'X-FH-TIMESTAMP': '<api-key>',
'X-FH-NONCE': '<api-key>',
'X-FH-SIGNATURE': '<api-key>'
}
};
fetch('https://open-api.fhsc.com.vn/users/v1/users/{userId}/transactions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://open-api.fhsc.com.vn/users/v1/users/{userId}/transactions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-FH-APIKEY: <api-key>",
"X-FH-NONCE: <api-key>",
"X-FH-SIGNATURE: <api-key>",
"X-FH-TIMESTAMP: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://open-api.fhsc.com.vn/users/v1/users/{userId}/transactions"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-FH-APIKEY", "<api-key>")
req.Header.Add("X-FH-TIMESTAMP", "<api-key>")
req.Header.Add("X-FH-NONCE", "<api-key>")
req.Header.Add("X-FH-SIGNATURE", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://open-api.fhsc.com.vn/users/v1/users/{userId}/transactions")
.header("X-FH-APIKEY", "<api-key>")
.header("X-FH-TIMESTAMP", "<api-key>")
.header("X-FH-NONCE", "<api-key>")
.header("X-FH-SIGNATURE", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://open-api.fhsc.com.vn/users/v1/users/{userId}/transactions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-FH-APIKEY"] = '<api-key>'
request["X-FH-TIMESTAMP"] = '<api-key>'
request["X-FH-NONCE"] = '<api-key>'
request["X-FH-SIGNATURE"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"error_code": "0",
"message": "success",
"data": {
"type": "stock",
"from": "2026-07-13",
"to": "2026-10-13",
"items": [
{
"product": "stock",
"date": "2026-10-06",
"side": "BUY",
"asset": "MBB",
"quantity": 100,
"price": 78100,
"amount": 0,
"status": "EXPIRED",
"detail": {
"order_id": "8000061026000016",
"sub_account_id": "0001001",
"product": "MBB",
"order_type": "LO",
"created_at": "2026-10-06T09:15:00+07:00"
}
}
],
"next_page": "2"
}
}{
"error_code": "400",
"message": "Invalid parameter"
}{
"error_code": "401",
"message": "Invalid signature"
}{
"error_code": "429",
"message": "Too many requests"
}{
"error_code": "500",
"message": "Internal server error"
}Authorizations
UUIDv4 duy nhất per-request (ví dụ crypto.randomUUID()). Server cache
cặp (apiKey, nonce) trong 5 phút; nếu nonce được reuse với cùng apiKey
trong window này, request sẽ bị từ chối với AUTH_NONCE_REUSED (401).
Server chấp nhận chuỗi opaque bất kỳ về mặt kỹ thuật, nhưng nên dùng UUIDv4 để đảm bảo tính unique.
Được tính per-request bởi signing middleware. Không set thủ công — xem middleware mẫu trong tài liệu Authentication.
HMAC-SHA256 của canonical signing payload, encode hex (lowercase).
Signing payload:
{X-FH-TIMESTAMP}\n{METHOD}\n{REQUEST_PATH}[?{QUERY}]\n{BODYHASH}
?{QUERY}chỉ nối vào path khi request có query string.{BODYHASH}là chuỗi rỗng khi body rỗng (vẫn không có newline sau đó).
Được tính per-request bởi signing middleware. Không set thủ công — dùng middleware mẫu trong README.
Path Parameters
Query Parameters
Response
Thành công.
Các field chung của envelope trong mọi response của Finhay API.
error_codelà"0"(string) khi thành công, mã khác"0"khi lỗi.messagelà thông điệp ngắn từ server.