
Python Client Library for Global Exchange Rates API
The Global Exchange Rates API now has an official Python client, published on PyPI: https://pypi.org/project/global-exchange-rates/.
It supports both sync and async usage and is ideal for developers who need to fetch currency exchange rates in Python, convert amounts, or integrate official central bank data in finance-related apps.
Installation
pip install global-exchange-rates
Example: Get Latest Exchange Rates
from global_exchange_rates import GlobalExchangeRates
client = GlobalExchangeRates(api_key="your_api_key")
rates = client.get_latest(
base_currency="EUR",
currencies=["USD", "GBP", "JPY"]
)
print(f"1 EUR = {rates.exchange_rates['USD']} USD")
Async usage is also supported via async with
:
import asyncio
from global_exchange_rates import GlobalExchangeRates
async def main():
async with GlobalExchangeRates(api_key="your_api_key") as client:
rates = await client._get_latest_async(base_currency="EUR", currencies=["USD"])
print(f"1 EUR = {rates.exchange_rates['USD']} USD")
asyncio.run(main())
Let us know if you use the library in a project or have feature requests—we’re always interested in improving things for Python developers.