v1 API 已標記為 deprecated,建議改用 v2,但仍會持續運作。

取得最新匯率、歷史匯率或時間序列資料。

最新匯率

取得最近一個營業日的匯率,每日約於歐洲中部時間(CET)16:00 更新。

curl https://api.frankfurter.dev/v1/latest

使用 base 參數變更基準貨幣,預設為 EUR。

curl https://api.frankfurter.dev/v1/latest?base=USD

限制回應僅包含特定目標貨幣。

curl https://api.frankfurter.dev/v1/latest?symbols=CHF,GBP

歷史匯率

查詢特定日期的匯率。

curl https://api.frankfurter.dev/v1/1999-01-04

變更基準貨幣並篩選目標貨幣。

curl https://api.frankfurter.dev/v1/1999-01-04?base=USD&symbols=EUR

注意:Frankfurter 以 UTC 儲存日期,若你位於其他時區,查詢結果可能對應不同的日曆日期。當日匯率在新數據發布時仍可能變動。

時間序列資料

取得指定期間內的匯率。

curl https://api.frankfurter.dev/v1/2000-01-01..2000-12-31

取得從指定日期至今的匯率。

curl https://api.frankfurter.dev/v1/2024-01-01..

提示:篩選目標貨幣可縮小回應體積並提升效能。

curl https://api.frankfurter.dev/v1/2024-01-01..?symbols=USD

可用貨幣

取得支援的貨幣代碼與完整名稱。

curl https://api.frankfurter.dev/v1/currencies

貨幣換算

取得匯率後,直接在程式碼中進行換算。

function convert(from, to, amount) {
  fetch(`https://api.frankfurter.dev/v1/latest?base=${from}&symbols=${to}`)
    .then((resp) => resp.json())
    .then((data) => {
      const convertedAmount = (amount * data.rates[to]).toFixed(2);
      alert(`${amount} ${from} = ${convertedAmount} ${to}`);
    });
  }

convert("EUR", "USD", 10);