Skip to main content

Get Historical Rate

Query the rate history of a currency pair so the Merchant can reconcile and analyse past quotes. Historical rates are retained for at least 2 months.

The API supports two modes:

  • Single day (type = 1) — return the rate snapshots recorded on a given date.
  • Date range (type = 2) — return the daily average rate for each day in a date range.

Path

  • URL: /cb-core/api/v1/fx/get-historical-rate
  • Method: POST
  • Description: Query the rate history of a currency pair.

Request

Request table

ParamsData TypeRequiredDescription
request_idstring(50)YesUnique code that identifies the request. Suggested format: MerchantCode + BK + YYYYMMDD + UniqueId
request_timestring(19)YesTime the Merchant sends the request. Format: YYYY-MM-DD HH:MM:SS
merchant_codestring(20)YesMerchant code provided by Baokim before integration
typeint(1)YesQuery mode. 1: rate snapshots on a single date. 2: daily average rate over a date range
from_currencystring(10)YesThe foreign currency code (e.g. USD). Only one currency code is allowed
to_currencystring(10)YesThe quote currency code (e.g. VND). Only one currency code is allowed
datestring(21)YesWhen type = 1: a single date YYYY-MM-DD.
When type = 2: a date range start_date,end_date, e.g. 2026-04-01,2026-06-01

Request Example — type = 1

{
"request_id": "MERCHANT1234BK202606054",
"request_time": "2026-06-05 10:15:30",
"merchant_code": "MERCHANT1234",
"type": 1,
"from_currency": "USD",
"to_currency": "VND",
"date": "2026-06-01"
}

Request Example — type = 2

{
"request_id": "MERCHANT1234BK202606055",
"request_time": "2026-06-05 10:15:30",
"merchant_code": "MERCHANT1234",
"type": 2,
"from_currency": "USD",
"to_currency": "VND",
"date": "2026-04-01,2026-06-01"
}

Response

Response Table

ParamsData TypeRequiredDescription
response_codeint(4)YesResult code from Baokim, as per the Error Codes table
response_messagestring(200)YesDescription of the result code
merchant_codestring(20)YesMerchant code provided by Baokim before integration
dataObjectYesHistorical rate result

Data Object Structure (inside data)

ParamsData TypeDescription
currency_pairstring(10)Currency pair in BASE/QUOTE format (e.g. USD/VND)
typeint(1)The query mode echoed back (1 or 2)
resultArray of ObjectsList of historical rate points

result Array Structure

ParamsData TypeDescription
timestampstring(19)When type = 1: the snapshot time YYYY-MM-DD HH:MM:SS. When type = 2: the date YYYY-MM-DD
biddecimal(18,4)Buying rate at that point (daily average when type = 2)
askdecimal(18,4)Selling rate at that point (daily average when type = 2)

Response Example — type = 1

{
"response_code": 200,
"response_message": "Success",
"merchant_code": "MERCHANT1234",
"data": {
"currency_pair": "USD/VND",
"type": 1,
"result": [
{ "timestamp": "2026-06-01 08:00:00", "bid": 26400.0000, "ask": 26460.0000 },
{ "timestamp": "2026-06-01 09:00:00", "bid": 26430.0000, "ask": 26490.0000 },
{ "timestamp": "2026-06-01 10:05:00", "bid": 26445.0000, "ask": 26505.0000 },
{ "timestamp": "2026-06-01 15:00:00", "bid": 26460.0000, "ask": 26520.0000 }
]
}
}

Response Example — type = 2

{
"response_code": 200,
"response_message": "Success",
"merchant_code": "MERCHANT1234",
"data": {
"currency_pair": "USD/VND",
"type": 2,
"result": [
{ "timestamp": "2026-04-01", "bid": 26200.1500, "ask": 26260.4500 },
{ "timestamp": "2026-04-02", "bid": 26250.1000, "ask": 26310.2000 },
{ "timestamp": "2026-04-03", "bid": 26255.2341, "ask": 26315.6300 }
]
}
}

Error Code

Response CodeResponse Message
200Success
101System Error
110Merchant Code Invalid
120Invalid Signature
404Currency Pair Not Supported
422Validation Error
429Too Many Requests