Laravel Exchange Rates API Package


January 2nd, 2020


Laravel Exchange Rates is a package by Ash Allen for interacting with the API. The API provides the latest exchange rate data as well as historical rates.

Here’s a few usage examples you can expect from this package:

First, you can get available currencies:

1$exchangeRates = new ExchangeRate();

Get the exchange rate between two countries:

1$exchangeRates = new ExchangeRate();
2$exchangeRates->exchangeRate('GBP', 'EUR');

You can get an exchange rate between dates:

1$exchangeRates = new ExchangeRate();
3 'GBP',
4 'EUR',
5 Carbon::now()->subWeek(),
6 Carbon::now()

The following will convert 1GBP (£1 = 100 pence) to the euro:

1$exchangeRates = new ExchangeRate();
2$exchangeRates->convert(100, 'GBP', 'EUR', Carbon::now());

You can learn more about this package, get full installation instructions, and view the source code on GitHub at ash-jc-allen/laravel-exchange-rates.

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.

Laravel News Partners