貨幣換算 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。
文件