Laravel Currency is a package that provides current and historical exchange rates for currency and cryptocurrencies. The package leverages the exchangerate.host API for exchange rate data, and has a clean API for getting data:
use AmrShawkyCurrencyFacadeCurrency; // Get the current USD -> EUR exchange rate Currency::convert() ->from('USD') ->to('EUR') ->get(); // Historical exchange rate data Currency::convert() ->from('USD') ->to('EUR') ->date('2019-08-01') ->get(); // Get all of the latest rates Currency::rates() ->latest() ->get(); // A more complete example, getting historical rates Currency::rates() ->historical('2020-01-01') ->symbols(['USD', 'EUR', 'CZK']) ->base('GBP') ->amount(5.66) ->round(2) ->source('ecb') ->get();
You can learn more about this package, get full installation instructions, and view the source code on GitHub. You can learn more about the exchangerate.host API by reading the official API documentation.