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

@willslzr/ration

v0.1.2

Published

Lightweight TypeScript SDK for South American currency exchange rates — VES (BCV official + parallel), ARS (official + blue), EUR, COP, and MXN. Zero runtime dependencies, dual ESM/CJS.

Readme

ration

SDK de TypeScript para consultar tasas de cambio del dólar en monedas sudamericanas — histórico y en tiempo real. Bolívar venezolano (oficial BCV y paralelo), peso argentino (oficial y paralelo), euro, peso colombiano y peso mexicano. Cero dependencias de runtime — usa exclusivamente fetch nativo (Node ≥ 18) — y build dual ESM/CJS con tipos incluidos.

Monedas soportadas

| Moneda | Código ISO | Fuentes (source) | | ------------------ | ---------- | ------------------------- | | Bolívar venezolano | VES | bcv_oficial, paralelo | | Peso argentino | ARS | oficial, paralelo | | Euro | EUR | oficial | | Peso colombiano | COP | oficial | | Peso mexicano | MXN | banxico_fix |

Instalación

npm install @willslzr/ration

Quickstart

El SDK necesita saber contra qué instancia de la API Ratio hablar. Hay una instancia en vivo, gratis y pública en https://ration-rate.onrender.com — las lecturas no requieren API key, así que alcanza con apuntar baseUrl ahí (o desplegar la tuya propia siguiendo la guía de Deploy del repo). La forma recomendada es vía variable de entorno, así el código nunca hardcodea la URL:

# .env
RATION_BASE_URL="https://ration-rate.onrender.com"   # o la URL de tu propio despliegue
import ration from "@willslzr/ration";

const latest = await ration("VES");
console.log(latest);
// { isoCode: 'VES', rate: '748.78640000', source: 'bcv_oficial', extractedAt: 2026-08-03T21:52:02.719Z }

También se puede pasar explícitamente por opción, sin depender de la variable de entorno:

import ration from "@willslzr/ration";

// Tasa más reciente
const latest = await ration("VES", undefined, { baseUrl: "https://ration-rate.onrender.com" });

// Tasa para una fecha específica (acepta 'DD/MM/YYYY', 'YYYY-MM-DD' o Date)
const historic = await ration("VES", "14/04/2026", {
  baseUrl: "https://ration-rate.onrender.com",
});

Render's free tier duerme el proceso tras 15 min sin tráfico — la primera petición después de un rato inactivo puede tardar unos segundos en despertar el servicio antes de responder.

Opciones

ration(isoCode: string, date?: string | Date, options?: RationOptions)

| Opción | Tipo | Default | Descripción | | ----------- | -------- | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | baseUrl | string | process.env.RATION_BASE_URL | URL base de tu instancia de la API Ratio. Requerido (por opción o env var). | | apiKey | string | process.env.RATION_API_KEY | Se envía como header x-api-key. No hace falta contra la instancia de referencia (las lecturas son públicas) — solo si corres tu propio fork con auth habilitada en lecturas. | | source | string | — | Filtra por fuente específica (ej. "bcv_oficial", "paralelo"). | | timeoutMs | number | 10000 | Timeout de la petición, vía AbortController. |

Resultado

interface ExchangeRateResult {
  isoCode: string;
  rate: string; // decimal como string, nunca number
  source: string;
  extractedAt: Date;
}

Errores

Todos los errores del SDK extienden RationError, así que se pueden capturar en conjunto o distinguir por tipo:

| Clase | Cuándo se lanza | | -------------------- | ----------------------------------------------------------------------------------------------------------------------- | | RationError | Clase base. También se usa directamente para errores de configuración (ej. falta baseUrl) o respuesta inesperada. | | InvalidDateError | El parámetro date no es 'DD/MM/YYYY', 'YYYY-MM-DD', ni un Date válido, o la fecha no existe (ej. 31/02/2026). | | RationApiError | La API respondió con un status fuera de 2xx. Expone status y detail (del cuerpo Problem Details). | | RationTimeoutError | La petición no respondió dentro de timeoutMs. Expone timeoutMs. | | RationNetworkError | Falló la conexión (DNS, red caída, etc.) antes de recibir una respuesta. |

import ration, { RationError, RationApiError } from "@willslzr/ration";

try {
  await ration("VES");
} catch (error) {
  if (error instanceof RationApiError && error.status === 404) {
    console.log("Sin datos para esa moneda");
  } else if (error instanceof RationError) {
    console.error("Error del SDK:", error.message);
  }
}

Licencia

MIT © willslzr