Stand with Ukraine 🇺🇦

Cryptocurrency Converter — Confluence Cloud Macro

external-content

The macro sets the amount to convert and the currencies for conversion, constructs an API URL to fetch the conversion rate, and calculates the converted amount.

Try for free

User Parameters

123

Amount

Enter an amount for conversion

From Currency

Select a crypto to convert from

To Currency

Select a fiat currency to convert to

Template

#set($amount = $parameters.amount)
#set($fromCurrency = $StringUtils.lowerCase($parameters.fromCurrency))
#set($toCurrency = $StringUtils.lowerCase($parameters.toCurrency))

## API URL for conversion
#set($apiUrl = "https://api.coingecko.com/api/v3/simple/price?ids=$fromCurrency&vs_currencies=$toCurrency")

## Fetch conversion rate from the API
#set($response = $RequestManager.get($apiUrl))

## Check if response contains valid data
#if($response && $response[$fromCurrency] && $response[$fromCurrency][$toCurrency])
## Calculate the converted amount
#set($conversionRate = $response[$fromCurrency][$toCurrency])
#set($convertedAmount = $amount * $conversionRate)

## Display the conversion result
<span class="aui-lozenge aui-lozenge-subtle aui-lozenge-success">Conversion result:</span>
<p>
    $amount $StringUtils.capitalize($fromCurrency) = $StringUtils.upperCase($toCurrency) $convertedAmount
</p>
#else
## Display error message if conversion fails
<p>
    Unable to retrieve conversion rate
</p>
#end