I am looking to find a API that I can use in JavaScript or Python to be able to eXchange the currency rates. I need the example of using those APIs too. Do you Guys have any Idea how to find it ? JavaScript or Python portfolio and positions example ?
-
2similar to http://stackoverflow.com/questions/3139879/how-do-i-get-currency-exchange-rates-using-google-finance-api ?? – unloco Nov 22 '11 at 21:53
-
No It is not. the should be a way to get currency from google api as stocks. that q is just suggest to use somewhere else ..!!! – Emax Nov 23 '11 at 20:51
3 Answers
Just try CurrencyFreaks API. It provides the latest currency exchange for 179 currencies worldwide in JSON/XML formats compatible with various programming languages including Javascript and PHP.
Currency conversion by using Javascript:
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://api.currencyfreaks.com/latest/convert
?apikey=YOUR_APIKEY
&from=USD&to=EUR
&amount=500");
xhr.send();
The JSON response will be:
{
"date": "2020-10-16 15:08:00+00",
"current_rates": {
"USD": "1.0",
"EUR": "0.8533"
},
"converted_amount": "426.6215",
"query": {
"given_amount": "500.0",
"from": "USD",
"to": "EUR"
}
}
Currency conversion by using PHP:
setUrl('https://api.currencyfreaks.com/latest/convert
?apikey=YOUR_APIKEY
&from=USD&to=EUR
&amount=500');
$request->setMethod(HTTP_Request2::METHOD_GET);
$request->setConfig(array(
'follow_redirects' => TRUE
));
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
The JSON response will be the same.
I hope it will work for you.

- 407
- 3
- 11
To retrieve the current exchange rate, you can use the Yahoo finance API (http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s=USDINR=X
).
For retrieving the exchange rate of a currency relative to USD for a particular historical date, you can use the Yahoo currency-converter-cache API (http://finance.yahoo.com/connection/currency-converter-cache?date=<YYYYMMDD>
).
I made this simple currency converter module that uses Yahoo Finance API and supports historical date. https://github.com/iqbalhusen/currency_converter.

- 2,094
- 1
- 20
- 28
-
@DJClayworth Thanks. I have edited my answer to include the essential parts. – Iqbal Apr 30 '15 at 14:13
The link of finance.yahoo.com is not working !
One can use : http://free.currencyconverterapi.com/api/v5/convert?q=EUR_USD&compact=y

- 1,402
- 14
- 16