UniRate

Integrates the UniRate currency exchange and VAT API into Payload CMS v3 with four server-side endpoints and a prefilled currency select field.

Community 0 MIT v0.1.0

Installation

pnpm add payload-plugin-unirate

About

This plugin integrates the UniRate currency exchange API into Payload CMS v3. It mounts four server-side GET endpoints under `/api/unirate` for fetching exchange rates, converting amounts, listing supported currencies, and retrieving VAT rates. The API key stays on the server and is never sent to the browser, so the browser only ever talks to your own Payload endpoints. You add it through the `plugins` array in `payload.config.ts`, passing an `apiKey` or relying on the `UNIRATE_API_KEY` environment variable. Other options let you override the base URL, set a per-request timeout, and disable the plugin at runtime. When no key is configured the endpoints return `503` instead of crashing at boot, and upstream UniRate errors are mapped to matching HTTP statuses (400, 401, 403, 404, 429, 502). Beyond the endpoints, the package exports a `currencyField` helper that builds a Payload `select` field prefilled with common ISO-4217 currency codes. You can override the code list or fetch the live list from `/api/unirate/currencies`, which is handy for marking a product price's currency. The internal `UniRateClient` and typed error classes (`AuthenticationError`, `RateLimitError`, `ProRequiredError`) are also exported, so you can call the API directly from hooks or custom endpoints. The free tier covers rates, conversion, the currency list, and VAT; historical data and time series require a Pro subscription. The plugin has zero runtime dependencies (payload is a peer) and requires Payload 3.0.0 or newer and Node 18.20 or newer.

Package info

Package name
payload-plugin-unirate
Latest version
0.1.0
Unpacked size
49 kB
License
MIT
Last publish
Jul 29, 2026

Similar plugins

More in Fields