The rise of the internet and smartphones has opened the door for many individual traders to access the foreign exchange markets. This trend has resulted in an influx of mobile applications in the finance market. Whether you are a developer aiming to build a simple currency converter application or an enterprise launching a market-disruptive product, picking the trusted data provider will always be the key to its success.
Therefore, building such applications that also target a global audience can’t be imagined without having currency conversion and market data APIs that can not only provide real-time data but should also have the ability to store historical data from trusted sources.
By leveraging those APIs the developers and organizations can let the API vendor do all the heavy lifting so they can focus on the business aspects of the application. One such API is the CurrencyScoop API which provides exchange rates for over 200 world currencies and precious metals using its developer-friendly API. One of its features that outshines it from its competitors is that it provides real-time mid-market and historical exchange rates, which you will find on trusted sources such as Yahoo Finance, Google Finance, Xigninte, and XE.
In this article, we will be exploring the CurrencyScoop API in detail. However, before we delve into the details, let us first learn some basics about forex and mid-market rates.
Forex Trading and Mid-market Rates
The Foreign exchange or Forex market is a global marketplace for exchanging national currencies. We use currencies to purchase goods and services both locally. Across the border, and to conduct a foreign trade – we must exchange currencies.
For example, if you lived in the U.S and wanted to import some items from France, you would’ve paid for that item in euros(EUR). It also applies to traveling, where we exchange at the current exchange rate. But there’s no centralized exchange for this trading as the currencies are traded worldwide in the major financial centers.
Below are some key terms that are used in forex trading.
Buy Rate
The buy rate of a currency is the rate the traders are willing to buy a currency for.
Selling Rate.
It’s also called asked price, and it’s the amount that a trader is selling the currency for.
Mid-market exchange rate
It’s defined as the midpoint between the “buying rate” and the “selling rate.” It’s sometimes referred to as the interbank exchange rate as well.
Real-time Exchange Rate.
It’s the latest available exchange rate between two currencies based on the real-time changes in the market. It keeps fluctuating all the time.
One of the significant benefits of using CurrencyScoop API is that it provides a real-time mid-market rate – which is the most accurate rate that we usually find on Google, Reuters, Yahoo Finance, etc.
What is CurrencyScoop API?
The CurrencyScoop API is a set of REST APIs that provides daily and historical exchange rates for over 200+ world currencies and precious metals. The API delivers the data in a JSON format that can be accessed using numerous languages and platforms.
The API’s backend sourced the data using a combination of financial data provides and banks, including European Central Bank and Canadian Central Bank. The platform is hosted on high-end cloud infrastructure that ensures the data is delivered within milliseconds. It also maintains uptime at nearly 100%, making it ideal for enterprises of all sizes.
The API is free and provides separate endpoints for retrieving a list of currency, latest and historical currency rates.
How does the CurrencyScoop API Work?
The CurrencyScoop API follows REST principles and provides endpoints that can be executed over the web using the language and framework of your choice.
It works in the following way:
The client application executes the endpoint using the RapidAPI’s Autogenerated SDK. The API processes the requests and retrieves the required information from its database, where currency rates are sourced using multiple sources.
The API then formats the data and delivers it to the client as JSON formatted response, as illustrated below.
Who can use the CurrencyScoop API?
Forex Traders and Brokers
The CurrencyScoop API can be beneficial to forex traders and brokers seeking to get accurate mid-market exchange rates with hassle-free integration. There are many web and mobile applications that can be used to integrate with CurrencyScoop API. Unlike traditional apps, APIs allow users to customize and visualize data in any format with the help of dashboards, widgets, and charts.
Application Developers
Application developers, aiming to build a variety of web and mobile applications for the financial market, are the primary target audience of the CurrencyScoop API. The API is developer-friendly as it follows the REST principles and provides the fastest speed and service availability.
Data Scientists
The CurrencyScoop API has endpoints that provide historical exchange rates for any given period. It’s beneficial for data scientists and AI enthusiasts for various purposes, such as building predictive models, creating data lakes, big data analytics, etc.
E-Commerce Application and Plugins
The API can also be used to extend the functionality of e-commerce applications using plugins to cater to the need for currency conversion, localized subscription, and payment processing abilities.
Payment Gateways
Building a payment gateway from scratch is a complex job. However, the overall complexity can be reduced by delegating the job of some of the components (like currency conversion) to the trusted data provider like CurrencyScoop API – making it easier for their customers to work with multiple currencies.
How to Connect to CurrencyScoop API Tutorial – Step by Step
In this section, we will learn how to connect to CurrencyScoop API using RapidAPI.
Step-1: Signup for an Account on RapidAPI
Navigate to RapidAPI and click on signup to create your account. If you already have an account on RapidAPI, then you may log in to access your dashboard. (RapidAPI allows you to find and connect to thousands of APIs using one SDK and one API Key.)
Step2: Search the API Marketplace
Once you have signup successfully, you will be redirected to the dashboard. You can then Navigate to “API Marketplace” and search for “CurrencyScoop API,” as illustrated below.
Click the first item from the search result, and it will take you to the CurrencyScoop API’s home page.
Step3: Test the CurrencyScoop API
Navigate to the ‘Endpoints’ tab and select the ‘CurrencyList’ endpoint. You will notice that the required header parameters like API-Key and Host have automatically been generated by RapidAPI Console.
Click on the ‘‘Test Endpoint’ button, and it will execute the endpoint. Next, you can view the JSON response in the ‘Results’ tab, as shown below.
The API is successfully executed and returned the list of all currencies in JSON Formatted text.
API Error Codes
When the API server detects any error, it will return an HTTP 422 status code along with a JSON object containing detailed information about the error.
Below are some standard API Error codes:
- 400 Bad Request – Client sent an invalid request (missing required parameters).
- 401 Unauthorized – Failed to authenticate with the API server.
- 403 Forbidden – The client authenticated but didn’t have permission to access the required resource.
- 404 Not Found – The requested resource (endpoint) doesn’t exist.
- 500 Internal Server Error – A generic error occurred on the API server.
- 503 Service Unavailable – The API service is not available.
- 600 – Maintenance – The API is offline for maintenance.
- 601– Unauthorized missing or incorrect API Token.
- 602– Invalid query parameters.
- 603 – Authorization subscription level required.
Explanation of CurrencyScoop API Endpoints
The CurrencyScoop API has three endpoints that can be executed using the GET method.
- /CurrencyList
This endpoint doesn’t have any required parameters, and it provides the JSON object containing the list of 200+ currencies and the list of countries that use that currency.
The JSON object contains the following fields
- Three-letter ISO currency code, e.g. USD/EUR
- Decimal_units.
- Countries: It’s an array of countries that use that currency.
The below image illustrates the successful response from the above endpoint.
2./Historical Rates
This endpoint allows the user to retrieves the historical exchange rate for any given date. It takes a required parameter ‘date’ with a valid date format (YYY-MM-DD).
The API returns the following JSON response.
- Date: date given by the user.
- Base: “USD” – base currency will always be “USD.”
- Rates: This field is an array that contains the list of all currencies and their rates for a given date.
For example, executing this endpoint with the date ‘2020-01-50’ produces the following response from the server.
3./Latest Currency Rates
This endpoint provides real-time rates of all the supported currencies by CurrencyScoop. The successful call to this endpoint will generate a very similar response to the historical rates endpoint. However, the subtle difference is that the date parameter in this endpoint contains the current date.
In the following section, we will learn how to integrate the CurrencyScoop API using various programming languages.
How to use CurrencyScoop API with Python
Before using the code snippet given below, please make sure that you have installed the Python application.
The below example uses http.client library to execute the ‘Latest Currency Rates’ endpoint.
import http.client conn = http.client.HTTPSConnection("currencyscoop.p.rapidapi.com") headers = { 'x-rapidapi-key': "ce19d0164fmsh3d383efc0e85ce5p16dcb1jsnb1a4a3c79541", 'x-rapidapi-host': "currencyscoop.p.rapidapi.com" } conn.request("GET", "/latest", headers=headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8"))
How to use CurrencyScoop API with PHP
If you haven’t installed PHP on your system then you may follow this guide on how to install this correctly.
We have generated the client SDK using PHP Curl which also executes the ‘Latest Currency Rates’ endpoint.
<?php $curl = curl_init(); curl_setopt_array($curl, [ CURLOPT_URL => "https://currencyscoop.p.rapidapi.com/latest", CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => [ "x-rapidapi-host: currencyscoop.p.rapidapi.com", "x-rapidapi-key: ce19d0164fmsh3d383efc0e85ce5p16dcb1jsnb1a4a3c79541" ], ]); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response;
How to use CurrencyScoop API with Ruby
In the below example, we are using Ruby’s net-http gem to execute the historical endpoint for a date ‘2021-01-01’
require 'uri' require 'net/http' require 'openssl' url = URI("https://currencyscoop.p.rapidapi.com/historical?date=2021-01-01") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Get.new(url) request["x-rapidapi-key"] = 'ce19d0164fmsh3d383efc0e85ce5p16dcb1jsnb1a4a3c79541' request["x-rapidapi-host"] = 'currencyscoop.p.rapidapi.com' response = http.request(request) puts response.read_body
How to use CurrencyScoop API with Javascript
To use the API in JavaScript, you need to first set up the JavaScript environment. You can download text editors such as Atoms, Visual Studio Code, NotePad++, etc.
The following code snippet demonstrates how to retrieve the latest exchange rates using the fetch method in JavaScript.
fetch("https://currencyscoop.p.rapidapi.com/latest", { "method": "GET", "headers": { "x-rapidapi-key": "ce19d0164fmsh3d383efc0e85ce5p16dcb1jsnb1a4a3c79541", "x-rapidapi-host": "currencyscoop.p.rapidapi.com" } }) .then(response => { console.log(response); }) .catch(err => { console.error(err); });
We can see from the below image that all the API calls were executed successfully using various SDKs.
Benefits
Free: The API is free and doesn’t need any subscription, which makes it an excellent choice for developers and startups aiming to use free finance market data
Availability and Speed: The speed can be a difference between a good user experience and a bad one. And this is another area where it shines by providing a latency of 700ms. In addition, the API is backed by a highly available cloud infrastructure which ensures 100% service availability.
Accurate and Trusted: CurrencyScoop API provides real-time mid-market exchange rates, which can be verified from popular independent sources. The data is sourced from multiple financial data providers and banks, including the European Central Bank and Canadian Central Bank.
Easy-to-Integrate:
CurrencyScoop API delivers the data in universally usable JSON format, compatible with any programming language of your choice.
Alternatives to CurrencyScoop API
Below are some alternatives to CurrencyScoop API.
- Currency Conversion and Exchange Rates: It’s a freemium API that also provides current and historical foreign exchange currency rates. It has additional endpoints that allow direct conversion from one currency to another and also generating time-series data for a given date range.
- Forex: This is a paid API that delivers real-time 145+ country and 2000+ forex currencies combination. It has various endpoints that support currency conversion, search, currency profile, latest price, pivot points, etc.
- FCS API: This is also a paid API that is powered by 25+ currency exchange data sources. It also provides exchange rates for cryptocurrencies as well.
- ExchangeRate-API: It’s a free API that provides the latest exchange rates for all 160 world countries.
- CurrencyAPI.NET: It’s a freemium API and allows users to retrieve real-time currency rates, historical data, and timeframe series. It has a separate endpoint for direct currency conversion using the latest exchange rate.
Summary
In this article, we have learned how CurrencyScoop API can be used to retrieve accurate currency exchange rates. We also explored all of its endpoints, the benefits of this API, and how to connect to it using RapidAPI, which provides a single platform to generate the code snippet for any programming language and execute the endpoints without leaving the browser.
Leave a Reply