Published Tuesday 15th July 2014

Alternative to Google's currency conversion API

This is an old post about a service that's since been discontinued. We've kept it though, because some of the attached comments might still be useful to somebody. As of August 2023, we're now live with our new Currency Exchange Rates API through the QWeb Ltd API Portal. Please refer to our newer blog post, QWeb Ltd launches new exchange rates API.

It's just been brought to my attention that Google closed their currency conversion API last November. Frustratingly a lot of the international websites that I've built in the past have made use of this API in some way, so I needed a quick fix. In the end this came in the form of rate-exchange.appspot.com who provide an API almost identical to the old Google service.

If your Google API call looked something like this:

http://www.google.com/ig/calculator?q=1USD=?EUR

Then the rate-exchange equivalent is this:

http://rate-exchange.appspot.com/currency?from=USD&to=EUR&q=1

And here's how you can use it from within a PHP script:

$baseCurrency = 'USD';
$currency = 'EUR';
$amount = 1;

$currencyAPIHandle = curl_init();
curl_setopt($currencyAPIHandle, CURLOPT_URL, 'http://rate-exchange.appspot.com/currency?from='.urlencode($baseCurrency).'&to='.urlencode($currency).'&q='.$amount);
curl_setopt($currencyAPIHandle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($currencyAPIHandle, CURLOPT_CONNECTTIMEOUT, 0);
$currencyAPIReturn = curl_exec($currencyAPIHandle);
curl_close($currencyAPIHandle);
$priceData = json_decode($currencyAPIReturn);
$price = $priceData->v;

If this is as useful to you as it is me, please consider donating towards their service.

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 qo]2XX2a C`a2

Muhammad Reda, Monday 13th July 2015 16:19

Link is broken (http://rate-exchange.appspot.com/currency). The app no longer exists.
You can use Currency API instead https://currency-api.appspot.com/

Avatar for C\5

Ric, Monday 13th July 2015 16:57

Thanks Muhammad,

We noticed this was broken but weren’t too keen on the alternatives, so we built our own! You’re welcome to use this one too: http://rates.egg-basket.com/

Avatar for P\y205]\

Biranchi, Saturday 21st January 2017 08:35

Ric Grant, its working great.

I tried to convert from usd to sar with the below request,
http://rates.egg-basket.com/exchange?from=usd&to=sar&amount=1

but i didn’t receive any response.

It would be great if more currencies are supported.

Avatar for C\5

Ric, Monday 23rd January 2017 09:39

Hi Biranchi,

We’ve added SAR to the supported currencies now, so the above conversion should work for you =).

Avatar for P`5ZY`k

Beckley, Monday 10th September 2018 00:33

I've also tried to convert from usd to ngn (Nigerian Naira) but didn't get any response. Have you considered adding the NGN? Thanks.

Avatar for C\5

Ric, Monday 10th September 2018 10:40

Sorry Beckley, it looks like the services that our rates API relies on have made some changes recently that's preventing our system from updating its rates. I'm afraid the current exchange rates returned are therefore out of date and we're unable to add new currencies in at this time.

Working on a resolution and will post back here when we have one!

Avatar for C\5

Ric, Monday 10th September 2018 12:07

Scrap that, sometimes we get things done faster than expected!

The issue found a couple of hours ago is now resolved - we're back up and running thanks to new data providers.

Added in the NGN currency as requested, and also moved the service to https (still available via http, but I'd encourage that you update your scripts to make https calls where possible). Also tidied up the information page inline with our new branding: https://rates.egg-basket.com/

Avatar for Q0^`Y2

Angela, Thursday 17th October 2019 23:21

Hello, I'm looking for an API that last for a really long time and has support for at least my own currency (PEN), american dollars and euro.
I found that rate-exchange-1.appspot.com (https://rate-exchange-1.appspot.com/currency?from=PEN&to=USD&q=25) is still working but not rate-exchange.appspot.com so that makes me think that they couldn't mantain their API alive.
Your API sounds like the perfect option since your last comment was last year haha, but it does not has support for PEN, https://rates.egg-basket.com/exchange?from=pen&to=usd&amount=25 gives no response.

Avatar for C\5

Ric, Thursday 17th October 2019 23:58

Hi Angela. PEN has now been added to our system, but it might take 24 hours to start picking up data before your requests work. Do let me know if you have any problems after this wait.

To anybody else stumbling onto this page. Our own API at https://rates.egg-basket.com has been up for over 4 years now and still going strong. We use it internally for a number of projects so we've no intention of dropping it any time soon. Please do consider donating to help with running costs if it's a useful asset for you =). You'll find a donation link at the bottom of that page.

Avatar for Q0^`Y2

Angela, Friday 18th October 2019 02:10

Thank you so much for answering so soon! I just saw PEN added to your web site, again thank you. I'll start using your service then. Is there a way for me to request convertion from PEN to all other currencies?

Avatar for C\5

Ric, Friday 18th October 2019 12:14

No problem at all.

There isn't a from-to-all call at the moment, no. I can see how adding this in would make sense though, to reduce the number of requests passing back and forth so I'll get that added for you too. Leave it with me =).

Avatar for Q0^`Y2

Angela, Tuesday 22nd October 2019 12:34

Hello and thank you again for being so helpfull.
Yep, my plan is to have a cron asking once a day to register on my database.
I've just checked because I need to implement this right now, that your service doesn't retrieve answer when I try to convert PEN to USD, at first I thought it was becase I had to wait some hours as you said but it has happened too much days already. Would you mind check on that?

Avatar for C\5

Ric, Wednesday 23rd October 2019 14:55

Hi Angela,

Sorry about that. One of the services we use to gather the data was experiencing problems over the weekend so we were a little slower at picking up the data than usual. It looks like they've resolved their issues now and it's coming through at a decent rate again.

While investigating, we made a couple of tweaks to optimise our own system too, and we're looking at other services to add in as fallbacks in case this happens again. We're already fetching the data from a few different sources because no single source is stable enough for us to rely on entirely, and because not all sources supply all of the currencies that we need.

Long story short, I manually added the PEN -> USD rate in yesterday so you should have picked that up by now at your end, and the remaining conversions should all become available within the next few hours.

Avatar for Q0^`Y2

Angela, Monday 4th November 2019 04:26

Thank you so much. Can you believe I'm about to start developing the code for my cron to execute? it's been 10 days since my last comment hahaha.
I saw you didn't add the from-to-all call, or at least I made a test with https://rates.egg-basket.com/exchange?from=PEN&amount=1 and it didn't retrieve anything at all, so I'll work with what I have in my hands. Seriously, thank you so much, I haven't seen such kindness online in a very long time.

Avatar for C\5

Ric, Monday 4th November 2019 14:59

Absolutely no problem. I've just pushed that change live actually, so you're able to receive all supported conversion rates if you just pass the ?from parameter, like this:

https://rates.egg-basket.com/exchange?from=gbp&amount=1

Avatar for C\5

Ric, Friday 18th August 2023 11:44

Our https://rates.egg-basket.com exchange rates API has moved to https://apis.qweb.co.uk/currency-exchange-rates and is now part of our new API Console, which we'll be migrating some of our other APIs into, and launching others for the first time.

If you've previously integrated our API, please update your integration ASAP as our older service will now be returning error messages. If you're looking for an exchange rates API, check out our latest blog post at https://www.qweb.co.uk/blog/qweb-ltd-launches-new-exchange-rates-api or go directly to https://apis.qweb.co.uk/currency-exchange-rates to get started.

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.