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

v0.1.0

Published

LangChain.js integration for the UniRate currency-exchange API. UniRateAPIWrapper + three structured tools (exchange, rate, currencies) ready to plug into any LangChain.js agent. Zero runtime deps; peer deps only.

Readme

@unirate/langchain-js

LangChain.js integration for the UniRate currency-exchange API.

Drop three structured tools into any LangChain.js agent to handle FX queries: exchange currency amounts, look up rates, and list supported currencies. Mirrors the Python langchain-unirate package.

UniRate API · 593+ fiat, crypto & commodity instruments · Free tier available

Installation

npm install @unirate/langchain-js @langchain/core zod

@langchain/core and zod are peer dependencies — install them alongside this package.

Quick start

import { createUniRateTools, UniRateAPIWrapper } from "@unirate/langchain-js";
import { ChatOpenAI } from "@langchain/openai";
import { AgentExecutor, createToolCallingAgent } from "langchain/agents";
import { ChatPromptTemplate } from "@langchain/core/prompts";

// Share one wrapper across all tools
const wrapper = new UniRateAPIWrapper({ apiKey: process.env.UNIRATE_API_KEY });
const tools = createUniRateTools(wrapper);

const llm = new ChatOpenAI({ model: "gpt-4o" });
const prompt = ChatPromptTemplate.fromMessages([
  ["system", "You are a helpful currency assistant."],
  ["human", "{input}"],
  ["placeholder", "{agent_scratchpad}"],
]);

const agent = createToolCallingAgent({ llm, tools, prompt });
const executor = new AgentExecutor({ agent, tools });

const result = await executor.invoke({ input: "Convert 250 USD to JPY" });
console.log(result.output);

Tools

unirate_exchangeUniRateExchangeTool

Convert an amount from one currency to another.

| Parameter | Type | Description | |---|---|---| | from_currency | string | ISO 4217 source code (e.g. "USD", "BTC") | | to_currency | string | ISO 4217 target code | | amount | number (optional) | Amount to convert, defaults to 1 |

const tool = new UniRateExchangeTool({ apiKey: "..." });
await tool.invoke({ from_currency: "USD", to_currency: "EUR", amount: 100 });
// → "100 USD = 92.5 EUR (UniRate latest rate)"

unirate_rateUniRateRateTool

Look up the exchange rate between two currencies (or all rates from a base).

const tool = new UniRateRateTool({ apiKey: "..." });
await tool.invoke({ from_currency: "USD", to_currency: "EUR" });
// → "1 USD = 0.925 EUR (UniRate latest rate)"

unirate_currenciesUniRateCurrenciesTool

List all 593+ supported currency codes.

const tool = new UniRateCurrenciesTool({ apiKey: "..." });
await tool.invoke({});
// → "UniRate supports 593 currencies: USD, EUR, GBP, ..."

UniRateAPIWrapper

The wrapper class is available for use outside of an agent context:

import { UniRateAPIWrapper } from "@unirate/langchain-js";

const wrapper = new UniRateAPIWrapper(); // reads UNIRATE_API_KEY from env
console.log(await wrapper.getRate("USD", "EUR")); // 0.925
console.log(await wrapper.convert("USD", "EUR", 100)); // 92.5
console.log(await wrapper.run("USD", "EUR", 100)); // "100 USD = 92.5 EUR (UniRate latest rate)"

Factory convenience

import { createUniRateTools } from "@unirate/langchain-js";

// Pass options directly — a shared wrapper is created internally
const [exchangeTool, rateTool, currenciesTool] = createUniRateTools({
  apiKey: process.env.UNIRATE_API_KEY,
});

Errors

All errors extend UniRateError:

| HTTP | Class | Meaning | |---|---|---| | 400 | InvalidRequestError | Bad parameters | | 401 | AuthenticationError | Missing/invalid API key | | 403 | ProRequiredError | Historical endpoints (Pro plan) | | 404 | InvalidCurrencyError | Unknown currency | | 429 | RateLimitError | Rate limit exceeded |

Security

  • Zero runtime dependencies; @langchain/core and zod are peers provided by your app.
  • Native fetch only — no transitive HTTP-client supply-chain surface.
  • API key never leaves the server; tools are designed for server-side agent use.
  • Published to npm with provenance attestation.

Part of the UniRate ecosystem

Official UniRate clients & framework integrations: Python · Node · React · Vue · Nuxt · Next.js · SvelteKit · NestJS · Remix · Angular · Astro · Eleventy · LangChain (Python) · LangChain.js · MCP server

License

MIT © UniRate