Module exchangerates
ballerinax/exchangerates Ballerina library
Overview
This is a generated connector from ExchangeRates-API v6 OpenAPI Specification.
With over 15 exchange rate data sources, the Exchangerates API is delivering exchanging rates data for more than 170 world currencies. The endpoints include functionalities like receiving the latest exchange rates information for a specific currency; conversion from one to another currency; receiving data Time-series for multiple or for one currency, and preserving the API daily for the fluctuation data.. More about the ExchangeRate-API can be find at ExchangeRates-API
This module supports ExchangeRates API version v6.
Prerequisites
Before using this connector in your Ballerina application, complete the following:
- Create ExchangeRate-API Account
- Obtain tokens
- Follow this link and obtain the API key.
Quickstart
To use the ExchangeRates connector in your Ballerina application, update the .bal file as follows:
Step 1: Import connector
First, import the ballerinax/exchangerates module into the Ballerina project.
import ballerinax/exchangerates;
Step 2: Create a new connector instance
You can now initialize the client.
exchangerates:Client baseClient = check new(serviceUrl = "https://v6.exchangerate-api.com/v6/");
Step 3: Invoke an operation
- Now you can use the operations available within the connector. Following code demonstrate how to obtain exchange rates for USD
exchangerates:CurrencyExchangeInfomation response = check baseClient->getExchangeRateFor("<API-Key>", "usd");
- Use
bal run
command to compile and run the Ballerina program.