Build a currency converter without writing conversion logic
Converting currencies sounds trivial – multiply by the rate. In practice you need the right rate for the right moment, a consistent base currency, cross rates for pairs that don’t involve USD, and correct rounding for each currency. The fxapi currency converter API handles all of that server-side: send an amount, a base currency and the target currencies, and get the converted values back as JSON.
The /v1/convert endpoint
| Parameter | Required | Description |
|---|---|---|
value | yes | Amount to convert, a number greater than 0 |
base_currency | no | Currency you are converting from, default USD |
currencies | no | Currencies you are converting to, comma-separated – default: all |
date | no | YYYY-MM-DD to convert at a historical rate (1999-01-01 to yesterday) |
type | no | Limit targets to fiat, metal or crypto |
Cross rates are calculated for you: converting CHF to SEK or BRL to INR works exactly like USD to EUR.
Convert at the invoice date
Accounting systems usually need the rate of the transaction date, not today’s rate. Add date and the API converts using the end-of-day rate of that day:
curl -G "https://api.fxapi.com/v1/convert" \
-d value=12500 -d base_currency=GBP -d currencies=EUR \
-d date=2026-06-30 \
-H "apikey: $FXAPI_KEY"
For period averages used in financial statements, see the average exchange rates API.
Examples in popular languages
Python
import os, requests
def convert(amount, from_ccy, to_ccy, date=None):
params = {"value": amount, "base_currency": from_ccy, "currencies": to_ccy}
if date:
params["date"] = date
r = requests.get(
"https://api.fxapi.com/v1/convert",
params=params,
headers={"apikey": os.environ["FXAPI_KEY"]},
timeout=10,
)
r.raise_for_status()
return r.json()["data"][to_ccy]["value"]
print(convert(99.90, "EUR", "USD"))
JavaScript (Node.js)
async function convert(amount, from, to) {
const url = new URL("https://api.fxapi.com/v1/convert");
url.search = new URLSearchParams({ value: amount, base_currency: from, currencies: to });
const res = await fetch(url, { headers: { apikey: process.env.FXAPI_KEY } });
const { data } = await res.json();
return data[to].value;
}
console.log(await convert(99.9, "EUR", "USD"));
PHP
<?php
$query = http_build_query(["value" => 99.90, "base_currency" => "EUR", "currencies" => "USD"]);
$ch = curl_init("https://api.fxapi.com/v1/convert?$query");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["apikey: " . getenv("FXAPI_KEY")],
]);
echo json_decode(curl_exec($ch), true)["data"]["USD"]["value"];
Prefer an SDK? Official libraries are available for JavaScript, Python, PHP, Go module, Ruby, C# and Rust.
Where a currency conversion API fits
- Checkout and invoicing – show and charge the right amount in the customer’s currency.
- Expense and travel tools – convert receipts at the rate of the day they were issued.
- Marketplaces and payouts – calculate seller payouts across currencies in one call.
- Spreadsheets and no-code tools – call the endpoint from Google Sheets, Zapier, Make or n8n with a plain HTTPS request.
- Chatbots and AI agents – let an agent answer “how much is 500 CHF in yen?” via the MCP server.
Need live rates instead of converted amounts?
If you convert inside your own application, call the real-time exchange rates API once, cache the rates and multiply locally. That is available on every plan, including the free plan.
This endpoint is part of the fxapi foreign exchange rates API – the same key, response format and 190+ currencies across every endpoint.
Frequently asked questions
Can I convert at a historical exchange rate?
date=YYYY-MM-DD to the convert request to use the end-of-day rate of that date. Any date from 1999-01-01 up to yesterday is supported.Can I convert one amount into several currencies at once?
currencies – for example EUR,GBP,JPY – and you get all converted amounts in one response, for the cost of one request.Which plan includes the convert endpoint?
/v1/latest and multiply the rate yourself.How do I round converted amounts?
decimal_digits and rounding fields from the currencies endpoint to round each currency correctly – JPY has 0 decimals, KWD has 3.