currency api for laravel
This package is auto-updated.
Last update: 2020-07-06 04:44:52 UTC
Get latest currency exchange rates for different dates.
this will require guzzle. so first make sure you have installed guzzle.
To install, edit your
composer.json and add the line mentioned below.
After installation, go to
config/app.php. Add in provider array
alias as well in alias array
configuration. Run following command
php artisan vendor:publish
Once publish is completed, open
config/currency.php. It contains two element. One is
url which is an api endpoint and another one is
baseCurrency. You can change
baseCurrency and set standard currency of your own, however
url value is not meant to be changed.
use Currency; in the top of the controller.
$exchangeRate = Currency::exchangeRate('baseCurrency', 'date', 'conversionCurrency');
baseCurrency is set to
GBP, all the conversion rates will be show in respect to
GBP as a base. Passing
date will give the exchange rate for that particular date. And passing
conversionCurrency will give the exchange Rate for that particular
conversionCurrency in respect to the specified
$exRate = Currency::exchangeRate('USD');
returns all available
exrates with respect to the
USD as a base currency for present date.
$exRate = Currency::exchangeRate('USD', '2015-10-23');
exrates for the specified date
$exRate = Currency::exchangeRate('USD', '2015-10-23', 'AUD');
1 USD to
1 AUD on specified
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
- Siddhartha Bhatta - Initial work - marleysidapple
This project is licensed under the MIT License - see the LICENSE.md file for details