The world is big and there are various currencies available for various countries. Some time we need to convert an amount from one currency to another, some time we want to see the current market price of one currency to other. Maximum time we need to check the USA market value in terms of US dollar.

 

To do this, we generally search in Google to get the current market value of currency. Now think a scenario when you want to integrate it in your application. In this post I will discuss about the converter API and how to retrieve the result using JSON.

 

Apart from Google, there are many other websites too which provide online currency conversion. Here we will discuss about the Google’s Currency Conversion Calculator API using JSON object. Google’s currency converter uses a secret open API for all types of foreign currency conversion.

 

How to use Google’s Currency Converter using JSON API?

If you want to use this JSON API for doing the currency conversion, you can build your query string and pass to the http://www.google.com/ig/calculator URL for processing.

 

The correct form of the URL will be: http://www.google.com/ig/calculator?hl=en&q=[VALUE][FROM_CODE]=?[TO_CODE]

 

Notice the above URL. [VALUE] represents the amount that you want to pass to the converter, [FROM_CODE] and [TO_CODE] represents the currency code of respective currencies.

 

For example, if you want to convert currency from 1 USD to INR, you have to construct the following URL:

http://www.google.com/ig/calculator?hl=en&q=1USD=?INR

 

The above link will return you the below JSON object, which you can extract to get the converted value:

{lhs: "1 U.S. dollar",rhs: "55.8284949 Indian rupees",error: "",icc: true}

 

I hope, this small post will be useful to you in near future. So don’t forget to bookmark it. If you came to this post by searching online, use the logic mentioned above to construct your URL and retrieve the converted currency value from the JSON object returned by the Google API. All the best and Happy Coding!!!

Have a question? Or, a comment? Let's Discuss it below...

Thank you for visiting our website!

We value your engagement and would love to hear your thoughts. Don't forget to leave a comment below to share your feedback, opinions, or questions.

We believe in fostering an interactive and inclusive community, and your comments play a crucial role in creating that environment.