ExchangeRate API icon

ExchangeRate API

Consume ExchangeRate API

Exchange Rate → Convert Value

AI-generated

Overview

This node integrates with the ExchangeRate API to perform currency exchange operations. Specifically, for the "Exchange Rate" resource and the "Convert Value" operation, it converts a specified amount from one currency to another using up-to-date exchange rates.

Common scenarios where this node is beneficial include:

  • Financial applications needing real-time currency conversion.
  • E-commerce platforms calculating prices in different currencies.
  • Accounting workflows requiring currency normalization.
  • Travel or expense management tools converting expenses into a base currency.

For example, you can convert 100 USD to EUR, optionally applying a conversion fee and rounding the result to a specific number of decimal places. The node can return either just the converted amount or a detailed response including exchange rate and fees applied.

Properties

Name Meaning
Amount The numeric amount to convert (must be positive).
From Currency The three-letter ISO currency code to convert from.
To Currency The three-letter ISO currency code to convert to.
Use Conversion Fee Boolean flag to indicate whether to apply a percentage fee to the conversion.
Conversion Fee (%) Percentage fee to add to the conversion if "Use Conversion Fee" is enabled.
Use Decimal Places Boolean flag to indicate whether to round the converted amount to a specific number of decimals.
Decimal Places Number of decimal places to round the result to if "Use Decimal Places" is enabled (non-negative integer).
Return Detailed Response Boolean flag to choose between returning a detailed response (with exchange rate, fees, timestamps) or just the converted amount.

Output

The output JSON structure depends on the "Return Detailed Response" property:

  • If detailed response is enabled (default):

    {
      "result": "success",
      "from": "USD",
      "to": "EUR",
      "amount": 100,
      "exchange_rate": 0.85,
      "conversion_fee_percentage": 1.5,
      "converted_amount": 86.28,
      "time_last_update_utc": "Mon, 01 Jan 2024 00:00:00 +0000"
    }
    

    This includes the original amount, source and target currencies, the exchange rate used, any conversion fee percentage applied, the final converted amount after fees and rounding, and the timestamp of the last update of the exchange rates.

  • If detailed response is disabled:

    {
      "converted_amount": 86.28
    }
    

    Only the final converted amount is returned.

The node does not output binary data.

Dependencies

  • Requires an active API key credential for the ExchangeRate API service.
  • The node makes HTTP GET requests to https://v6.exchangerate-api.com/v6/latest/{currency_code} to fetch latest exchange rates.
  • Proper configuration of the API key credential in n8n is necessary.
  • No other external dependencies are required.

Troubleshooting

  • API Key Missing or Invalid:
    Error message: "API key is empty. Please provide a valid API key in the credentials."
    Resolution: Ensure that a valid API key is configured in the node's credentials.

  • Invalid Amount:
    Error message: "Amount must be a positive number"
    Resolution: Provide a positive numeric value for the amount to convert.

  • Currency Not Found:
    Error message: "Currency {code} not found in exchange rates"
    Resolution: Verify that the currency codes used are valid and supported by the ExchangeRate API.

  • Invalid API Response:
    Error message: "Invalid API response: conversion_rates data is missing or has an unexpected format"
    Resolution: Check network connectivity and API service status; ensure the API key has proper permissions.

  • Decimal Places Validation:
    Error message: "Decimal places must be a non-negative integer"
    Resolution: Provide a non-negative integer value for decimal places when rounding is enabled.

  • General API Errors:
    Error messages may include error type and message from the API. Review these messages for clues and verify API usage limits or credentials.

If "Continue On Fail" is enabled, errors for individual items will be returned as objects with an error field containing the error message.

Links and References

Discussion