@allratestoday/hmrc-exchange-rate
v1.3.1
Published
Official HM Revenue & Customs (United Kingdom) monthly exchange rates — 141 currencies vs GBP, history since 2021. Zero-dependency Node.js/TypeScript client.
Downloads
314
Maintainers
Readme
HM Revenue & Customs Exchange Rates API — hmrc-exchange-rate
Official HM Revenue & Customs (the United Kingdom) monthly exchange rates for Node.js and TypeScript. The published tax authority rates behind tax filings, customs valuations, audits, and compliant invoicing — not market estimates, but the numbers HM Revenue & Customs itself prints, every month.
🚀 Why this client?
- 🏛️ Official published rates — HM Revenue & Customs's own table, with the publisher's own
rate_dateon every response - 📅 History back to 2021 — point-in-time tables and daily series for any past date
- 🔀 Published vs derived, always flagged — computed inverse/cross pairs carry
derived: true, never mixed with official prints - ⚡ Zero dependencies — pure ESM + CJS over global
fetch; Node 18+, Bun, Deno, and edge runtimes - 🔷 Type-safe — full TypeScript definitions shipped with the package
- 🧾 Compliance-grade metadata —
rate_type, publication date, and source disclaimer on every response
Official rate, not mid-market: every value here is a number HM Revenue & Customs itself published, fixed once printed and carrying the tax authority's own
rate_date— what filings and audits require. Need the live interbank midpoint for pricing or display instead? Use the mid-market API or@allratestoday/sdk. The two can diverge by several percent.
⚡ Try it without a key
The latest HM Revenue & Customs table is also served keyless, CORS-open and edge-cached, for evaluation, embeds and AI agents:
curl "https://allratestoday.com/api/open/central-bank/hmrc?source=GBP&target=USD"const r = await fetch('https://allratestoday.com/api/open/central-bank/hmrc').then((x) => x.json());
console.log(r.rate_date, r.rates.length); // the tax authority's latest published table, no keyThe open endpoint serves the latest table only and asks for a visible attribution link. The client below uses the keyed API, which adds point-in-time tables, history, and CSV/XML/Excel output.
🔑 Get your API key
Get a free API key at allratestoday.com/register — no credit card required. Latest rates are on every plan, including free.
📦 Installation
npm install @allratestoday/hmrc-exchange-rateyarn add @allratestoday/hmrc-exchange-ratepnpm add @allratestoday/hmrc-exchange-rateRequires Node 18+ (global fetch); also runs on Bun, Deno and edge runtimes. Scoped mirror of hmrc-exchange-rate — same code, same versions.
🏁 Quick start
import { getRate } from '@allratestoday/hmrc-exchange-rate';
const pair = await getRate('GBP', 'USD', { apiKey: 'art_live_...' });
console.log(pair.rate, pair.rate_date); // the official HM Revenue & Customs rate, on the tax authority's own date📚 API reference
- Latest pair rate — one pair from the latest published table
- Full published table — everything the tax authority printed, in one call
- Table for a date — the official table for an invoice or filing date
- Daily time series — one pair across a date range
Latest pair rate
Free plan and up. Pairs the tax authority does not print directly are resolved from its table and flagged (see Published vs derived rates below).
const pair = await getRate('GBP', 'USD', { apiKey: 'art_live_...' });Response:
{
bank: 'hmrc',
name: 'HM Revenue & Customs',
rate_date: '2026-09-01', // HM Revenue & Customs's own publication date
source: 'GBP',
target: 'USD',
rate: 1.3554,
rate_type: 'monthly',
derived: false,
method: 'published',
disclaimer: 'Official rates as published by the named central bank. On weekends/holidays the most recent published rate_date is returned.'
}Full published table
Free plan and up. The complete table for the latest publication date.
import { getLatestRates } from '@allratestoday/hmrc-exchange-rate';
const table = await getLatestRates({ apiKey: 'art_live_...' });
console.log(table.rate_date, table.rates.length);Response:
{
bank: 'hmrc',
name: 'HM Revenue & Customs',
rate_date: '2026-09-01',
rates: [
{ "base": "GBP", "quote": "USD", "type": "monthly", "value": 1.3554 },
// … the rest of the published table (141 currencies vs GBP)
],
disclaimer: '…'
}Table for a date
Paid plans. The official table for any date since 2021 — weekends and holidays return the most recent published date, flagged via published_on_requested_date, which is exactly the in-force rate a filing needs.
import { getRatesForDate } from '@allratestoday/hmrc-exchange-rate';
const day = await getRatesForDate('2026-06-30', { apiKey: 'art_live_...' });
// Optionally narrow to one pair:
const one = await getRatesForDate('2026-06-30', { apiKey: 'art_live_...', source: 'GBP', target: 'USD' });Response:
{
bank: 'hmrc',
requested_date: '2026-06-30',
rate_date: '2026-06-30', // the date actually published
published_on_requested_date: true, // false when a weekend/holiday fell back
rates: [ /* the full table for that date */ ],
disclaimer: '…'
}Daily time series
Paid plans. One resolved rate per publication date — ready for charting, revaluation runs, or audit workpapers.
import { getHistory } from '@allratestoday/hmrc-exchange-rate';
const series = await getHistory(
{ source: 'GBP', target: 'USD', from: '2026-01-01', to: '2026-09-01' },
{ apiKey: 'art_live_...' }
);Response:
{
bank: 'hmrc',
source: 'GBP',
target: 'USD',
from: '2026-01-01',
to: '2026-09-01',
count: 152,
rates: [
// one entry per publication date
{ date: '2026-09-01', rate: 1.3554, rate_type: 'monthly', derived: false, method: 'published' },
// …
],
disclaimer: '…'
}Pass { symbol: 'USD' } instead of source/target to get the raw published rows for one currency (all rate types, no pair resolution).
🗺️ Currencies covered
HM Revenue & Customs currently publishes rates covering 141 currencies against the GBP (as of the latest table):
🇦🇪 AED · 🇦🇱 ALL · 🇦🇲 AMD · 🇦🇴 AOA · 🇦🇷 ARS · 🇦🇺 AUD · 🇦🇼 AWG · 🇦🇿 AZN · 🇧🇦 BAM · 🇧🇧 BBD · 🇧🇩 BDT · 🇧🇭 BHD · 🇧🇮 BIF · 🇧🇲 BMD · 🇧🇳 BND · 🇧🇴 BOB · 🇧🇷 BRL · 🇧🇸 BSD · 🇧🇹 BTN · 🇧🇼 BWP · 🇧🇾 BYN · 🇧🇿 BZD · 🇨🇦 CAD · 🇨🇩 CDF · 🇨🇭 CHF · 🇨🇱 CLP · 🇨🇳 CNY · 🇨🇴 COP · 🇨🇷 CRC · 🇨🇺 CUP · 🇨🇻 CVE · 🇨🇿 CZK · 🇩🇯 DJF · 🇩🇰 DKK · 🇩🇴 DOP · 🇩🇿 DZD · 🇪🇬 EGP · 🇪🇷 ERN · 🇪🇹 ETB · 🇪🇺 EUR · 🇫🇯 FJD · 🇬🇪 GEL · 🇬🇭 GHS · 🇬🇲 GMD · 🇬🇳 GNF · 🇬🇹 GTQ · 🇬🇾 GYD · 🇭🇰 HKD · 🇭🇳 HNL · 🇭🇹 HTG · 🇭🇺 HUF · 🇮🇩 IDR · 🇮🇱 ILS · 🇮🇳 INR · 🇮🇶 IQD · 🇮🇸 ISK · 🇯🇲 JMD · 🇯🇴 JOD · 🇯🇵 JPY · 🇰🇪 KES · 🇰🇬 KGS · 🇰🇭 KHR · 🇰🇲 KMF · 🇰🇷 KRW · 🇰🇼 KWD · 🇰🇾 KYD · 🇰🇿 KZT · 🇱🇦 LAK · 🇱🇧 LBP · 🇱🇰 LKR · 🇱🇷 LRD · 🇱🇸 LSL · 🇱🇾 LYD · 🇲🇦 MAD · 🇲🇩 MDL · 🇲🇬 MGA · 🇲🇰 MKD · 🇲🇲 MMK · 🇲🇳 MNT · 🇲🇴 MOP · 🇲🇷 MRU · 🇲🇺 MUR · 🇲🇻 MVR · 🇲🇼 MWK · 🇲🇽 MXN · 🇲🇾 MYR · 🇲🇿 MZN · 🇳🇬 NGN · 🇳🇮 NIO · 🇳🇴 NOK · 🇳🇵 NPR · 🇳🇿 NZD · 🇴🇲 OMR · 🇵🇦 PAB · 🇵🇪 PEN · 🇵🇬 PGK · 🇵🇭 PHP · 🇵🇰 PKR · 🇵🇱 PLN · 🇵🇾 PYG · 🇶🇦 QAR · 🇷🇴 RON · 🇷🇸 RSD · 🇷🇺 RUB · 🇷🇼 RWF · 🇸🇦 SAR · 🇸🇧 SBD · 🇸🇨 SCR · 🇸🇩 SDG · 🇸🇪 SEK · 🇸🇬 SGD · 🇸🇱 SLE · 🇸🇴 SOS · 🇸🇷 SRD · 🇸🇻 SVC · 🇸🇿 SZL · 🇹🇭 THB · 🇹🇲 TMT · 🇹🇳 TND · 🇹🇴 TOP · 🇹🇷 TRY · 🇹🇹 TTD · 🇹🇼 TWD · 🇹🇿 TZS · 🇺🇦 UAH · 🇺🇬 UGX · 🇺🇸 USD · 🇺🇾 UYU · 🇺🇿 UZS · 🇻🇪 VES · 🇻🇳 VND · 🇻🇺 VUV · 🇼🇸 WST · XAF · XCD · XOF · XPF · 🇾🇪 YER · 🇿🇦 ZAR · 🇿🇲 ZMW · 🇿🇼 ZWG
🏛️ Source
HM Revenue & Customs is the United Kingdom's tax, payments, and customs authority. It publishes one official exchange rate table per calendar month — released ahead of the month it applies to — and that single rate is what UK customs declarations and VAT invoices must use for the whole month, regardless of how the market moves in between.
- Publisher's own page: Monthly exchange rates for customs and VAT · www.gov.uk/government/organisations/hm-revenue-customs
- Publication: every month; the exact schedule, freshness status and any current delay are on the HM Revenue & Customs rates page
- Values are stored unmodified, with the publisher's own
rate_dateon every row — see the methodology
🧭 Reading the numbers
valueis always quote currency per 1 unit of base currency (base: "EUR", quote: "USD", value: 1.15means 1 EUR = 1.15 USD).- HM Revenue & Customs quotes foreign currency per 1 GBP (e.g.
base: "GBP", quote: "USD"means USD per one GBP). - Need the other way round? Ask
getRate(target, source)and the API inverts or crosses for you, flaggedderived: true— never divide a published rate yourself in a compliance workflow. rate_typetells you which of the tax authority's series a row belongs to (monthlyhere); some publishers print buy/sell or several fixings for the same pair.
🧩 ERP & accounting systems
Loading the official HM Revenue & Customs rate into an accounting system is a supported workflow, not a hack. Step-by-step guides with the direction each system expects:
- Dynamics 365 Business Central — built-in Currency Exchange Rate Service, no code
- Xero · QuickBooks Online · SAP S/4HANA and ECC · Odoo
The same keyed endpoints return ?format=csv, ?format=xml and ?format=xlsx, and accept the key as ?api_key= on the URL for importers that cannot send headers:
curl "https://allratestoday.com/api/v1/central-bank/hmrc/latest?format=xml&api_key=art_live_..."🤖 AI agents
- MCP server:
npx -y @allratestoday/central-bank-mcp(stdio) or the hosted endpointhttps://allratestoday.com/api/mcp— tools for official rates, history, cross-bank comparison and publication calendars - Machine-readable site guide: llms.txt · for-ai-agents
⚖️ Published vs derived rates
If HM Revenue & Customs does not print a pair directly, the API resolves it from the tax authority's own table and says so — official and computed values are never confused:
| method | derived | Meaning |
| --- | --- | --- |
| published | false | The tax authority printed this pair directly |
| inverse | true | Computed as 1 ÷ the published opposite direction |
| cross | true | Computed via GBP from two published rates |
🛡️ Error handling
Errors are thrown as Error with status (HTTP code) and body (the API's JSON error) attached:
try {
const pair = await getRate('GBP', 'XXX', { apiKey: 'art_live_...' });
} catch (err) {
console.log(err.message); // human-readable reason
console.log(err.status); // e.g. 404
}| Status | Meaning |
| ------ | ------- |
| — | Missing apiKey (thrown before any request) |
| 400 | Malformed date or parameters |
| 401 | Invalid API key |
| 403 | Endpoint needs a paid plan (historical dates & series) |
| 404 | Pair or date range not covered by HM Revenue & Customs |
| 429 | Monthly quota exceeded |
🔷 TypeScript
Full definitions ship with the package — no @types install:
import type { LatestRates, PairRate, DatedRates, RateEntry, HistoryQuery, RequestOptions } from '@allratestoday/hmrc-exchange-rate';📦 CommonJS
const { getRate } = require('@allratestoday/hmrc-exchange-rate');
getRate('GBP', 'USD', { apiKey: 'art_live_...' }).then((pair) => console.log(pair.rate));💡 Quota tips
- Rates change once a month — cache the published table locally and a small monthly quota goes a long way.
- Every request counts toward your AllRatesToday quota, shared across all AllRatesToday endpoints on your key.
📖 Methods reference
| Method | Plan | Description |
| ------ | ---- | ----------- |
| getRate(source, target, { apiKey }) | Free | Latest rate for one pair, resolved from the published table |
| getLatestRates({ apiKey }) | Free | The tax authority's full latest published table |
| getRatesForDate(date, { apiKey, source?, target? }) | Paid | The official table (or one pair) for a YYYY-MM-DD date |
| getHistory({ symbol \| source+target, from?, to? }, { apiKey }) | Paid | Daily series since 2021 |
📥 Bulk data (no key)
Need the whole archive rather than an API call? The same published tables are mirrored daily as open data:
- Hugging Face: AllRates/central-bank-exchange-rates — one CSV per institution (
rates/hmrc.csv) - Kaggle: allratestoday/central-bank-exchange-rates
- CDN JSON:
https://cdn.jsdelivr.net/gh/AllRates-Today/central-bank-exchange-rates@main/data/hmrc/latest.json
🔗 Links
- HM Revenue & Customs rates page — live table, publication cadence, FAQ
- All tax authority sources
- Package docs on the site · ERP integration guides
- API documentation · Interactive reference · Methodology
- Register (free) · Pricing
- GitHub
📜 License
MIT
