In my case, I've found very useful Fixer.io and Open Exchange Rates API's. I've tested and compared both to Yahoo, XE and Google rates and the difference is about 3 to 5 cents!
Both API's offer free 1000 requests per month with 1 hour refresh. Payed plans offer more requests and more updates per hour. Open Exchange Rates also offers HTTPS requests with free plan.
Both API's responds in JSON format so it's very easy to parse the response data.
More info here:
Open Exchange Rates
https://openexchangerates.org/
Fixer.io
https://fixer.io/
How to convert currencies using free plan?
In free plans, both API's give you access to currency rates list only. Can't use currency exchange endpoints, so to be able to convert currencies, you need to apply this formula, toCurrency * (1 / fromCurrency)
Using Open Exchange Rates and PHP:
$url = 'https://openexchangerates.org/api/latest.json?app_id=YOUR_APP_ID';
$useragent = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:37.0) Gecko/20100101 Firefox/37.0';
$rawdata = '';
if (function_exists('curl_exec')) {
$conn = curl_init($url);
curl_setopt($conn, CURLOPT_USERAGENT, $useragent);
curl_setopt($conn, CURLOPT_FRESH_CONNECT, true);
curl_setopt($conn, CURLOPT_RETURNTRANSFER, true);
$rawdata = curl_exec($conn);
curl_close($conn);
} else {
$options = array('http' => array('user_agent' => $useragent));
$context = stream_context_create($options);
if (function_exists('file_get_contents')) {
$rawdata = file_get_contents($url, false, $context);
} else if (function_exists('fopen') && function_exists('stream_get_contents')) {
$handle = fopen($url, "r", false, $context);
if ($handle) {
$rawdata = stream_get_contents($handle);
fclose($handle);
}
}
}
if ($rawdata) {
$rawdata = json_decode($rawdata);
$convertedCurrency = false;
$convertedCurrency = $rawdata->rates->$currB * (1 / $rawdata->rates->$currA);
}