Historical FX rate by date
GET /api/fx-historicalHistorical foreign-exchange rate for a specific date using European Central Bank reference rates (via Frankfurter). Send GET /api/fx-historical with the required fields from, to and date and pay $0.002 per call over x402 or MPP (there is no free tier). It returns a JSON object with from, to, date, rate and source.
Returns the rate that was published on (or rolled forward to) the requested date. ?from=USD&to=EUR&date=2024-01-02
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
from | string | yes | 3-letter source currency code, e.g. USD Also accepted as source, src, start. |
to | string | yes | 3-letter target currency code, e.g. EUR Also accepted as target, dest, destination, end. |
date | string | yes | ISO date (YYYY-MM-DD) |
Example request
curl -i "https://agent402.tools/api/fx-historical?from=USD&to=EUR&date=2024-01-02"
Without payment this returns HTTP 402 Payment Required with the exact price for fx-historical; any x402 v2 or MPP client pays it and retries.
Example response
{
"from": "USD",
"to": "EUR",
"date": "2024-01-02",
"rate": 0.9128,
"source": "ECB via Frankfurter"
}
| Field | Type | Always present | In the example |
|---|---|---|---|
from | string | yes | USD |
to | string | yes | EUR |
date | string | yes | 2024-01-02 |
rate | number | yes | 0.9128 |
source | string | yes | ECB via Frankfurter |
From an MCP client
catalog.call {
"slug": "fx-historical",
"params": {
"from": "USD",
"to": "EUR",
"date": "2024-01-02"
}
}
The hosted connector at https://agent402.tools/mcp needs a payment for fx-historical; the stdio package pays it from a wallet or from AGENT402_CREDITS_KEY. Local install: npx -y agent402-mcp.
Errors and behavior
from,toanddateare required. An input the tool rejects returns an HTTP 4xx whose body carrieserror,tool,expected,requiredandexample, so the caller can correct it.- A paid call that ends in any status of 400 or above is not charged over x402, MPP or a prepaid credits key: settlement is cancelled when the tool fails. The exception is a Tempo push credential, a transfer the buyer sent before the call: it settles before the tool runs, so if the tool then fails the payment is recorded as a refund owed to the paying wallet.
- Wallet-only: this tool reaches the network or stored state, so it has no proof-of-work tier. A prepaid card-credits key issued earlier (
Authorization: Bearer a402_...) also pays it. - A
POSTwith a JSON body to /api/fx-historical is served as this GET, with the body as the input. - An
Idempotency-Keyheader makes a retried paid call replay the first 200 instead of charging again (an answer larger than 1 MB is not replayed).
Paid call (JavaScript agent)
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const client = new x402Client();
client.setSpendControls?.(false); // keep your own spending ceiling in code
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);
const res = await payFetch("https://agent402.tools/api/fx-historical?from=USD&to=EUR&date=2024-01-02");
Part of these workflows
Historical FX rate by date is one step in this skill pack, each sold as a single call:
- FX monitor - Major currency snapshot: EUR/USD, GBP/USD, JPY/USD rates plus the full FX dashboard in one call.
Related tools
FX rate time series
GET /api/fx-timeseriesDaily FX rates between two currencies across a date window using European Central Bank reference rates (via Frankfurter)…
Currency exchange rate
GET /api/fx-rateLive currency conversion using European Central Bank reference rates (via Frankfurter). Converts an amount between two c…
G10 FX dashboard vs USD
GET /api/fx-dashboardSnapshot of all G10 spot exchange rates quoted against USD (EUR, GBP, JPY, CHF, CAD, AUD, NZD, SEK, NOK) using ECB refer…
Country info
GET /api/country-infoCountry facts by name or ISO code: official name, capital, region, currencies, languages, timezones, dialing code, TLD, …
US CPI year-over-year inflation
GET /api/cpi-yoyLatest US Consumer Price Index year-over-year inflation rate (headline CPI-U) plus the trailing 12 months of YoY reading…
Crypto global market
GET /api/crypto-globalGlobal crypto market snapshot: total market cap, total 24h volume, BTC dominance, ETH dominance, active coin count, acti…