jsonrates + currencylayer  Read more

We're happy to announce that the jsonrates API has been integrated into the currencylayer API.
You can continue using our API for free by signing up here ยป

Important: This documentation has been deprecated and is no longer valid. For detailed reference about API integration, usage guides and language examples please visit: currencylayer.com/documentation

PHP code examples

The following code examples demonstrate the PHP interaction with the API.
All examples also expect your API key.


Example 1
Get the exchange rate between two currencies
$data = file_get_contents(
    'http://jsonrates.com/get/?'.
    'from=USD'.
    '&to=EUR'
);
$json = json_decode($data);
$rate = (float) $json->rate;
Example 2
Convert an amount from one into another currency
$data = file_get_contents(
    'http://jsonrates.com/convert/?'.
    'from=USD'.
    '&to=EUR'.
    '&amount=2.99'
);
$json = json_decode($data);
$amount = (float) $json->amount;
Example 3
Get historical exchange rates between two currencies for three days
$data = file_get_contents(
    'http://jsonrates.com/historical/?'.
    'from=USD'.
    '&to=EUR'.
    '&dateStart=2014-06-25'.
    '&dateEnd=2014-06-27'
);
$json = json_decode($data);

foreach ($json->rates as $date => $values) {
    $histrate = (float) $values->rate;
}