ExchangeRate API icon

ExchangeRate API

Consume ExchangeRate API

Convert Value

AI-generated

Overview

This node integrates with an external currency exchange rate API to perform currency-related operations. Specifically, for the "Convert Value" operation, it converts a specified amount from one currency to another using up-to-date exchange rates. It optionally applies a conversion fee and can round the result to a specified number of decimal places. This node is useful in financial workflows where currency conversion is needed, such as invoicing systems, e-commerce platforms, or financial reporting tools.

Practical examples:

  • Convert an invoice amount from USD to EUR before sending it to a European client.
  • Calculate the equivalent value of a payment received in GBP into your local currency.
  • Apply a small conversion fee when converting currencies for internal accounting purposes.

Properties

Name Meaning
Amount The numeric amount to convert (must be positive).
From Currency The three-letter ISO currency code representing the currency to convert from.
To Currency The three-letter ISO currency code representing the currency to convert to.
Use Conversion Fee Boolean flag indicating 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 indicating whether to round the converted amount to specific decimal places.
Decimal Places Number of decimal places to round the converted amount to (must be a non-negative integer).
Return Detailed Response Boolean flag to choose between returning a detailed response object or just the converted amount.

Output

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

  • If detailed response is enabled (true), the output includes:

    • result: Status string, e.g., "success".
    • from: Source currency code.
    • to: Target currency code.
    • amount: Original amount to convert.
    • exchange_rate: The exchange rate used for conversion.
    • conversion_fee_percentage: The applied conversion fee percentage (0 if none).
    • converted_amount: The final converted amount after applying fees and rounding.
    • time_last_update_utc: Timestamp of the last update of exchange rates.
  • If detailed response is disabled (false), the output contains only:

    • converted_amount: The final converted amount.

No binary data output is produced by this node.

Dependencies

  • Requires an 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 current exchange rates.
  • Proper configuration of the API key credential in n8n is necessary for successful operation.

Troubleshooting

  • API Key Issues:
    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.

  • Invalid Decimal Places:
    Error message: "Decimal places must be a non-negative integer."
    Resolution: Specify a non-negative integer for decimal places if rounding is enabled.

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

  • API Response Errors:
    Error messages like "API Error: {error_type} - {error_message}" indicate issues returned by the external API. Check API key validity, network connectivity, and API service status.

  • Missing or Malformed API Data:
    Error message: "Invalid API response: conversion_rates data is missing or has an unexpected format."
    Resolution: This indicates an unexpected API response; retry later or check API documentation for changes.

Links and References

Discussion