PHP Classes

PHP Exchange Rates: Get currency exchange rates from ExchangeRates API

Recommend this page to a friend!
  Info   View files Example   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 82 This week: 1All time: 10,054 This week: 560Up
Version License PHP version Categories
exchangerates 1.0.0GNU General Publi...5.6PHP 5, Web services, Finances
Description 

Author

This class can get currency exchange rates from ExchangeRates API.

It can send HTTP requests to the ExchangeRates API Web server to perform several types of operations to obtain information related to the exchange rates between different currencies. Currently, it can:

- Get the symbols of the currencies for which there is exchange rate information
- Latest values of exchange rates between currencies
- Convert amounts between currencies
- Get a time series, or the fluctuation, or the historical values of the exchange rates over time

Innovation Award
PHP Programming Innovation award nominee
August 2021
Number 5
Exchange rates are important for businesses that need to deal using multiple currencies.

For investors that use foreign currencies to keep their reserves, it is important to evaluate the stability of a currency over time before they decide to use it.

This package can retrieve the exchange rates for currencies over time and the information of how the exchange rates fluctuated. This way, investors can evaluate the currency stability.

Manuel Lemos
Picture of Dave Smith
  Performance   Level  
Name: Dave Smith is available for providing paid consulting. Contact Dave Smith .
Classes: 51 packages by
Country: United States United States
Age: 58
All time rank: 618 in United States United States
Week rank: 21 Up4 in United States United States Up
Innovation award
Innovation award
Nominee: 32x

Winner: 7x

Example

<?php
/*
example usage
exchangeRates ver 1.0

You must get an API key from https://exchangeratesapi.io/pricing/
and enter it in the exchangerates.class.php file

For complete documentation on each endpoint and available paramaters
see https://exchangeratesapi.io/documentation/
*/

//turning off low level notices
error_reporting(E_ALL ^ E_NOTICE);

//instantiate the class
require('exchangerates.class.php');
$exchange = new exchangeRates();

//get exhange rate for USD to GBP,JPY,EUR
$exchange->setEndPoint('latest');
$exchange->setParam( 'base', 'USD' );
$exchange->setParam( 'symbols', 'GBP,JPY,EUR' );

//get response from API
$exchange->getResponse();

//dump response object
echo '<strong>Current Rates</strong>';
echo
'<pre>';
var_dump($exchange->response);
echo
'</pre>';

//get historical rates from Dec 24 2013
$exchange->setEndPoint('historical', '2013-12-24');

//get response from API
$exchange->getResponse();

//dump response object
echo '<strong>Historical Rates</strong>';
echo
'<pre>';
var_dump($exchange->response);
echo
'</pre>';

die;
?>


  Files folder image Files  
File Role Description
Accessible without login Plain text file example.php Example Example Usage
Plain text file exchangerates.class.php Class Main Class
Accessible without login Plain text file license.txt Lic. License

 Version Control Unique User Downloads Download Rankings  
 0%
Total:82
This week:1
All time:10,054
This week:560Up