Connects Payload v3 to the UniRate API for currency exchange rates and VAT data. It adds four custom endpoints under /api/unirate and keeps the API key on the server. It also exports a currency select field helper and a typed client with error classes. Requires a UniRate API key and Payload 3.0.0 or later.
Payload CMS v3 plugin for the UniRate currency-exchange API — server-side proxy endpoints (rate/convert/currencies/vat) and a prefilled currency select field. Zero runtime deps.
Installation
npm i payload-plugin-unirate0
Stars
0
Forks
0
Open Issues
3 months ago
Last Updated
0
Weekly Downloads
v0.1.0
npm Version
49.3 KB
Unpacked Size
0
Dependencies
Trends appear after 7 days of data. Collecting since Oct 22 — 6 daily snapshots so far.
Trends appear after 7 days of data. Collecting since Oct 22 — 6 daily snapshots so far.
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/1315674283-root)<a href="https://payloaddirectory.dev/plugins/1315674283-root"><img src="https://payloaddirectory.dev/badge/1315674283-root.svg" alt="Payload Directory"></a>README
A Payload CMS v3 plugin that integrates the
UniRate API for currency exchange rates and VAT data.
It appends four server-side endpoints under /api/unirate and ships an
optional prefilled currency select field — your API key stays server-side,
never exposed to clients. Zero runtime dependencies (payload is a peer).
npm install payload-plugin-unirate
Requires Payload >=3.0.0 (peer dependency) and Node >=18.20.
// payload.config.ts
import { buildConfig } from "payload";
import { uniratePlugin } from "payload-plugin-unirate";
export default buildConfig({
// ...your usual config
plugins: [
uniratePlugin({
apiKey: process.env.UNIRATE_API_KEY, // or omit and set the env var
}),
],
});
Set your key (recommended over inlining it):
UNIRATE_API_KEY=your_key_here
uniratePlugin(options):
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | process.env.UNIRATE_API_KEY | UniRate API key (stays server-side). |
baseUrl | string | https://api.unirateapi.com | API base URL. |
disabled | boolean | false | When true, the plugin is a no-op and adds no endpoints. |
timeoutMs | number | 30000 | Per-request timeout. |
The plugin appends these custom endpoints (Payload serves custom endpoints
under the /api prefix):
| Method | Path | Description |
|---|---|---|
| GET | /api/unirate/rate?from=USD&to=EUR | Exchange rate (single, or all rates for a base when to is omitted) |
| GET | /api/unirate/convert?from=USD&to=EUR&amount=100 | Convert an amount |
| GET | /api/unirate/currencies | List supported currencies |
| GET | /api/unirate/vat?country=DE | VAT rates (optional country filter) |
Example:
curl "http://localhost:3000/api/unirate/convert?from=USD&to=EUR&amount=100"
# → { "from": "USD", "to": "EUR", "amount": 100, "result": 92.00 }
When no API key is configured, the endpoints respond 503 (and log a warning)
rather than crashing at boot.
An exported helper builds a Payload select field prefilled with common
ISO-4217 currency codes:
import { currencyField } from "payload-plugin-unirate";
const Products = {
slug: "products",
fields: [
{ name: "title", type: "text" },
currencyField({ name: "priceCurrency", defaultValue: "USD", required: true }),
],
};
Pass options: ["USD", "EUR", ...] to override the code list, or fetch the live
list from /api/unirate/currencies.
Endpoint responses map upstream UniRate errors to the appropriate HTTP status:
| Status | Meaning |
|---|---|
| 400 | Invalid request parameters |
| 401 | Missing or invalid API key |
| 403 | Endpoint requires a Pro subscription |
| 404 | Currency not found / no data |
| 429 | Rate limit exceeded |
| 503 | Service unavailable / plugin not configured |
| 502 | Upstream/transport failure |
The internal client and its typed error classes are also exported for direct use in hooks or custom endpoints:
import { UniRateClient, AuthenticationError, RateLimitError, ProRequiredError } from "payload-plugin-unirate";
const client = new UniRateClient({ apiKey: process.env.UNIRATE_API_KEY! });
try {
const rate = await client.getRate("USD", "EUR"); // → 0.92
} catch (err) {
if (err instanceof AuthenticationError) { /* invalid key */ }
if (err instanceof RateLimitError) { /* slow down */ }
if (err instanceof ProRequiredError) { /* upgrade plan */ }
}
Free-tier endpoints: rates, convert, currencies, VAT rates. Historical data and time series require a Pro subscription.
UniRate API client libraries: Python · Node.js · Go · Rust · Ruby · PHP · Java · Swift · .NET
Framework integrations: Next.js · Nuxt · SvelteKit · Astro · NestJS · Eleventy · React · Vue · tRPC
CMS & e-commerce: WordPress · Directus · Strapi · Payload (this package) · Medusa · Hugo · Jekyll
Data & AI: LangChain Python · LangChain.js · FastAPI · Flask · Django REST · dbt · Airflow
Other: MCP server · CLI · Obsidian · money gem · laravel-money
MIT © Unirate Team
payload oapi
Generate an OpenAPI spec from your Payload config with optional documentation UIs
867.8k/wk125v3
payload dub
Create and sync Dub shortlinks, tags and analytics for published Payload documents
77175/wk4v4
payload plugin deskcrew
Turn new documents in chosen collections into DeskCrew support tickets
620/wk0v2
payload operations
Typed custom operations for Payload CMS using the native Payload REST SDK
530/wk2v3
payload plugin socials
Compose, schedule and publish posts to Pinterest, Instagram, Facebook Pages and Google Business Profile from Payload
520/wk3v3
payload instagram plugin
Connect an Instagram feed and import selected posts into a Payload collection
4331/wk25v3