Need API for currency converting [closed]

free.currencyconverterapi.com returns results in JSON format.

The web service also supports JSONP. The API is very easy to use, and it lets you convert one currency to another.

Disclaimer, I'm the author of the website.

A sample conversion URL is: http://free.currencyconverterapi.com/api/v6/convert?q=USD_PHP&compact=ultra&apiKey=sample-api-key which will return a value in json format, e.g. {"USD_PHP":51.459999}


As mentioned in the comments this service was shut down in Nov 2013.

Googles calulator API can do this;

Request:

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

Response:

{lhs: "100 Euros",rhs: "145.67 U.S. dollars",error: "",icc: true}

(More info)


Yahoo is no longer working. See comment below

Yahoo Finance Currency Converter.

This url format could be used to fetch conversion rates in different formats.

http://download.finance.yahoo.com/d/quotes.csv?s=AUDUSD=X&f=nl1d1t1

Substitute quotes.csv with appropriate format and parameters with the required codes

EDIT: Added Example Url formats


Now iGoogle has been killed off, Alex K's solution no longer works sadly. In php, this is an alternative which works in the same way and is just as effective:

$amount = urlencode($amount);
$from_Currency = urlencode($from_Currency);
$to_Currency = urlencode($to_Currency);
$get = file_get_contents("https://www.google.com/finance/converter?a=$amount&from=$from_Currency&to=$to_Currency");
$get = explode("<span class=bld>",$get);
$get = explode("</span>",$get[1]);  
$converted_amount = preg_replace("/[^0-9\.]/", null, $get[0]);

UPDATE: Yahoo API is not working anymore. Leaving this legacy answer just to provide information that this doesn't work anymore.


use yahoo api:

http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.xchange%20where%20pair%20in%20(%22USDLTL%22)&format=json&env=store://datatables.org/alltableswithkeys&callback=

it will return json format like:

{
  query: {
  count: 1,
  created: "2013-12-04T13:52:53Z",
  lang: "en-US",
  results: {
    rate: {
        id: "USDLTL",
        Name: "USD to LTL",
        Rate: "2.5485",
        Date: "12/4/2013",
        Time: "8:52am",
        Ask: "2.5486",
        Bid: "2.5485"
      }
    }
  }
}

Check out in the URL there is USDLTL now, so just change to what you need.

Also sometime the rate is so low, that you don't see it even with 4 numbers it shows:

Rate: 0.0006

Do not panic just make a reversal query, flip your currencies and make some simple math.

e.g. you got that the rate is from KRW to EUR 0.0006 but the real rate is something like 0.00000125 so ask API again, just flip the currencies: what is the ratio from EUR to USD. then you will get huge number like 12500000.xxx so make math to get the ratio you need: 1/12500000 and you will get ratio = 0.00000125

Hope that helps ;)

P.S. decoded URL which is easier to read looks like this:

http://query.yahooapis.com/v1/public/yql
?q=select * from yahoo.finance.xchange where pair in ("USDLTL")
&format=json
&env=store://datatables.org/alltableswithkeys
&callback=