Docs
Node.js Currency Exchange Rate API Documentation

Node.js Currency Exchange Rate API Documentation

Comprehensive guide on how to use our Node.js Currency Exchange Rate API for real-time currency conversion.

Introduction to the Node.js Currency Exchange Rate API

Welcome to our Node.js Currency Exchange Rate API documentation. Our API offers a simple and reliable solution for integrating real-time currency exchange rates into your Node.js applications. Ideal for both personal and professional projects, our API supports straightforward integration with minimal setup.

Key Features of Our Node.js API

  • Ease of Integration: Easily incorporate our API into your Node.js applications with simple GET requests.
  • Fast and Accurate JSON Responses: Our API delivers quick, JSON-formatted responses that are easy to parse using Node.js's native JSON handling.

For detailed information on the available request types and error responses, please refer to our Main Documentation.

Getting Started with Node.js: Currency Conversion Example

To start using our API with Node.js, you'll need to sign up for a free account to obtain your API key. Register here to get your API key.

Here’s a basic example to demonstrate how to fetch and use currency conversion rates in a Node.js application using the internal fetch package:

// Define your API key and base URL
const apiKey = "YOUR-API-KEY";
const baseCurrency = "USD";
const url = `https://api.currencyexchangerate-api.com/v1/${apiKey}/latest/${baseCurrency}`;
 
// Function to fetch exchange rates
async function fetchExchangeRates() {
  try {
    const response = await fetch(url);
    const data = await response.json();
 
    // Check if the request was successful
    if (data.result === "success") {
      // Access conversion rates
      const conversionRate = data.conversion_rates["EUR"];
      console.log(
        `Exchange rate from ${baseCurrency} to EUR: ${conversionRate}`,
      );
    } else {
      console.error("Failed to fetch exchange rates:", data);
    }
  } catch (error) {
    console.error("Error fetching data:", error);
  }
}
 
// Execute the function
fetchExchangeRates();

Sample JSON Response

Here’s a sample JSON response from the API with USD as the base currency code:

{
  "result": "success",
  "base_code": "USD",
  "qouta": 100,
  "remining": 78,
  "conversion_rates": {
    "USD": 1,
    "AED": 3.6725,
    "AFN": 71.3023,
    ...
  }
}

For additional details on request types, error handling, and more, please visit our Main Documentation.

Need Help?

If you have any questions or need further assistance, don’t hesitate to contact us. We’re here to assist you!