Module cloudmersive.currency
ballerinax/cloudmersive.currency Ballerina library
Overview
The Cloudmersive Currency connector provides programmatic access to the Cloudmersive Currency API, which helps you retrieve exchange rates and convert prices between currencies. This connector supports version 1 of the API and lets Ballerina applications look up supported currencies, fetch live exchange rates and convert prices with a few remote method calls.
Key features
- List the currencies and countries supported by the API
- Retrieve the current exchange rate between any two supported currencies
- Convert a price from a source currency into a destination currency
- Authenticate with a single Cloudmersive API key
Setup guide
To use this connector you need a Cloudmersive API key.
- Sign up or log in at the Cloudmersive portal.
- Open the API Keys page of your account.
- Create a new API key, or copy an existing one.
- Supply the key as the
apikeyfield when you initialize the client. Keep it out of source control, for example by reading it fromConfig.toml.
Quickstart
-
Add the import:
import ballerinax/cloudmersive.currency; -
Create a
Config.tomlwith your API key:apiKey = "<YOUR_API_KEY>" -
Declare the configurable for the API key:
configurable string apiKey = ?; -
Create the client and invoke an operation:
public function main() returns error? { currency:Client currencyClient = check new ({apikey: apiKey}); currency:ExchangeRateResult _ = check currencyClient->getExchangeRate("USD", "EUR"); }
Examples
The Cloudmersive Currency connector provides practical examples illustrating usage in various scenarios. Explore these examples, covering the following use cases:
- currency_price_conversion - Validate a currency pair against the supported list and convert a price.
- exchange_rate_lookup - Look up exchange rates from a base currency to several targets.