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:
1use AmrShawky\Currency\Facade\Currency; 2 3// Get the current USD -> EUR exchange rate 4Currency::convert() 5 ->from('USD') 6 ->to('EUR') 7 ->get(); 8 9// Historical exchange rate data10Currency::convert()11 ->from('USD')12 ->to('EUR')13 ->date('2019-08-01')14 ->get();15 16// Get all of the latest rates17Currency::rates()18 ->latest()19 ->get();20 21// A more complete example, getting historical rates22Currency::rates()23 ->historical('2020-01-01')24 ->symbols(['USD', 'EUR', 'CZK'])25 ->base('GBP')26 ->amount(5.66)27 ->round(2)28 ->source('ecb')29 ->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.
0 comments:
Post a Comment
Thanks