Exchange Rates and Currency Conversion with (Sponsored)

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 currency 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 conversion and exchange rates for present and historical time, ensuring accurate data at checkout as well as refunds in the case that currency has changed over time.

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
{ "success":true, "timestamp":1521677363, "base":"EUR", "date":"2018-03-22", "rates":{ "AED":4.538449, "AFN":85.146208, // ... "BTC":0.000139, // ... "USD":1.235794 }

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 customers 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:

curl ? 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": { "2012-05-01":{ "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:
$.ajax({ url: '' + endpoint + '?access_key=' + access_key, dataType: 'jsonp', success: function(json) { // exchange rata data is stored in json.rates alert(json.rates.GBP); // base currency is stored in json.base alert(json.base); // timestamp can be accessed in json.timestamp alert(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 —!

Related Post

Rojenx is a leading concept artist who work appears in games and publications

Check out his personal gallery here

In other news …