Motyar

Google's Currency Converter and JSON API

There are a lot of online Currency Converter Calculators on web. I want to share one more with you.
You can believe it; because its Google's Currency Converter Calculator. It can be used to see changes live for currency and foreign exchange rates with this free currency converter.

Here is the Google's Currency Converter

Open JSON API
Good news is here - Google have a secrete API for Currency Conversion. Its a simple open API you can use for all type of foreign currencies.

How to use it?
If you want currency converter £ to dollars, use it like this -
http://www.google.com/ig/calculator?hl=en&q=1GBP=?USD

If you want to calculate currency converter $ to £ -
http://www.google.com/ig/calculator?hl=en&q=1USD=?GBP

You can change value of input currency, for example you want to know the value for $100 in India Rupees
http://www.google.com/ig/calculator?hl=en&q=100USD=?INR

Working ready script

Hope you enjoyed the post, I am on twitter @motyar.

Labels: , ,

By :

23 comments

#

Anonymous Piotr Nalepa says…

Thx a lot. That's very useful info. It'll help me to develop currency calculator.
 
#

Anonymous rtg says…

i think its not working..any idea on fetching it?
 
#

Anonymous Enrichman says…

You're my day hero!

Thanks a lot for this, very helpful!
 
#

Anonymous Anonymous says…

it is working like a silver bullet
 
#

Blogger Brian says…

It does not return valid JSON and won't decode properly. For example, it returns:

{lhs: "1 U.S. dollar",rhs: "0.991099923 Canadian dollars",error: "",icc: true}

But, that string should have quotes around the lhs, rhs, error, and icc in order to be valid JSON.
 
#

Blogger Rumen Georgiev says…

var lines = this.responseText.replace(/{|}|\"/g,"").split(",");
var result = {};
for(var i in lines){
var kv = lines[i].split(":");
result[kv[0]] = kv[1].trim();
}
console.log(result);
 
#

Anonymous Anonymous says…

Can someone send the complete javascript code that returns the string from the URL http://www.google.com/ig/calculator?hl=en&q=1GBP=?USD.

That is I want to capture the value({lhs: "1 British pound",rhs: "1.6069 U.S. dollars",error: "",icc: true}) returned from the URL inside a textbox

 
#

Blogger Ketan says…

Thank you very much.
I was very confused regarding currency conversion in my php project.
Now it will be solved
 
#

Blogger gooday says…

hi, i made a php script to clean response from google api. it strips out bad characters in gaps between numbers and make them floats.

http://pastebin.com/P7BpL019
 
#

Blogger dskanth says…

This API is very useful. However, for few countries like Lebanese, i am facing an issue with the returned json response.

For example, i tried this URL:
http://www.google.com/ig/calculator?hl=en&q=1USD=?LBP

The "rhs" in json response (rhs: "1 506.0241) contains a special character of space (Â). How can i strip that and get the original value (1 506.0241) ?

 
#

Anonymous timen chad says…

try this :
http://www.google.com/ig/calculator?hl=en&q=0.1USD=?LBP
it won't be an space character if the result under 1k.
 
#

Blogger Hyacinthus Chu says…

JSON is not well formatted by google's API, lhs,rhs,error,icc should be wrapped by double quotes. Meanwhile, it doesn't support JSONP either. Here is another JSON(P) API http://rate-exchange.appspot.com/currency?from=USD&to=EUR&q=1 based on the Google API.
 
#

Blogger Dheeraj says…

how can I found sport news in news API. all news comes together If we need categories wise.
 
#

Anonymous vipul says…

Thanks foor the info
 
#

Blogger Kuba says…

That would be a fresh news, in 2008
 
#

Blogger Nils Juenemann says…

This feature is deprecated and I'm pretty sure Google will disable it soon.
 
#

Blogger Bhavik Tailor says…

Is it free?
Can I use it for my commercial website?
 
#

Blogger Money Exchange says…

I must appreciate and give thanks to you for providing me an clear information on Google currency exchange converter. My search ends here.
 
#

Blogger Sadèé says…

You can use like this in PHP
$replace = array(
'lhs' => '"lhs"',
'rhs' => '"rhs"',
'error' => '"error"',
'icc' => '"icc"'
);
$json_string = file_get_contents("http://www.google.com/ig/calculator?hl=en&q=1GBP=?LKR");
$json_string = str_replace(array_keys($replace), array_values($replace), $json_string);

$parsed_json = json_decode($json_string);
$output = $parsed_json->{'rhs'};
echo $json_string."
";
echo "Current temperature in 1 GBP = ${output} LKR \n";

Thanx Motyar! (Y)
 
#

Blogger Vasim Shaikh says…

not all currencies are supported for ex, IRR (iranian rial) not supported.
 
#

Blogger ganesh shankar vidharthi says…

Google URL is not providing updated Currency rate. It provides one rate update in a day.
 

Post a Comment