{"_id":"@allratestoday/moneyify","name":"@allratestoday/moneyify","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.1":{"name":"@allratestoday/moneyify","version":"1.0.1","description":"Lightweight currency conversion library — cashify-compatible API with optional auto-fetch from the AllRatesToday API. 160+ currencies, mid-market rates, zero runtime deps.","main":"dist/index.js","module":"dist/index.mjs","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"scripts":{"build":"tsup src/index.ts --format cjs,esm --dts --clean","test":"node --test test/*.test.mjs"},"keywords":["moneyify","cashify","currency","currency-converter","currency-conversion","money","money.js","convert","conversion","exchange","exchange-rate","fx","forex","mid-market","refinitiv","reuters","big.js","allratestoday","typescript"],"author":{"name":"AllRatesToday","email":"support@allratestoday.com","url":"https://allratestoday.com"},"license":"MIT","homepage":"https://allratestoday.com","repository":{"type":"git","url":"git+https://github.com/cahthuranag/moneyify.git"},"bugs":{"url":"https://github.com/cahthuranag/moneyify/issues"},"engines":{"node":">=18"},"devDependencies":{"@types/node":"^25.6.0","tsup":"^8.0.0","typescript":"^5.3.0"},"publishConfig":{"access":"public"},"_id":"@allratestoday/moneyify@1.0.1","_nodeVersion":"22.22.1","_npmVersion":"9.2.0","dist":{"integrity":"sha512-PjfQh30EgLs8nDDd4WDbNaculaCcjjmAU3Te6qK+O9xFy4AQ3/k1duOH+PpARHMiKgrR52LoF9xwcdEOYOGIFQ==","shasum":"bcffe1df178643d49d949e9d95d239f320ec6501","tarball":"https://registry.npmjs.org/@allratestoday/moneyify/-/moneyify-1.0.1.tgz","fileCount":7,"unpackedSize":33419,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCICS+xZrJ4J2CDgugAIa84FMhtQF42tEx47HpiJ3088rrAiEAnDzuqC/nHxBtPHnJAXrOJwyqe3JEGbv+pIroJ/0ZdiY="}]},"_npmUser":{"name":"chathurangac8","email":"basnayakac8@gmail.com"},"directories":{},"maintainers":[{"name":"chathurangac8","email":"basnayakac8@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/moneyify_1.0.1_1787947806391_0.9046243113206687"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-28T20:10:06.220Z","1.0.1":"2026-08-28T20:10:06.756Z","modified":"2026-08-28T20:10:07.071Z"},"maintainers":[{"name":"chathurangac8","email":"basnayakac8@gmail.com"}],"description":"Lightweight currency conversion library — cashify-compatible API with optional auto-fetch from the AllRatesToday API. 160+ currencies, mid-market rates, zero runtime deps.","homepage":"https://allratestoday.com","keywords":["moneyify","cashify","currency","currency-converter","currency-conversion","money","money.js","convert","conversion","exchange","exchange-rate","fx","forex","mid-market","refinitiv","reuters","big.js","allratestoday","typescript"],"repository":{"type":"git","url":"git+https://github.com/cahthuranag/moneyify.git"},"author":{"name":"AllRatesToday","email":"support@allratestoday.com","url":"https://allratestoday.com"},"bugs":{"url":"https://github.com/cahthuranag/moneyify/issues"},"license":"MIT","readme":"> Scoped mirror of [`moneyify`](https://www.npmjs.com/package/moneyify) published by the AllRatesToday org — same code, same versions.\n\n# 💱 moneyify\n\n[![npm version](https://img.shields.io/npm/v/moneyify)](https://www.npmjs.com/package/moneyify)\n[![npm downloads](https://img.shields.io/npm/dm/moneyify)](https://www.npmjs.com/package/moneyify)\n[![license](https://img.shields.io/npm/l/moneyify)](./LICENSE)\n\nLightweight currency conversion library. **Cashify-compatible API** — bring your own rates and convert synchronously — plus **one extra superpower**: `Moneyify.live()` auto-fetches mid-market rates from the [AllRatesToday API](https://allratestoday.com) so you never need to maintain a rate table yourself.\n\n- 💡 Drop-in replacement for `cashify` (sync `convert`, expression parsing, big.js support)\n- 🌍 Auto-fetch 160+ currencies from Refinitiv (Reuters) + interbank feeds\n- 📦 **Zero runtime dependencies**\n- 🧮 Optional `big.js` integration for arbitrary-precision math\n- 💬 Parses expressions: `\"10 USD to EUR\"`, `\"€10 EUR in GBP\"`, `\"1,250.5 usd in gbp\"`\n- 🟦 Written in TypeScript, ships ESM + CJS + `.d.ts`\n- ⚡ Node 18+\n\n---\n\n## 📦 Installation\n\n```bash\nnpm install @allratestoday/moneyify\n```\n\n```bash\nyarn add @allratestoday/moneyify\npnpm add @allratestoday/moneyify\n```\n\n---\n\n## 🚀 Usage\n\n### 1. Bring your own rates (identical to cashify)\n\n```js\nimport { Moneyify } from \"moneyify\";\n\nconst rates = { EUR: 1.00, GBP: 0.85, USD: 1.08 };\nconst m = new Moneyify({ base: \"EUR\", rates });\n\nm.convert(10, { from: \"EUR\", to: \"GBP\" }); // 8.5\nm.convert(\"10 EUR to GBP\");                // 8.5\nm.convert(\"€10 EUR in USD\");               // 10.8\n```\n\n### 2. Auto-fetch from AllRatesToday (the moneyify moat)\n\n```js\nimport { Moneyify } from \"moneyify\";\n\n// Rates are fetched and cached on construction.\nconst m = await Moneyify.live({\n  base: \"USD\",\n  apiKey: process.env.ALLRATESTODAY_API_KEY,\n});\n\nm.convert(100, { from: \"USD\", to: \"INR\" });  // e.g. 8320.5\nm.convert(\"50 USD to EUR\");                   // e.g. 46.17\n```\n\nGet a free API key at **[allratestoday.com/register](https://allratestoday.com/register/)** — no credit card required.\n\n### 3. Functional (no constructor, also matches cashify)\n\n```js\nimport { convert } from \"moneyify\";\n\nconvert(10, {\n  from: \"EUR\",\n  to: \"GBP\",\n  base: \"EUR\",\n  rates: { GBP: 0.85, EUR: 1.0 },\n}); // 8.5\n```\n\n### 4. Parse expressions without converting\n\n```js\nimport { parse } from \"moneyify\";\n\nparse(\"10 EUR to GBP\");    // { amount: 10, from: \"EUR\", to: \"GBP\" }\nparse(\"€10 EUR\");          // { amount: 10, from: \"EUR\" }\nparse(\"1,250.5 usd in gbp\"); // { amount: 1250.5, from: \"USD\", to: \"GBP\" }\n```\n\nSupported separators: `to`, `in`, `as` (case-insensitive).\nSupported symbols: `$`, `€`, `£`, `¥`, `₹`, `₽`, `₺`, `₩`, `₪`, `R$`, `A$`, `C$`, `HK$`, `NZ$`, `S$`.\n\n### 5. Precision math with `big.js`\n\n```js\nimport Big from \"big.js\";\nimport { Moneyify } from \"moneyify\";\n\nconst m = new Moneyify({\n  base: \"USD\",\n  rates: { EUR: 0.923456789 },\n  BigJs: Big,\n});\n\nm.convert(100, { from: \"USD\", to: \"EUR\" }); // 92.3456789 (no float drift)\n```\n\n---\n\n## 📚 API\n\n### `new Moneyify({ base, rates?, BigJs? })`\n\n| Option  | Type                           | Description |\n|---------|--------------------------------|-------------|\n| `base`  | `string`                       | Base currency (`\"USD\"`, `\"EUR\"`, …). Required. |\n| `rates` | `Record<string, number>`       | Rate table where each value is \"1 base = X of this currency\". Default: `{}`. |\n| `BigJs` | `BigJsConstructor`             | Optional big.js-compatible constructor for arbitrary-precision math. |\n\n### `instance.convert(amount, options?)`\n\nSync. Returns a `number` (or big.js-backed `number` if `BigJs` was passed).\n\n- `amount`: `number` or a parseable expression string (`\"10 USD to EUR\"`)\n- `options.from?`: source currency (defaults to `base`)\n- `options.to?`: target currency (required unless embedded in the expression)\n\n### `Moneyify.live(options)` — static async factory\n\n```ts\nMoneyify.live({\n  base: string;\n  apiKey?: string;       // defaults to process.env.ALLRATESTODAY_API_KEY\n  baseUrl?: string;      // default: \"https://allratestoday.com\"\n  fetch?: typeof fetch;\n  timeoutMs?: number;    // default 15000\n  symbols?: string[];    // pre-fetch only these codes (default: all 160+)\n  BigJs?: BigJsConstructor;\n}): Promise<Moneyify>\n```\n\nPre-fetches rates against `base` and returns a ready-to-use instance. Once resolved, `.convert(...)` is fully synchronous.\n\n### `convert(amount, { from, to, base, rates, BigJs? })` — functional\n\nSame as `instance.convert()` but bring your own `base` and `rates` each call. Cashify parity.\n\n### `parse(expression)` — string parser\n\nReturns `{ amount, from?, to? }`. Throws `MoneyifyError` if unparseable.\n\n### `MoneyifyError`\n\nAll errors thrown by moneyify are instances of `MoneyifyError`. Network/API errors include a `.status` field with the HTTP status code.\n\n```js\nimport { MoneyifyError } from \"moneyify\";\n\ntry {\n  m.convert(10, { from: \"USD\", to: \"XYZ\" });\n} catch (err) {\n  if (err instanceof MoneyifyError) {\n    console.error(err.status, err.message);\n  }\n}\n```\n\n---\n\n## 🔄 Migrating from cashify\n\nThe public API is identical. Drop-in swap:\n\n```diff\n- import { Cashify, convert, parse } from \"cashify\";\n+ import { Moneyify as Cashify, convert, parse } from \"moneyify\";\n```\n\nEverything else works the same. If you want to stop maintaining your rate table, switch from `new Cashify({ base, rates })` to `await Moneyify.live({ base, apiKey })`.\n\n---\n\n## 🌍 Supported currencies\n\n160+ currencies including majors (USD, EUR, GBP, JPY, CHF, CAD, AUD, NZD), emerging-market (INR, CNY, BRL, MXN, TRY, ZAR, SGD, HKD, KRW, THB, PHP, PKR, BDT, LKR, NGN, GHS, KES, AED, SAR, EGP), and precious metals (XAU, XAG).\n\nFull list: [`allratestoday.com/api/v1/symbols`](https://allratestoday.com/api/v1/symbols).\n\n---\n\n## 🔗 Related projects\n\n- [`cashify`](https://github.com/xxczaki/cashify) – The library this package's API is modelled on. If you only need offline conversion math and don't want a network call, use cashify.\n- [`fx-rates`](https://www.npmjs.com/package/fx-rates) – Even lighter companion: a one-function library + `fx-rates` CLI for real-time rates.\n- [`@allratestoday/sdk`](https://www.npmjs.com/package/@allratestoday/sdk) – Full-featured SDK with historical data, batch requests, and webhooks.\n- [`react-currency-localizer-realtime`](https://www.npmjs.com/package/react-currency-localizer-realtime) – React hooks and components for auto-localized pricing.\n- [`allratestoday`](https://allratestoday.com) – The REST API that powers `Moneyify.live()`.\n\n---\n\n## 🤖 AI disclosure\n\nThis project contains code generated by Large Language Models (LLMs), under human supervision and proofreading. All published versions are reviewed, tested, and released by a human maintainer.\n\n---\n\n## 📄 License\n\n[MIT](./LICENSE) © [AllRatesToday](https://allratestoday.com) — maintained by [Chathuranga Basnayaka](https://github.com/cahthuranag).\n","readmeFilename":"README.md","_rev":"1-e484b1e58a38b1ff8ec388ce8ab6f0bd"}