
ExchangeRate API Has a Free Tier — Convert 161 Currencies in Real-Time (No Key Needed)
Currency Data Without the Price Tag Most currency APIs charge for real-time rates. ExchangeRate-API gives you 1500 requests/month free with no API key needed for the open endpoint. No-Key Endpoint (Open Access) import requests def get_rates ( base = " USD " ): r = requests . get ( f " https://open.er-api.com/v6/latest/ { base } " ) data = r . json () return data [ " rates " ] rates = get_rates ( " USD " ) print ( f " 1 USD = { rates [ EUR ] : . 4 f } EUR " ) print ( f " 1 USD = { rates [ GBP ] : . 4 f } GBP " ) print ( f " 1 USD = { rates [ JPY ] : . 2 f } JPY " ) Currency Converter def convert ( amount , from_currency , to_currency ): rates = get_rates ( from_currency ) result = amount * rates [ to_currency ] return round ( result , 2 ) print ( f " $100 = { convert ( 100 , USD , EUR ) } EUR " ) print ( f " $100 = { convert ( 100 , USD , JPY ) } JPY " ) print ( f " 100 GBP = { convert ( 100 , GBP , USD ) } USD " ) Historical Rates (With Free Key) API_KEY = " your_free_key " # Get at ex
Continue reading on Dev.to Tutorial
Opens in a new tab


