Laravel Exchange Rates API Package

Packages

January 2nd, 2020

laravel-exchange-rate.png

Laravel Exchange Rates is a package by Ash Allen for interacting with the exchangeratesapi.io 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();
2$exchangeRates->currencies();

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();
2$exchangeRates->exchangeRateBetweenDateRange(
3 'GBP',
4 'EUR',
5 Carbon::now()->subWeek(),
6 Carbon::now()
7);

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.