Free Node.js Exchange Rate API

Welcome to the UnirateAPI Node.js documentation! Our free exchange rate API provides real-time currency conversion capabilities that you can easily integrate into your Node.js applications. Whether you're building a web server, financial dashboard, or any other system that needs currency conversion, our API has you covered.

UnirateAPI is designed to be developer-friendly and reliable, with a focus on simplicity and performance. We provide both direct API access using standard HTTP clients and an official Node.js client library built with TypeScript for type-safe integration.

With UnirateAPI, you get:

  • Real-time exchange rates from reliable sources
  • Simple RESTful API endpoints
  • Support for 590+ currencies
  • Completely free with no credit card required
  • 99.9% uptime guarantee
  • Fast response times (avg. 50ms)
  • Automatic currency updates every hour

Our Node.js solutions are designed to be:

  • Easy to integrate with minimal code
  • Fully typed with TypeScript for better IDE support
  • Error-resistant with proper exception handling
  • Available on npm for easy installation
  • Works in both CommonJS and ES Modules environments

For more detailed information about our API endpoints, rate limits, and advanced features, please check our main API documentation.

Below you'll find examples showing how to use our API with Node.js, both directly and using our official client library.

Getting Started with JavaScript

You can use our API in Node.js either by making direct HTTP requests or by using our official client library. We'll show you both approaches below.


// Option 1: Using Node.js fetch API directly (Node.js 18+ or with node-fetch)

// Direct API request example
async function convertCurrency(apiKey, fromCurrency, toCurrency, amount) {
  const baseUrl = 'https://api.unirateapi.com/api';
  const url = `${baseUrl}/convert?api_key=${apiKey}&from=${fromCurrency}&to=${toCurrency}&amount=${amount}`;
  
  try {
    const response = await fetch(url);
    
    if (!response.ok) {
      throw new Error(`API request failed with status ${response.status}`);
    }
    
    return await response.json();
  } catch (error) {
    console.error('Error fetching data:', error);
    throw error;
  }
}

// Example usage
async function main() {
  try {
    const apiKey = 'YOUR_API_KEY';
    const result = await convertCurrency(apiKey, 'USD', 'EUR', 100);
    console.log(`Converted amount: ${result.result} ${result.to}`);
  } catch (error) {
    console.error('Error:', error.message);
  }
}

main();


// Option 2: Using the official UnirateAPI Node.js client library
// First, install the library: npm install unirate-api

// ES Modules
import { UnirateClient } from 'unirate-api';

// OR CommonJS
// const { UnirateClient } = require('unirate-api');

// Initialize the client with your API key
const client = new UnirateClient('YOUR_API_KEY');

// Get exchange rate between currencies
async function getExchangeRateExample() {
  const rate = await client.getRate('USD', 'EUR');
  console.log(`1 USD = ${rate} EUR`);
  
  // Convert amount between currencies
  const amount = await client.convert(100, 'USD', 'EUR');
  console.log(`100 USD = ${amount} EUR`);
  
  // Get list of supported currencies
  const currencies = await client.getSupportedCurrencies();
  console.log('Supported currencies:', currencies.slice(0, 5), '...');
}

getExchangeRateExample().catch(error => {
  console.error('API Error:', error.message);
});

Response Example


// Direct API Response:
{
  "from": "USD",
  "to": "EUR",
  "amount": 100,
  "result": 92.45
}

// Client Library Output:
1 USD = 0.9245 EUR
100 USD = 92.45 EUR
Supported currencies: [ 'USD', 'EUR', 'GBP', 'JPY', 'AUD' ] ...

Important Notes

  • Replace 'YOUR_API_KEY' with your actual API key
  • Install the client library with: npm install unirate-api
  • The client library is written in TypeScript with full type definitions
  • Make sure to handle API errors appropriately in production
  • Node.js 18+ includes fetch natively; for older versions, use a package like node-fetch
  • The client has configurable request timeout settings
  • Store your API key securely using environment variables

Ready to Get Started?

Sign up now to get your API key and start converting currencies in your JavaScript applications.

Get Your API Key