Dev CenterΞ

FXR-API: Foreign Exchange Rates API

Twitter · Facebook
FXR-API provides you a reliable platform to receive live (near real-time) and historical exchange rates for several currencies across the world.Free foreign exchange rates and currency conversion API

FXR-API currently supports the following 15 currencies: United States Dollar (USD), Euro (EUR), British Pound Sterling (GBP), Japanese Yen (JPY), Swiss Franc (CHF), Australian Dollar (AUD), Chinese Yuan Renminbi (CNY), Canadian Dollar (CAD), New Zealand Dollar (NZD), South African Rand (ZAR), Indian Rupee (INR), Ghanaian Cedi (GHS), Nigerian Naira (NGN), Kenyan Shilling (KES), and West African CFA Franc (XOF). However, more currencies will be added soon.

Below are the various API resources that are currently available:

GET /{currency}

This API resource returns a currency object representing the currency information and live exchange rates for {currency} against a selected list of currencies, namely, USD, EUR, GBP, JPY, and CHF. If the exchange rate of the specified currency against one of the selected currencies is less than 1.0000, the pairing is reversed with the specified currency becoming the counter currency instead. You may, however, disable this behavior by appending the query string parameter fixed to the request. If the specified currency is not found, an HTTP 404 status response is triggered.

Example request:

https://dev.kwayisi.org/apis/forex/ghs

Example response:

{
   "code": "GHS",
   "name": "Ghanaian Cedi",
   "rates": [
       {
           "date": "2016-01-19",
           "pair": "USD/GHS",
           "rate": 3.8723
       },
       {
           "date": "2016-01-19",
           "pair": "EUR/GHS",
           "rate": 4.2262
       },
       {
           "date": "2016-01-19",
           "pair": "GBP/GHS",
           "rate": 5.4854
       },
       {
           "date": "2016-01-19",
           "pair": "GHS/JPY",
           "rate": 30.3746
       },
       {
           "date": "2016-01-19",
           "pair": "CHF/GHS",
           "rate": 3.8593
       }
   ]
}

GET /{base-currency}/{counter-currency}

This API resource returns a quotation object representing the relative active (live) value of {base-currency} against {counter-currency} on the foreign exchange market. Unlike GET /{currency}, the specified base currency is unconditionally made the fixed currency of the currency pair. If either of the specified currencies is not found, an HTTP 404 status response is triggered.

Example request:

https://dev.kwayisi.org/apis/forex/usd/ghs

Example response:

{
   "date": "2016-01-19",
   "pair": "USD/GHS",
   "rate": 3.8723
}

GET /{base-currency}/{counter-currency}/{date}

This API resource returns a quotation object representing the relative historical value of {base-currency} against {counter-currency} on or before {date} on the foreign exchange market. The date is recommended to be in the format YYYY-MM-DD. If either of the specified currencies is not found, or no currency data exists for the specified date, an HTTP 404 status response is triggered.

Example request:

https://dev.kwayisi.org/apis/forex/usd/ghs/2016-01-01

Example response:

{
   "date": "2016-01-01",
   "pair": "USD/GHS",
   "rate": 3.8092
}

Currency object

PropertyTypeNullable?Description
codestringNoCurrency code (ISO 4217).
namestringNoOfficial name of currency.
ratesarrayNoArray of quotation instances.

Quotation object

PropertyTypeNullable?Description
datestringNoDate of rate (ISO 8601).
pairstringNoCurrency pair separated by slash (/).
ratefloatNoExchange rate for the pair.

Comments (6)

  1. BiikBiik
    Mar 30, 2016 08:51 GMT

    Hi Michael,
    Thanks for hosting these great public APIs!
    I've been able to request stock data through your GSE-API. Marvelous!

    Now I would love to also request forex data through your FXR-API, but Chrome is giving me this error message: 'XMLHttpRequest cannot load 'https://dev.kwayisi.org/apis/forex/ghs'. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:49458' is therefore not allowed access.'

    I'm a programming rookie, would be very thankful for your advice here.

    My jQuery is as follows:
    $(document).ready(function() {
         $.getJSON("https://dev.kwayisi.org/apis/forex/ghs", function(data) {
              console.log(data);
         });
    });

    1. Michael KwayisiMichael Kwayisi
      Mar 30, 2016 10:31 GMT

      Your web browser is preventing you from requesting resources not hosted on the same server as the one executing your JavaScript code. The solution to this is to append "?callback=?" to the URL so that it reads as such: "https://dev.kwayisi.org/apis/forex/ghs?callback=?". Yet another hack (called JSONP) in the JS world, I guess :)

  2. OgaOga
    Mar 1, 2017 20:28 GMT

    HI Mike

    Impressive stuff with your GSE and forex api's.
    Did a random google search on APIs in Ghana and i ended up here.
    Planning on building an iOS app with them as a side project.

    Quick question, whats the source of your forex data ?

    1. Michael KwayisiMichael Kwayisi
      Mar 1, 2017 20:54 GMT

      They are actually gathered from several sources with precedence given to particular ones, most remarkable among them XE.com.

  3. MaxwellMaxwell
    Apr 12, 2017 09:59 GMT

    Nice work. Have you been able to add any new countries yet?

    1. Michael KwayisiMichael Kwayisi
      Apr 14, 2017 00:03 GMT

      Actually, yes - but not live yet :) And not just a few currencies but ALL the active currencies in the world with ISO-assigned codes (157 in total). I'm currently reworking the backend to accommodate the new changes, verifying the data feed sources for improved accuracy, and expanding the historical exchange rates to at least 10 years back where applicable. They'll be live as soon as I'm done. Thanks!

NOTE: You are replying to 's comment. [Cancel]