Today I’m chuffed to release two closely related projects that have been eating up all my spare time recently. I started work on both specifically for our enterprise analytics application (just like accounting.js) but they soon took on a life of their own – quite literally, in one case.
You only need exchange rates relative to one single currency (eg. USD) to be able to convert between any others – money.js does it all for you.
More info, demo, download and docs at the money.js homepage
“But where do we get these exchange rates?” (“Maybe there’s some in that truck!!..”)
The biggest issue with currency conversion has to be sourcing reliable exchange rates without having to sell your mum to pay for the API access. I’ve been wanting to take a stab at that for a long time, and here it is:
The Open Source Exchange Rates API project
While working on money.js, I realised very quickly that finding a free, reliable source of JSON-formatted, regularly updated data (with no access limits or hidden catches) is, well, impossible. It just doesn’t exist.
It was originally designed for integration with money.js, and hacked together in an afternoon. It’s powered by a simple nodeJS scraper and a list of currencies: every hour, Currency Bot collects all the exchange rates from the Google Calculator API (one by one), then pushes them in JSON format to a public GitHub code repository for everybody to use.
The rates are available historically for any day since the project started, and could soon be extended to provide data going back several years.
Also, it’s mirrored on openexchangerates.org, which sends files with friendly
Access-Control HTTP headers for cross-origin resource sharing (
CORS) – so that they can be loaded into an app or page via AJAX.
I would write more, but I’m shattered after waking up at 6am to get Currency Bot out of his can’t-scrape-won’t-scrape funk (he had a few teething problems.) He’s back on form and collecting data like a boss – you can see it at the currencybot/open-exchange-rates GitHub repository.
Learn more about using the free service at the Open Source Exchange Rates API homepage!
The next step
Wow. I’ve wanted to get these two done for a long time, and now I’m left scrambling to find something else to do – lucky for me, there’s plenty. Here’s the future plans for these two projects (if you feel you can contribute, please get in touch!)
- Find a way to do a once-off retrospective crawl of historical exchange rates going back as far as possible. This will almost certainly involve abusing another free but non-user-friendly or rate-limited service. Open to suggestions.
- Package up money.js into a
npmmodule so that you can go
npm install moneyjs.
- Write documentation for how to use the Open Source Exchange Rates API in the most popular languages and frameworks
- Write a full test suite for money.js
- And a bunch more – all I can say is, hit ‘watch’ on the GitHub repositories (here and here) and follow me on twitter here if you’re interested and want to keep up to date.
Thanks for reading!