cURL
curl -H "X-FH-APIKEY: $FINHAY_API_KEY" \
"https://open-api.fhsc.com.vn/market/financial-data/metal-providers"import requests
url = "https://open-api.fhsc.com.vn/market/financial-data/metal-providers"
headers = {"X-FH-APIKEY": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-FH-APIKEY': '<api-key>'}};
fetch('https://open-api.fhsc.com.vn/market/financial-data/metal-providers', 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/market/financial-data/metal-providers",
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>"
],
]);
$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/market/financial-data/metal-providers"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-FH-APIKEY", "<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/market/financial-data/metal-providers")
.header("X-FH-APIKEY", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://open-api.fhsc.com.vn/market/financial-data/metal-providers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-FH-APIKEY"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"error_code": "0",
"message": "success",
"data": [
{
"index": "PNJ_GOLD",
"name": "Vàng PNJ",
"short_name": "PNJ",
"buy_value": 92600000,
"sell_value": 94700000,
"provider": "PNJ",
"date": "2024-04-18",
"usd_value": 2352,
"vnd_value": 94700000,
"provider_icon": "https://cdn.finhay.com/providers/pnj.png",
"updated_at": "2024-04-18T10:00:00Z",
"change_percent": 0.4,
"buy_value_change_percent": 0.33,
"sell_value_change_percent": 0.46
},
{
"index": "PNJ_SILVER",
"name": "Bạc PNJ",
"short_name": "PNJ",
"buy_value": 980000,
"sell_value": 1050000,
"provider": "PNJ",
"date": "2024-04-18",
"usd_value": 28,
"vnd_value": 1050000,
"provider_icon": "https://cdn.finhay.com/providers/pnj.png",
"updated_at": "2024-04-18T10:00:00Z",
"change_percent": 0.15,
"buy_value_change_percent": 0.12,
"sell_value_change_percent": 0.18
}
]
}{
"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"
}Hàng hoá
Giá vàng và bạc theo nhà cung cấp
Superset của /gold-providers — trả về cả giá vàng lẫn bạc của mọi nhà
cung cấp trong 1 call duy nhất. Phân biệt vàng / bạc qua field index
(*_GOLD vs *_SILVER).
GET
/
market
/
financial-data
/
metal-providers
cURL
curl -H "X-FH-APIKEY: $FINHAY_API_KEY" \
"https://open-api.fhsc.com.vn/market/financial-data/metal-providers"import requests
url = "https://open-api.fhsc.com.vn/market/financial-data/metal-providers"
headers = {"X-FH-APIKEY": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-FH-APIKEY': '<api-key>'}};
fetch('https://open-api.fhsc.com.vn/market/financial-data/metal-providers', 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/market/financial-data/metal-providers",
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>"
],
]);
$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/market/financial-data/metal-providers"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-FH-APIKEY", "<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/market/financial-data/metal-providers")
.header("X-FH-APIKEY", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://open-api.fhsc.com.vn/market/financial-data/metal-providers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-FH-APIKEY"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"error_code": "0",
"message": "success",
"data": [
{
"index": "PNJ_GOLD",
"name": "Vàng PNJ",
"short_name": "PNJ",
"buy_value": 92600000,
"sell_value": 94700000,
"provider": "PNJ",
"date": "2024-04-18",
"usd_value": 2352,
"vnd_value": 94700000,
"provider_icon": "https://cdn.finhay.com/providers/pnj.png",
"updated_at": "2024-04-18T10:00:00Z",
"change_percent": 0.4,
"buy_value_change_percent": 0.33,
"sell_value_change_percent": 0.46
},
{
"index": "PNJ_SILVER",
"name": "Bạc PNJ",
"short_name": "PNJ",
"buy_value": 980000,
"sell_value": 1050000,
"provider": "PNJ",
"date": "2024-04-18",
"usd_value": 28,
"vnd_value": 1050000,
"provider_icon": "https://cdn.finhay.com/providers/pnj.png",
"updated_at": "2024-04-18T10:00:00Z",
"change_percent": 0.15,
"buy_value_change_percent": 0.12,
"sell_value_change_percent": 0.18
}
]
}{
"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
API key dài hạn của client. Cấu hình 1 lần lúc khởi tạo; có thể wire thẳng
vào static setter của SDK tự-gen. Đi kèm với FINHAY_API_SECRET — secret
này chỉ dùng ở phía client để tính X-FH-SIGNATURE, không bao giờ
gửi qua mạng.
Response
Trả về data mảng các record vàng/bạc của mọi nhà cung cấp; phân loại qua field index.
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.
⌘I