Minimal, idiomatic Python client for OpenExchangeAPI
- All endpoints supported
- API key is optional
- Returns Python dataclasses for all responses
- Precise decimal support
pip install openexchangeapi
Or copy openexchangeapi.py into your project.
from openexchangeapi import OpenExchangeApiClient, OpenExchangeApiException client = OpenExchangeApiClient('YOUR_API_KEY') # API key optional # Get latest rates latest = client.get_latest() # Convert currency result = client.convert('USD', 'EUR', 100) # List currencies currencies = client.list_currencies() # Get currency details eur = client.get_currency('EUR')
get_latest(base=None)get_latest_precise(base=None)get_historical(date, base=None)get_historical_precise(date, base=None)convert(from_, to, amount)convert_precise(from_, to, amount)list_currencies(type=None)get_currency(code)
All methods raise OpenExchangeApiException on error.
try: data = client.get_latest() except OpenExchangeApiException as e: # Handle error print(e)
MIT