Thursday, January 15, 2009

Google Currency Conversion API

Well, the api is pretty straight forward.  
I stole it from the Curreny Conversion gadget from IGoogle.

Here is the example:

Here is templage in php:
$amount = "100";
$from_Currency = "EUR";
$to_Currency = "AUD";

$query_URL = "http://www.google.com/ig/calculator?hl=en&q=$amount$to_Currency.%3D%3F$to_Currency";


And the resposnse looks like this:
{lhs: "100 Euros",rhs: "191.745037 Australian dollars",display: "DISPLAY_FULL_PAGE",error: "",icc: true}

That is all I know for now.

19 comments:

Rizwan said...

Thanks Brother for posting this here.
It helped em alot

Unknown said...

Thanks man! How did you find this? Is their documentation somewhere?

Anonymous said...

My update :)

$amount = urlencode("100");
$from_Currency = urlencode("EUR");
$to_Currency = urlencode("AUD");
$url = "hl=en&q=$amount$from_Currency%3D%3F$to_Currency";
$rawdata = file_get_contents("http://google.com/ig/calculator?".$url);
$data = explode('"', $rawdata);
$data = explode(' ', $data['3']);
$var = $data['0'];
echo $var;

outputs just a number :)

Justin W said...

Hey, here's another site I found which looks pretty easy www.exchangerate-api.com

sasikumar said...

Nice :)

Unknown said...
This comment has been removed by the author.
Weslly said...

here's my one line solution:

print_r(json_decode(str_replace(Array('lhs','rhs','error','icc'),Array('"lhs"','"rhs"','"error"','"icc"'),file_get_contents("http://www.google.com.br/ig/calculator?q=1USD=?BRL")),true));

Unknown said...
This comment has been removed by the author.
Unknown said...

Is the API given trail version or it is a Full version. Please reply ASAP as I'm getting problems using it for my site or please give me reply to my Email Id.(vijaykumar.ambala@gmail.com)

Anonymous said...

Its free to use

Unknown said...

Hi,

A huge thanks to James ...

To the publisher...:D

It works..

Softmatrix Technologies said...
This comment has been removed by the author.
Syntaqx said...

This method has been implemented into a google package for the FuelPHP framework. I hope you can either use it within Fuel, or you can port it into your own system.

https://github.com/ninjarite/fuel-google/blob/master/classes/num.php

Gl!

basZero said...

NOTE: somebody posted a comment earlier of a service which is a commercial API ! www.exchangerate-api.com

Kish said...

But if you try to find IDR rate I cant split rate.
eg. http://www.google.com/ig/calculator?hl=en&q=1USD=?IDR
o/p:
{lhs: "1 U.S. dollar",rhs: "9 090.90909 Indonesian rupiahs",error: "",icc: true}

Now can I get rate upto four decimal places.

If try to do it , it only returns 9 .
Plz help

Umair Aslam said...

Awesome work , nice effort by author . I modified it a little on .net and make a function if any one need it then can get from

http://umairaslam.blogspot.com/2012/01/google-currency-converter-code.html

I make it in C# it need three arguments
This update is on .net 3.5

hava said...

Seems it shows 2 results eg:
http://www.google.com/ig/calculator?hl=en&q=100USD=?EUR
78.1616383
refresh
77.9423227
refresh
78.1616383
ans os on, what whould that mean, sell/buy?

Unknown said...

Not sure what the deal is.

For me, when I refresh numerous times it didnt toggle between the two values, it randomly selected one of three values.

It looks more like the requests are each is handled by different servers, one of which hasnt yet updated (which is a bit crap).

apple said...

Currency conversion is very important to us, so we must be updated about this. Thanks for sharing this, it really help a lot.

Philippine Peso Exchange Rate