Integrating External REST API for Currency Conversion
So, you're ready to spice up our app with some real-world currency conversion, and what better way than using a Free Currency Conversion API from the folks at https://freecurrencyapi.com/? I hope you are! If not, buckle up as we break down the process.
Before we dive into the coding ocean, it's always a good idea to check the map. Head over to the dev documentation to understand how to navigate the waters of this API successfully.
Now, let's demystify the construction of our REST API URL. We'll be using the endpoint https://api.freecurrencyapi.com/v1/latest?, and we're using the GET method. But wait, what's with the "?" and "&"?
- The "?" indicates the start of the query parameters.
- The "&" separates different parameters in our request.
Our final endpoint looks like this: https://api.freecurrencyapi.com/v1/latest?apikey=our_magic_api_key¤cies=EUR and the server response we are looking for will be something like this (200 OK):

Now, why the secrecy around API keys? These keys are your app's secret handshake with the external service, uniquely identifying you. Sharing them would be like giving out the keys to your digital kingdom, inviting unwanted guests. So please, don't do it!
Defining the Data Source in Shared Components
Now that we have our secret sauce, it's time to define it in the Shared Components section. Here's the step-by-step guide.
Under Data Sources, click on REST Data Sources.
Hit Create and choose the 'From scratch' method (let's stick with the defaults for simplicity).
On the General dialog, enter the following details:
- REST Data Source Type: Simple HTTP
- Name: Free Currency Conversion API
- URL endpoint: https://api.freecurrencyapi.com/v1/latest?apikey=our_magic_api_key¤cies=EUR
Click Next, breeze through the Remote Server dialog, and on to the Authentication dialog.
Time for magic! Click on the Advanced option (bottom right). Here, we define our two parameters, one for the API key and one for the currencies:
- Name: apikey
- Type: URL Query String
- Direction: In
- Default value: enter your magic API key, I am not sharing mine! :)
- Name: currencies
- Type: URL Query String
- Direction: In
- Default value: EUR
Click Discover and witness the marvel.
Preview the Data Source, smile at your creation, and click Create REST Data Source.
And there you have it! You've just set sail into the world of external REST APIs, and your app is now armed with the ability to seamlessly convert earnings from USD to EUR. Bravo! 🌐💸