Currency Exchange Rates — Confluence Cloud Macro
The macro builds an interactive table that fetches and displays exchange rates for a user-specified base currency. Major currencies (e.g., USD, EUR) are filtered from the response and presented with corresponding country flags.
User Parameters
Base Currency
Select a base currency against which to display the rates
Template
#set($baseCurrency = $parameters.baseCurrency)
## Define the API URLs
#set($exchangeRateApiUrl = "https://open.er-api.com/v6/latest/$baseCurrency")
#set($flagApiBaseUrl = "https://flagsapi.com/")
## Fetch exchange rate data
#set($exchangeResponse = $RequestManager.get($exchangeRateApiUrl))
## Check if data fetch was successful
#if($exchangeResponse)
#set($exchangeData = $exchangeResponse.rates)
## Major currencies list (customizable)
#set($majorCurrencies = ["USD", "EUR", "GBP", "JPY", "CHF", "CAD", "AUD"])
<table class="aui aui-table-interactive aui-table-rowhover" style="width: 50%; table-layout: fixed; border: 1px solid #ddd; border-collapse: collapse;">
<thead style="background-color: #f1f2f4;">
<tr>
<th style="width: 50%; border: 1px solid #ddd;">Currency</th>
<th style="width: 50%;">Rate ($baseCurrency)</th> ## Updated header
</tr>
</thead>
<tbody>
## Loop over the available currencies in the response and display only major currencies, excluding the base currency
#foreach($currency in $exchangeData.keySet())
#if($currency != $baseCurrency) ## Skip the base currency
## Check if the currency is in the majorCurrencies list by manual iteration
#set($isMajorCurrency = false)
#foreach($majorCurrency in $majorCurrencies)
#if($currency == $majorCurrency)
#set($isMajorCurrency = true)
#end
#end
## Display only if it's a major currency
#if($isMajorCurrency)
<tr>
<td style="border: 1px solid #ddd;">
#if($currency == "EUR")
<span style="margin-right: 5px; vertical-align: middle;">
<img src="https://upload.wikimedia.org/wikipedia/commons/b/b7/Flag_of_Europe.svg" alt="EU flag" style="width: 20px; height: 15px;">
</span>
$currency
#else
<span style="margin-right: 5px; vertical-align: middle;">
<img src="${flagApiBaseUrl}${currency.substring(0,2)}/shiny/32.png" alt="$currency flag" style="width: 20px; height: 20px;">
</span>
$currency
#end
</td>
<td>$MathTool.roundTo(3, $exchangeData.get($currency))</td> ## Rounding rate to 2 decimal places
</tr>
#end
#end
#end
</tbody>
</table>
#else
<p>
Failed to retrieve exchange rates.
</p>
#endRecommended Macros
Get the latest cryptocurrency rates for major coins.
Convert a specified amount of cryptocurrency to fiat currency.
Parses a table containing cost and currency columns, converts each row's value into a selected result currency, and appends a footer row showing the total sum. Useful for tracking multi-currency expenses and reporting totals in a unified currency.
This macro allows user to retrieve all pages from current space despite limitation of 250 pages per request
Space Information macro by space Id
Add a configurable tile to a Confluence page
Generate a list of labels from all spaces leading to corresponding content pages, organized in alphabetical order.
Read and display the fixed version of Confluence pages by checking page or ancestor labels