npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

payload-plugin-unirate

v0.1.0

Published

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.

Readme

payload-plugin-unirate

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).

Install

npm install payload-plugin-unirate

Requires Payload >=3.0.0 (peer dependency) and Node >=18.20.

Quick start

// 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

Options

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. |

Endpoints

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.

Currency select field

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.

Error handling

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 vs Pro tier

Free-tier endpoints: rates, convert, currencies, VAT rates. Historical data and time series require a Pro subscription.

Related packages

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

License

MIT © Unirate Team