Skip to content

Get Historical Exchange Rates With A Forex API

Do you need historical foreign exchange rates for a financial settlement, production, historical currency conversion straight into your app, or any other use? An API will surely fit your needs.

The foreign exchange market is the biggest, most liquid market in the world. It consists of over $5 trillion U.S. dollars being traded daily by investors.

Exchange rates are the rates at which one currency can be exchanged for another. In modern trading, it is vital to know exchange rates in order to know the actual value of a particular product from a foreign country. When you visit a website which has all pricing information in US Dollars, there is no way of knowing if you are actually getting the best deal for yourself or not. What if at that time, the price was actually less if you paid in Euros?

Get Historical Exchange Rates With A Forex API

While the implications of knowing historical exchange rates can be tremendous, there are many different scenarios in which the use of this information can be very handy. Some examples include:

  • Knowing whether historical exchange rates were in your favor could help offset costs and save you money.
  • Knowing past exchange rates is beneficial because it allows you to see how the current exchange rate came to be.
  • When you have an idea about the historical exchange rates, you can plan your investments better.

Exchange rates represent the value of a given currency relative to another. These values change frequently, and sometimes dramatically, such as when currencies experience periods of high inflation or rapid economic growth . This is why if you’re investing in forex, it’s critical to be able to see what happened, to better help you undesrtand what might happen.

We recommend using Exchangr for this task

Why Exchangr?

Exchangr is a REST API that uses the JSON data format to deliver accurate currency exchange rates and conversions to consumers and businesses.

Get Historical Exchange Rates With A Forex API

For diverse actions, the API includes five customisable endpoints. The live endpoint returns real-time exchange rates, while the historical endpoint returns historical currency rates, the convert endpoint returns multiple currencies, the time-series endpoint returns exchange rates over a specified period, and the fluctuation endpoint returns change parameters for any currency.

From all across the world, the Exchangr API accepts 164 currencies and 8 cryptocurrencies. The data is acquired from a number of commercial forex data sources and banks and mixed algorithmically before being supplied to clients. It updates data on a regular basis, with intervals of 60 minutes to 24 hours.

Data about historical exchange rates can be found here.

If you’re looking for an API to access live and historical pricing, you’ve come to the right place. Historical data, daily closing rates, and historical currency exchange rates are all available through the Exchangr API. It’s also a great API for getting cryptocurrency information, like as current and historical prices. More than 164 currencies, including eight cryptos, are supported through an efficient historical FX API.

You may query the Exchangr API for historical rates by adding a date (format YYYY-MM-DD) to the base URL.

The URL for this endpoint is https://api.getexchangr.com/historical/DATE, and here’s a sample curl command to get historical USD currency values for April 26, 2021:

$ curl 'https://api.getexchangr.com/historical/2021-04-26?apikey=YOUR_APIKEY'
{
    "date": "2021-04-26",
    "base": "USD",
    "rates": {
        "FJD": "2.033",
        "MXN": "19.8618",
        "STD": "20738.069016",
        "SCR": "14.146",
        "CDF": "1991.5905",
        "BBD": "2.0",
        "HNL": "24.0876",
        "UGX": "3600.499",
        "ZAR": "14.2733",
        "STN": "20.500089"
        }

Convert exchange rates from the past.

There are two more elements to the historical rates conversion endpoint. The first is that you can change the base currency in the history rates to move between prior currency rates, and the second is that you can acquire historical forex rates for any currency with any base currency.

As seen in the example below, the QAR (Qatari Rial), CNH (Chinese Yuan Renminbi), and BTC (Bitcoin) to SGD (Singapore Dollar) conversion endpoints use historical cross rates to provide additional historical currency values.

You just need to provide the value of the query parameter “base” as well as any preceding date. On April 5, 2021, here’s a curl example for converting past cross rates.

$ curl 'https://api.getexchangr.com/historical/2021-04-05?apikey=YOUR_APIKEY&symbols=QAR,CNH,BTC&base=SGD'
{
   "date": "2021-04-05",
   "base": "SGD",
   "rates": {
       "QAR": "2.7133",
       "CNH": "4.890211842443814",
       "BTC": "0.000012648815118471506"
   }
}

Get the difference in currency exchange rates between two dates in the past.

You may use this endpoint to look up historical rates between two dates in the API. It is the most efficient method of obtaining time-series data for studying trends in historical forex data. It may also be used to map and track historical exchange rates over time for certain days, months, or years.

This endpoint’s URL is https://api.GetExchangr.com/timeseries. and here’s a curl example to collect 30 days of LKR (Sri Lanka Rupee), OMR (Rial Omani), PHP (Philippine Peso), TRY (Turkish Lira) time series analysis from 2021-03-025 to 2021-04-26 by base TWD (New Taiwan Dollar).

$ curl 'https://api.getexchangr.com/timeseries?apikey=YOUR_APIKEY&start_date=2021-03-025&end_date=2021-04-26&symbols=LKR,OMR,PHP,TRY&base=TWD'
{
   "start_date": "2021-03-25",
   "end_date": "2021-04-26",
   "base": "TWD",
   "rates": {
       "2021-03-25 00:00:00+00": {
           "LKR": "6.96",
           "OMR": "0.0136",
           "PHP": "1.7055",
           "TRY": "0.279"
       },
       "2021-03-26 00:00:00+00": {
           "LKR": "6.9554",
           "OMR": "0.0135",
           "PHP": "1.6893",
           "TRY": "0.2843"
       },
       "2021-03-27 00:00:00+00": {
           "LKR": "6.9554",
           "OMR": "0.0135",
           "PHP": "1.6893",
           "TRY": "0.2843"
       },
       [...]
   }
}

Conclusion

The forex API from Exchangr not only supports common currency pairs, but it also calculates cross rates by linking major currencies. We make every attempt to obtain accurate data from a variety of trustworthy sources in order to cover even the smallest traded currencies. A link to past data coverage may be found here. As a consequence, you can trust the Exchangr FX API to handle even the most difficult business needs.

Create a free account and acquire your API key to use the Exchangr API; no credit card is necessary. You can also join up with your Google account.


Also published on Medium.

Published inAppsTechnology
%d bloggers like this: