PHP Classes

OpenExchangeRates: Convert currency amount with Openexchangerates API

Recommend this page to a friend!
  Info   View files Documentation   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-01-10 (4 months ago) RSS 2.0 feedNot enough user ratingsTotal: 213 All time: 8,330 This week: 206Up
Version License PHP version Categories
openexchangerates 0.7.2MIT/X Consortium ...5.3PHP 5, Web services, Finances


This class can convert currency amounts with the API.

It can send HTTP requests to the API Web server to get the exchange rates between different currencies.

The retrieved information is cached to avoid the overhead of retrieving it repeatedly.

The class can perform several operations with the retrieved information like returning the latest rates, historical data, time series, list of all currencies, convert amounts between two currencies, etc..

The class can perform all OpenExchangeRates operations available either in the paid or free plans.

Picture of Jasenko Rakovic
  Performance   Level  
Name: Jasenko Rakovic <contact>
Classes: 2 packages by
Country: Bosnia and Herzegovina Bosnia and Herzegovina
Age: 35
All time rank: 31085 in Bosnia and Herzegovina Bosnia and Herzegovina
Week rank: 75 Up2 in Bosnia and Herzegovina Bosnia and Herzegovina Up
Innovation award
Innovation award
Nominee: 1x


Open Exchange Rates PHP Wrapper

A PHP wrapper for API with extended features for non advanced options plan.


  • Return all available currencies
  • Return latest exchange rates using default base currency USD or custom currency
  • Return historical exchange rates using default base currency USD or custom currency
  • Return dates range exchange rates using default base currency USD or custom currency
  • return single rate
  • Change base currency
  • Convert between currencies
  • Cache exchange rates using Memcache, APC or File cache
  • Set currencies that will be returned in resulting exchange rates



use Dzasa\OpenExchangeRates\OpenExchangeRates;
use Dzasa\OpenExchangeRates\Cache;

$config = array(
    'api_key' => 'your_api_key', // required
    'protocol' => 'https', // optional [http|https]
    'client' => 'curl',  // optional [curl|file_get_contents]
    'base' => 'EUR' // optional

// using File cache
$cache = new Cache("file", array('cache_dir'=>'/path_to_cache_dir/'));
$exchangeRates = new OpenExchangeRates($config, $cache);

// or using APC
$cache = new Cache("apc");
$exchangeRates = new OpenExchangeRates($config, $cache);

// or using Memcache
$cache = new Cache("memcache", array('host'=>'localhost', 'port'=> 11211));
$exchangeRates = new OpenExchangeRates($config, $cache);

// or not using cache
$exchangeRates = new OpenExchangeRates($config);

// get all currencies
$currencies = $exchangeRates->getAllCurrencies();

// change base currency

// set currencies

// get latest currencies
$latestRates = $exchangeRates->getLatestRates();

// get exchange rates for 01.01.2014, input can be any valid strtotime input for past
$historicalRates = $exchangeRates->getHistorical("2014-01-01");

// get exchange rates for date range, input can be any valid strtotime() input
$timeSeries = $exchangeRates->getTimeSeries("last Friday", "today");

// convert from EUR to BAM with 3 decimals
$convert = $exchangeRates->convert("EUR", "BAM", 10, 3);

// get rate for EUR currency
$singleRate = $exchangeRates->getRate("EUR");

// get base currency
$baseCurrency = $exchangeRates->getBaseCurrency();

// get API license
$license = $exchangeRates->getLicense();

// get API Disclaimer
$disclaimer = $exchangeRates->getDisclaimer();



  • Works with PHP 5.3 or above.

Submitting bugs and feature requests

Bugs and feature request are tracked on [GitHub]




Jasenko Rakovic -


Licensed under the MIT License - see the LICENSE file for details


  Files folder image Files  
File Role Description
Files folder imagesrc (2 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file Doc. Documentation

  Files folder image Files  /  src  
File Role Description
  Plain text file Cache.php Class Class source
  Plain text file OpenExchangeRates.php Class Class source

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:8,330
This week:206Up