Crypto Exchange Rates — Confluence Cloud Macro
The macro sets the base currency and predefined cryptocurrency IDs, constructs an API URL to fetch market data, and displays the results in an interactive HTML table.
User Parameters
Base currency
Select a base currency
Template
#set($currency = $StringUtils.lowerCase($parameters["baseCurrency"]))
<div id="crypto-rates-wrapper">
<table class="aui aui-table-interactive aui-table-rowhover" style="table-layout: fixed; width: 50%;">
<thead>
<tr>
<th style="width:50%;">Cryptocurrency</th>
<th style="width:50%;">Rate ($StringUtils.upperCase($currency))</th>
</tr>
</thead>
<tbody id="crypto-rates-body">
<tr>
<td colspan="2">Loading...</td>
</tr>
</tbody>
</table>
</div>
<script>
(async () => {
const currency = "$currency";
const cryptoIDs = "bitcoin,ethereum,tether,ripple,cardano,solana,polkadot,dogecoin,tron,toncoin";
const apiUrl =
"https://api.coingecko.com/api/v3/coins/markets?vs_currency="
+ currency
+ "&ids="
+ cryptoIDs
+ "&order=market_cap_desc";
const tbody = document.getElementById("crypto-rates-body");
try {
const response = await fetch(apiUrl);
const data = await response.json();
if (!Array.isArray(data) || data.length === 0) {
tbody.innerHTML =
"<tr><td colspan='2'>Unable to retrieve cryptocurrency rates</td></tr>";
return;
}
let html = "";
data.forEach(c => {
html += "<tr>";
html += "<td>";
html += "<span style='margin-right:7px;vertical-align:sub;'>";
html += "<img src='" + c.image + "' alt='" + c.name + " logo' style='width:20px;height:20px;'>";
html += "</span>";
html += c.name;
html += "</td>";
html += "<td>" + c.current_price + "</td>";
html += "</tr>";
});
tbody.innerHTML = html;
} catch (err) {
tbody.innerHTML =
"<tr><td colspan='2'>Unable to retrieve cryptocurrency rates</td></tr>";
console.error("Crypto macro error:", err);
}
})();
</script>
Recommended Macros
Retrieve and display current exchange rates for major currencies against a specified base currency.
Convert a specified amount of cryptocurrency to fiat currency.
Shows a mention of the user who created the current page. If it's a current user, mention blue. If it's another user, mention gray.
Show confetti bursts and a motivational message upon saving an edited page
Space Information macro by space Id
Display the top comments from a selected Confluence page or the current page by default.
Display information about how many users have access to each space
Displays a list of pages in specific space with certain title or label