- FixerIO - Exchange Rates and Currency Conversion with

My most stressful tasks as a coder have always revolved around money.  Whether you’re coding a site for a client, your own business, or your employer, you want to be damn sure that any handling of is accurate, secure, and localized.  We always want our code to work but when someone’s livelihood or employment is on the line, another level of importance is realized.

After using, I’m convinced I’ve found the best solution. provides currency and for present and historical , ensuring accurate data at checkout as well as refunds in the case that currency has changed over .

Quick Hits

  • lets you sign up for free
  • is trusted by Microsoft, Kraken, Samsung, and instacart
  • is a simple, easy to use API
  • provides accurate current and historical currency data
  • also provides Bitcoin (BTC) information
  • is from apilayer, the same service provider for currencylayereversign, and streetlayer

Using is another apilayer masterclass in creating an API that’s easy to use and very focused.  The easiest API call is as follows:

# Get currency rate based on EUR

      // ...
      // ...

With this call you’ll get currency conversions with a given base currency, in this case the US Dollar.

Now consider the case of a refund, especially a refund to a currency like Bitcoin that fluctuates quickly.  If the currency sharply increases, it’s possible that may want to request a refund simply due to the value change.  You can protect yourself or your client by using’s state_date and end_date parameters to get a currency value change over a given date:

    ? access_key = API_KEY
    & start_date = 2012-05-01
    & end_date = 2012-05-25

    "success": true,
    "timeseries": true,
    "start_date": "2012-05-01",
    "end_date": "2012-05-03",
    "base": "EUR",
    "rates": {
          "USD": 1.322891,
          "AUD": 1.278047,
          "CAD": 1.302303
        "2012-05-02": {
          "USD": 1.315066,
          "AUD": 1.274202,
          "CAD": 1.299083
        "2012-05-03": {
          "USD": 1.314491,
          "AUD": 1.280135,
          "CAD": 1.296868

Retrieving that value lets you refund to the given fiat currency without losing value based on the time of transaction!

apilayer always allows you to use JSONP with their APIs, and is no exception:

// set endpoint and your access key
endpoint = 'latest'
access_key = 'API_KEY';

// get the most recent exchange rates via the "latest" endpoint:
    url: '' + endpoint + '?access_key=' + access_key,   
    dataType: 'jsonp',
    success: function(json) {

        // exchange rata data is stored in json.rates
        // base currency is stored in json.base
        // timestamp can be accessed in json.timestamp

So many APIs don’t support JSONP, making you create your own proxies — thankfully not!

Conclusion is exactly what an API should be:  easy to use, no hassle, and reliable;  I enjoy using and reviewing apilayer’s APIs for just that reason.  When the data really matters, especially in the case of money, use an API you can trust —!

Source link


Please enter your comment!
Please enter your name here