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

unirate-vendure

v0.1.0

Published

Vendure plugin for the UniRate currency-exchange API — injectable UniRateService (rates, convert, currencies, VAT) plus unirateConvert/unirateRate GraphQL queries, with zero runtime dependencies.

Readme

unirate-vendure

npm ci

UniRate API currency-exchange integration for Vendure — an injectable UniRateService (live rates, conversion, supported currencies, VAT rates) plus optional unirateConvert / unirateRate / unirateSupportedCurrencies GraphQL queries, with zero runtime dependencies.


Install

npm install unirate-vendure

@vendure/core (>=3.0.0), @nestjs/common, @nestjs/graphql, graphql, and reflect-metadata are peer dependencies — your Vendure project already provides them.

Get a free API key at unirateapi.com.


Quick start

1. Register the plugin in vendure-config.ts

import { VendureConfig } from "@vendure/core";
import { UniRatePlugin } from "unirate-vendure";

export const config: VendureConfig = {
  // ...your existing config
  plugins: [
    UniRatePlugin.init({
      apiKey: process.env.UNIRATE_API_KEY!,
      defaultBaseCurrency: "USD", // used by getRates() when no base is passed
      exposeShopApi: false,       // Admin API only by default
    }),
  ],
};

2. Inject UniRateService anywhere

UniRateService is a standard NestJS provider, exported by the plugin and available application-wide:

import { Injectable } from "@nestjs/common";
import { UniRateService } from "unirate-vendure";

@Injectable()
export class PricingService {
  constructor(private readonly unirate: UniRateService) {}

  async priceInEur(usd: number): Promise<number> {
    return this.unirate.convert(usd, "USD", "EUR");
  }
}

3. Or query the GraphQL API

The plugin extends the Admin API (and the Shop API when exposeShopApi: true) with:

query {
  unirateConvert(from: "USD", to: "EUR", amount: 100) {
    from
    to
    amount
    result
  }
  unirateRate(from: "USD", to: "GBP") {
    rate
  }
  unirateSupportedCurrencies
}

By default the queries are rejected on the Shop API to avoid exposing exchange lookups to unauthenticated storefront traffic. Set exposeShopApi: true to opt in.


UniRateService API

| Method | Returns | Tier | |---|---|---| | getRate(from, to) | Promise<number> | Free | | getRates(base?) | Promise<Record<string, number>> | Free | | convert(amount, from, to) | Promise<number> | Free | | getSupportedCurrencies() | Promise<string[]> | Free | | getVatRates() / getVatRates(country) | Promise<VATRatesAll \| VATRateOne> | Free | | getHistoricalRate(date, from, to) | Promise<number> | Pro | | getTimeSeries(startDate, endDate, base?, currencies?) | Promise<Record<string, Record<string, number>>> | Pro | | getHistoricalLimits() | Promise<HistoricalLimitsResponse> | Pro | | raw | UniRateClient | escape hatch |

Currency and country codes are uppercased automatically before the request.


Plugin options

UniRatePlugin.init({
  apiKey: string;             // required — your UniRate API key
  baseUrl?: string;           // default "https://api.unirateapi.com"
  timeoutMs?: number;         // default 30000
  defaultBaseCurrency?: string; // default "USD"
  exposeShopApi?: boolean;    // default false (Admin API only)
});

Error handling

Every method rejects with a typed error inheriting from UniRateError:

| HTTP | Error | When | |---|---|---| | 400 | InvalidRequestError | Bad parameters | | 401 | AuthenticationError | Missing / invalid API key | | 403 | ProRequiredError | Endpoint requires a Pro subscription | | 404 | InvalidCurrencyError | Unknown currency / no data | | 429 | RateLimitError | Rate limit exceeded | | other / network | UniRateError | Carries status + body |

import { ProRequiredError } from "unirate-vendure";

try {
  await unirate.getHistoricalRate("2020-01-01", "USD", "EUR");
} catch (err) {
  if (err instanceof ProRequiredError) {
    // historical data needs a UniRate Pro plan
  }
}

Historical and time-series endpoints are Pro-gated and return 403 (ProRequiredError) on the free tier.


Rate limits

The free tier is rate limited; a 429 surfaces as RateLimitError. Upgrade at unirateapi.com for higher limits and historical data.


Related UniRate integrations


License

MIT © Unirate Team