How to use CurrencyUpdaterAPI for Salesforce?

You can use the CurrencyUpdaterAPI to retrieve currency exchange rates between any set of ISO currency codes for a given date, using either Salesforce’s local DatedConversionRate object or an external Heroku proxy.

The main method to use is:

public static Map<String, Map<String, String>> getExchangeRates(
List currencies,
Date rateDate,
String corporateCurrency,
Boolean local
)
  • currencies: List of ISO codes like ['USD', 'EUR', 'JPY']

  • rateDate: The date for which to fetch exchange rates

  • corporateCurrency: (optional) the base currency for cross-rate calculation; if null, it’s resolved automatically

  • local: true to use Salesforce DatedConversionRate, or false to fetch via Heroku


✅ Example: Using local rates from DatedConversionRate

List currencies = new List{ 'USD', 'EUR', 'CAD' };
Date rateDate = Date.today();
Map<String, Map<String, String>> rates = s4g_currencies.CurrencyUpdaterAPI.getExchangeRates(
currencies,
rateDate,
null, // resolve corporate currency automatically
true // use local DatedConversionRate
);// Output example
for (String origin : rates.keySet()) {
for (String target : rates.get(origin).keySet()) {
System.debug(origin + ' ➝ ' + target + ' = ' + rates.get(origin).get(target));
}
}

This will return all cross-rates between the listed currencies for the given date. If any conversion cannot be calculated, the value will be null. If a currency is compared to itself (e.g., USD ➝ USD), the result will be "1.00".