Skip to content

Standardized wrapper for popular currency rate APIs such as FixerIO, CurrencyLayer, Open Exchange Rates etc.

License

Notifications You must be signed in to change notification settings

Rackbeat/php-currency-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API Wrapper for popular currency rate APIs

Dont worry about your favorite service suddenly shutting down or switching plans on you. Switch away easily.

Build Status Coverage Total Downloads Latest Stable Version License

Supported APIs

Installation

You just require using composer and you're good to go!

composer require rackbeat/php-currency-api

If you're using Laravel, a service provider and facade is included to provide configuration of driver etc.

Usage

Initialize instance

$api = Rackbeat\Currency\API::make('fixerio'); // driver from supported drivers.

Set base currency (default = USD)

$api->setBase(Rackbeat\Currency\Symbol::USD);

Set symbols to return (default = all/[])

$api->setSymbols([ Rackbeat\Currency\Symbol::DKK, Rackbeat\Currency\Symbol::EUR, Rackbeat\Currency\Symbol::USD ]);

Please note, you are not required to use Rackbeat\Currency\Symbol to specify symbols. It's simply a convenience helper.

Get latest rates

$api->get(); // Get latest rates for selected symbols, using set base currency
$api->get('DKK');  // Get latest rates for selected symbols, using DKK as base currency

Convert amount from one currency to another

$api->convert($fromCurrency = 'DKK', $toCurrency = 'EUR', 10.00); // Convert 10 DKK to EUR

Get rate on specific date

$api->historical($date = '2018-01-01'); // Get currency rate for base on 1st of January 2018
$api->historical($date = '2018-01-01', 'GBP'); // Get currency rate for GBP on 1st of January 2018

Laravel

... todo

Requirements

  • PHP >= 7.1
  • Possibly a paid plan for your desired API. Check their pricing.

About

Standardized wrapper for popular currency rate APIs such as FixerIO, CurrencyLayer, Open Exchange Rates etc.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages