Published Friday 18th August 2023

QWeb Ltd launches new exchange rates API

Back in 2014 I wrote a post about a rate exchange API that did a decent job replacing a Google service which had shut down the prior November. A year later, in 2015, this API too was shut down, and finding the alternatives were all just as unstable, we opted to build our own as part of our Egg Basket ecommerce framework. We opened this up to the public at rates.egg-basket.com/exchange where it ran until 2022, before changes to the origin services that we source this data from meant that quite a heavy rewrite was needed.

Egg Basket is today somewhat of a dead framework. It's still technically available for public use but we no longer use it internally, or advocate using it for any new projects. It's not kept up to date, doesn't comply with modern design principles or GDPR, and we can't guarantee that it's still completely operational. There are plans to migrate its functionality in to one of our newer frameworks, QFlex CMS, which we'll then be releasing as open source software to replace Egg Basket entirely so when rewriting our exchange rates API became a necessity, it just made good sense to move it out of the Egg Basket brand too.

This rewrite was completed fairly quickly, and our new exchange rates API has been running for nearly a year now at its new location. We added a notice to the older Egg Basket endpoint so that developers using it knew to get in touch for private access, but we otherwise weren't ready to go public before now, because we've been busy building a whole new API portal to migrate some of our other APIs into, most of which will be going public for the very first time!

API portal  development was completed yesterday, and although there's currently only the one API accessible through it - our new currency exchange rates API - we're proud to officially announce this new service, and the public availability of the Currency Exchange Rates API by QWeb Ltd with conversion rates for over 160 currencies, updated daily.

This is a REST API returning JSON objects, making it super simple to use in any project. You just need to generate an access key via the new portals API Console, and use it in basic HTTP GET requests. Here's a really basic example of how to do this in PHP:

// Generate your access key through https://apis.qweb.co.uk/console
$accessKey = 'YOUR_ACCESS_KEY';
$from = 'gbp';
$to = 'usd';
$amount = 10;

// Curl would be a better option for performance and flexibility, but file_get_contents() is simpler
$data = json_decode(file_get_contents('https://apis.qweb.co.uk/currency-exchange-rates/'.$accessKey.'/'.$from.'/'.$to.'.json'));

if($data->answer == 'success')
	echo number_format($amount, 2).' '.$from.' is '.number_format($amount * $data->exchange, 2).' '.$to;

The https://apis.qweb.co.uk/currency-exchange-rates endpoint takes 3 parameters, as per the example above. The first is your access key which you generate through the API Console, the second is the origin currency you want an exchange rate from, and the third can be either a single currency, or a comma separated list. Refer to the Currency Exchange Rates API homepage for a list of supported currency codes, and for usage further examples.

Photo of Ric

Ric

Ric is a senior web and game programmer with nearly 30 years industry experience and countless programming languages in his skillset. He's worked for and with a number of design and development agencies, and is the proprietor of QWeb Ltd. Ric is also a Linux server technician and an advocate of free, open-source technologies. He can be found on Mastodon where he often posts about the projects he's working on both for and outside of QWeb Ltd, or you can follow and support his indie game project on Kofi. Ric also maintains our Github page of useful scripts.

Blog posts are written by individuals and do not necessarily depict the opinions or beliefs of QWeb Ltd or its current employees. Any information provided here might be biased or subjective, and might become out of date.

Discuss this post

Avatar for C\5

Ric, Tuesday 12th September 2023 23:02

Just over 3 weeks since launching our API portal and this currency exchange rates API, we've already moved 3 of our other APIs in. There's now an IP lookup API, an ASN lookup API, and a places lookup API to explore. We've still a couple of others to migrate yet, and the repository will continue to grow over time as we build more systems.

Leave a comment

Your email address is used to notify you of new comments to this thread, and also to pull your Gravatar image. Your name, email address, and message are stored as encrypted text. You won't be added to any mailing list, and your details won't be shared with any third party.

This site is protected by reCAPTCHA and the Google Privacy Policy & Terms of Service apply.