Global Exchange Rates
A Python client library for interacting with the Global Exchange Rates API.
It provides a set of methods for retrieving exchange rates, currency and providers information, and converting amounts between currencies.
Global Exchange Rates API
The Global Exchange Rates API provides a simple and reliable way to download official exchange rates from central banks and tax authorities (providers) worldwide.
You can check the updated list from the official website.
Daily exchange rates of all the available currencies are also provided, calculated using a proprietary algorithm blending the official data from central banks and the market rate from commercial institutions.
Ideal for accounting, CRM and ERP systems, business intelligence, auditing, tax compliance and reporting.
Getting Started
- Sign up to the Developer API Portal and start the 30 day free trial.
- Get your API key.
- Install:
pip install global-exchange-rates
Usage
Synchronous API
from global_exchange_rates import GlobalExchangeRates, ApiException
# Initialize the client
client = GlobalExchangeRates(api_key="your_api_key")
try:
# Get all currencies
currencies = client.get_currencies()
print(f"Got {len(currencies)} currencies")
# Get specific currencies
eur_usd = client.get_currencies(codes=["EUR", "USD"])
print(f"EUR: {eur_usd[0].name}, USD: {eur_usd[1].name}")
# Get latest exchange rates
rates = client.get_latest(
base_currency="EUR",
currencies=["USD", "GBP", "JPY"]
)
print(f"1 EUR = {rates.exchange_rates['USD']} USD")
# Get historical exchange rates
from datetime import date
historical = client.get_historical(
date_value=date(2025, 1, 1),
base_currency="EUR",
currencies=["USD", "GBP"]
)
print(f"1 EUR = {historical.exchange_rates['USD']} USD on Jan 1, 2025")
# Convert currency
conversion = client.convert(
amount=100.0,
base_currency="EUR",
to_currencies=["USD", "GBP"]
)
print(f"€100 = ${conversion.conversions['USD']:.2f}")
# Get providers
providers = client.get_providers()
for provider in providers:
print(f"Provider: {provider.code} ({provider.description})")
except ApiException as e:
print(f"API Error: {e}")
Asynchronous API
import asyncio
from global_exchange_rates import GlobalExchangeRates, ApiException
async def main():
# Use as async context manager
async with GlobalExchangeRates(api_key="your_api_key") as client:
try:
# Get all currencies
currencies = await client._get_currencies_async()
print(f"Got {len(currencies)} currencies")
# Get latest exchange rates
rates = await client._get_latest_async(
base_currency="EUR",
currencies=["USD", "GBP", "JPY"]
)
print(f"1 EUR = {rates.exchange_rates['USD']} USD")
# Get historical exchange rates
from datetime import date
historical = await client._get_historical_async(
date_value=date(2025, 1, 1),
base_currency="EUR",
currencies=["USD", "GBP"]
)
print(f"1 EUR = {historical.exchange_rates['USD']} USD on Jan 1, 2025")
# Convert currency
conversion = await client._convert_async(
amount=100.0,
base_currency="EUR",
to_currencies=["USD"]
)
print(f"€100 = ${conversion.conversions['USD']:.2f}")
except ApiException as e:
print(f"API Error: {e}")
# Run the async function
asyncio.run(main())
Error Handling
The client raises ApiException when an API error occurs. This exception contains:
status_code: HTTP status codeerror_code: API-specific error code (if available from the API)api_message: Error message from the API (if available)
try:
currencies = client.get_currencies()
except ApiException as e:
print(f"Error message: {str(e)}")
print(f"HTTP Status: {e.status_code}")
if e.error_code:
print(f"Error Code: {e.error_code}")
if e.api_message:
print(f"API Message: {e.api_message}")
API Reference
The client provides the following methods:
Synchronous Methods
get_currencies(codes: Optional[Iterable[str]] = None) -> List[Currency]get_latest(provider: Optional[str] = None, currencies: Optional[Iterable[str]] = None, base_currency: Optional[str] = None) -> ExchangeRateResponseget_historical(date_value: Union[date, datetime, str], latest: Optional[bool] = None, provider: Optional[str] = None, currencies: Optional[Iterable[str]] = None, base_currency: Optional[str] = None) -> ExchangeRateResponseconvert(amount: float, base_currency: Optional[str] = None, to_currencies: Optional[Iterable[str]] = None, provider: Optional[str] = None, date_value: Optional[Union[date, datetime, str]] = None) -> ConversionResponseget_providers(codes: Optional[Iterable[str]] = None, country_code: Optional[str] = None) -> List[Provider]
Asynchronous Methods
_get_currencies_async(codes: Optional[Iterable[str]] = None) -> List[Currency]_get_latest_async(provider: Optional[str] = None, currencies: Optional[Iterable[str]] = None, base_currency: Optional[str] = None) -> ExchangeRateResponse_get_historical_async(date_value: Union[date, datetime, str], latest: Optional[bool] = None, provider: Optional[str] = None, currencies: Optional[Iterable[str]] = None, base_currency: Optional[str] = None) -> ExchangeRateResponse_convert_async(amount: float, base_currency: Optional[str] = None, to_currencies: Optional[Iterable[str]] = None, provider: Optional[str] = None, date_value: Optional[Union[date, datetime, str]] = None) -> ConversionResponse_get_providers_async(codes: Optional[Iterable[str]] = None, country_code: Optional[str] = None) -> List[Provider]
License
MIT License - see the LICENSE file for details.
Full Documentation
The full API documentation is available at doc.globalexchangerates.org.
Metadata
Release files for global-exchange-rates 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| global_exchange_rates-1.0.1.tar.gz | 9.4 kB | Without provenance | Details for global_exchange_rates-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| global_exchange_rates-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for global_exchange_rates-1.0.1-py3-none-any.whl |
Total release size: 18.1 kB
Release files / global_exchange_rates-1.0.1.tar.gz
| Download URL | global_exchange_rates-1.0.1.tar.gz |
|---|---|
| Size | 9.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d87ad7768010c45e2a376ed60917f90b2a65be6c167da3c0f8aa09aea9e60380
|
|
BLAKE2b-256 checksum How to use checksums |
a5b48ce76da7866cd98547d1790bfdb2211bc2111fc9785633fe0d82728dd715
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Release files / global_exchange_rates-1.0.1-py3-none-any.whl
| Download URL | global_exchange_rates-1.0.1-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7329942fe53c20c7832dc0524b538004a3c490bee2631c2bb1bebf7e10bb6c63
|
|
BLAKE2b-256 checksum How to use checksums |
b0b71decd3c9f6d1976ad446b866664ae86e9fc1a2e4a424e09ead96785a42cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Security for global-exchange-rates 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.