This package provides the most famous currency rates providers' implementations. The package was originally built on Yahoo API, but there was a discontinuation of it. It is therefore highly recommended that you make use of only active providers, such as the ones listed below.
Once the extension is installed, simply use it in your code by :
'components' => [
'currencyConverter' => [
'class' => 'imanilchaudhari\CurrencyConverter\CurrencyConverter',
'provider' => [
'class' => 'imanilchaudhari\CurrencyConverter\Provider\ExchangeRatesApi',
],
],
...
],
$converter = Yii::$app->currencyConverter;
$rate = $converter->convert('USD', 'NPR');
OR
use imanilchaudhari\CurrencyConverter\CurrencyConverter;
use imanilchaudhari\CurrencyConverter\Provider\OpenExchangeRatesApi;
$converter = new CurrencyConverter([
'provider' => [
'class' => OpenExchangeRatesApi::class,
'appId' => Yii::$app->params['openExchangeRate']['appId'],
],
]);
$rate = $converter->convert('USD', 'NPR');
print_r($rate); // it will print current Nepalese currency (NPR) rate according to USD
- ApiForex API - Get exchange rates from https://api.forex/
- Currency API - Get exchange rates from https://currencyapi.com/
- CurrencyFreaks API - Get exchange rates from https://currencyfreaks.com/
- Currency Layer API - Get exchange rates from https://currencylayer.com/
- Exchange Rates API - Get exchange rates from https://www.exchangerate-api.com/
- Fixer API - Get exchange rates from https://fixer.io/
- Open Exchange Rates API - Get exchange rates from https://openexchangerates.org/