I Found the Right Currency Exchange Rates API For Trading
You might find this currency exchange rates API handy 👈 if you are into forex trading. I’m using this API in both ways. First, I’ve integrated it into an Excel file to give me current rates whenever I want to check and keep a list of historical daily rates. The second is to integrate it into a mobile app project I’m working on. It is a mock-up project and I don’t mean to commercially release it, but I hope to find some inspiration. I’m mostly interested in catching buy/sell/hold opportunities based on data (as you can see from the other posts in my blog), so let’s dig into this forex API a bit more.
How “Real-time” Is This Forex API?
This was the first question I had in mind. With forex trading, even minutes can matter. From what the developer of the API, Finnworlds support tells me and from my own experience, the forex API updates more frequently than every minute. This is useful indeed. The “time” field in the currency exchange data output will give you the date and time the rate belongs to in a very clear way 💹
Which brings us to our next question, “What does the forex API output look like?”
This a bit depends on what you want to fetch. For example, you can get all pairs for the currency you request in a single output or just focus on one. For example, using the “¤cy=usd” will return you all available pairs of USD and their current rates which is a lot of pairs. “¤cypair=USD/BBD” will return this specific pair alone.
Currency Rates API Useful Code Snippets
Below I've posted code snippets for the currency rates API you can use. This is to make a JS GET request.
const axios = require('axios');
// Replace 'YOUR_API_KEY' with your actual API key
const API_KEY = 'YOUR_API_KEY';
const endpoint = 'https://api.finnworlds.com/api/v1/currencypairs';
// Function to fetch currency data
async function getCurrencyData() {
try {
const response = await axios.get(`${endpoint}?key=${API_KEY}&pair=usd/aud`);
return response.data.result.output[0];
} catch (error) {
console.error('Error fetching data:', error);
throw error;
}
}
// Usage example
getCurrencyData()
.then(data => {
console.log('Currency Data:', data);
// Do something with the data here
})
.catch(err => {
// Handle errors
});
I've navigated around more codes and snippets and haven’t had any unexpected error codes with the currency rates API which is a good sign. The response rates have been also good but that’s a given as the output size is small.
Note 1: This currency exchange data includes a staggering 2020 pairs. I honestly didn’t expect this many. GJ!
And here’s what the exchange data output looks like:
{
"status": {
"code": 200,
"message": "OK",
"details": ""
},
"result": {
"basics": {
"code": 200,
"message": "OK",
"details": ""
},
"output": [
{
"pair": "USD/AUD",
"bid": "1.5200",
"ask": "1.5202",
"high": "1.5237",
"low": "1.5127",
"time": "2023-12-12 13:42"
}
]
}
}
Note 2: I kept on refreshing the data to test the update rates and can confirm you can get minute-by-minute updates with this forex API. While this is more than what I personally ask for, I realize some of us might be looking for even more frequent updates. It might be worth contacting Finnworlds about this.
How I Gained Access To Currency Exchange Data In a Minute
Simply, get an API key on the API provider website and access the currency exchange rates API with the API key immediately sent to your email. That's it; you have now access to real-time currency exchange rates of more than 2000 pairs with bid/ask/high/low values. With it, I could access all of their APIs along with the currency exchange data. For other reviews, the rest of my blog awaits you :)