I am going to build the extension for Magento 2 and would like to retrieve currency rate by given currency code
You can use class – “currencyFactory” and “getAnyRate” method to retrieve the rate
$_objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $currencyFactory =$_objectManager->create('\Magento\Directory\Model\CurrencyFactory'); $currencyRates = $currencyFactory->create()->load("USD")->getAnyRate("JPY");