chile-kit
ES Support

UF, UTM, dólar and euro

Live values from mindicador.cl (Banco Central and SII data) or the official CMF API, through the global fetch, with a pluggable cache (default: one hour in memory), an optional fallback source and typed errors.

import { getIndicator, getIndicators, IndicatorError } from "chile-kit/indicators";

const uf = await getIndicator("uf");                      // { code: "uf", value: 39643.59, date: "2026-12-04", … }
const usd = await getIndicator("dolar", { date: "2026-12-01" });
const { uf: u, utm } = await getIndicators(["uf", "utm"]);

try {
  await getIndicator("dolar", { date: "2026-12-05" });    // a Saturday
} catch (error) {
  if (error instanceof IndicatorError) error.reason;       // "not-found" | "network" | "timeout" | "http" | "invalid-response"
}

Sources and fallback

mindicador.cl is free and community-run, with no SLA: fine for dashboards and side projects. When a wrong or missing value costs money (invoices, quotes, payments), use the official CMF API as the primary source or as a fallback. Its key is free at api.cmfchile.cl; keep it in an environment variable. chile-kit never stores it and masks it in error messages.

import { cmfSource, getIndicator, mindicadorSource } from "chile-kit/indicators";

const cmf = cmfSource({ apiKey: process.env.CMF_API_KEY ?? "" });

await getIndicator("uf", { fallback: cmf });                 // mindicador, then CMF if it fails
await getIndicator("uf", { source: cmf });                   // CMF only
await getIndicator("uf", { source: cmf, fallback: mindicadorSource() }); // CMF first

A source is { name, url(code, date), parse(body, code, date) }, so you can write your own for a mirror or an internal cache. The next source is tried only when the previous one throws an IndicatorError (down, timeout, bad answer or no value).

Caching

// Next.js: let the framework cache the request
await getIndicator("uf", { fetchOptions: { next: { revalidate: 3600 } } });

// Your own cache (Redis, KV…): get/set, sync or async
await getIndicator("uf", { cache: { get: (k) => kv.get(k), set: (k, v) => kv.set(k, v) } });

// No cache
await getIndicator("uf", { cache: null });