貨幣換算 API
使用一個選定匯率轉換一個正十進位金額。
REST 和 fx_convert_currency 返回相同的金額、匯率、結果、時間戳記、新鮮度和市場時段。
請求
REST
curl --request GET \
--url "https://api.narwhalapi.com/v1/fx/convert?from=USD&to=JPY&amount=100.00" \
--header "Authorization: Bearer $NARWHAL_API_KEY"| 參數 | 規則 |
|---|---|
from | 必填 來源 貨幣. |
to | 必填目標貨幣。它必須不同於 from. |
amount | 不超過以下範圍的正十進位字串 1000000000000. |
回應
200 OK
{
"from": "USD",
"to": "JPY",
"amount": "100.00",
"rate": "147.23",
"converted": "14723",
"market_session": "open",
"timestamp": "2026-08-22T06:29:39Z",
"stale": false
}捨入
Narwhal 使用十進位算術,並採用銀行家捨入法,一次性捨入到目標貨幣 ISO 4217 的最小單位。
錯誤
無效的貨幣對或金額會返回 400 invalid_query。不支援的幣種會返回 404 currency_not_supported.