Skip to main content

ecb-fx-rates

Async Python client for ECB daily reference exchange rates.

Fetches and parses the ECB's XML feeds into typed Python objects. No caching, no storage — bring your own persistence layer.

Installation

pip install -e path/to/ecb-fx-rates

Requires Python 3.12+ and aiohttp.

Usage

import aiohttp
from ecb_fx_rates import EcbRatesClient, EcbDailyRates

async def main():
    client = EcbRatesClient()

    async with aiohttp.ClientSession() as session:
        # Today's rates
        today: EcbDailyRates = await client.fetch_daily(session)
        print(today.date)              # date(2025, 12, 31)
        print(today.get("USD"))        # Decimal("1.0842")
        print(today.get("EUR"))        # Decimal("1") — always

        # All rates for a specific year
        year_2025 = await client.fetch_year(session, 2025)
        # ~250 EcbDailyRates, one per ECB business day

        # Last 90 calendar days (~60 business days)
        recent = await client.fetch_last_90_days(session)

        # Full history since 1999 (~6MB download)
        everything = await client.fetch_history(session)

API

EcbRatesClient

Method Returns Feed used
fetch_daily(session) EcbDailyRates eurofxref-daily.xml (~5KB)
fetch_last_90_days(session) list[EcbDailyRates] eurofxref-hist-90d.xml (~50KB)
fetch_history(session) list[EcbDailyRates] eurofxref-hist.xml (~6MB)
fetch_year(session, year) list[EcbDailyRates] 90d or hist, filtered to year

EcbDailyRates

Attribute Type Description
date date ECB publication date
rates dict[str, Decimal] Currency code → EUR/X rate
Method Returns Description
get(currency) Decimal | None Rate for currency. EUR always returns Decimal("1").

Rate semantics: 1 EUR = rate units of currency. To convert foreign currency to EUR: eur = amount / rate.

Testing

pip install -e ".[dev]"
pytest tests/ -x -q

License

MIT

Metadata

Release files for ecb-fx-rates 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ecb-fx-rates 0.1.0
File Size Uploaded Provenance
ecb_fx_rates-0.1.0.tar.gz 6.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ecb-fx-rates 0.1.0
File Interpreter ABI Platform
ecb_fx_rates-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.1 kB

Release files / ecb_fx_rates-0.1.0.tar.gz

Download URL ecb_fx_rates-0.1.0.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c6321e8b32dba615094cf7a8cf48449914deb1932759e48a85a02135fca45f2b
BLAKE2b-256 checksum
How to use checksums
ea31d4ac7a642badef03ba55b52a6f2b1ccf0f031372efcd9631df6a70c7b1cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / ecb_fx_rates-0.1.0-py3-none-any.whl

Download URL ecb_fx_rates-0.1.0-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e82986a3fe9278f337ad6bf4097bca72ae32931de1b017f8935b861700fb3d0c
BLAKE2b-256 checksum
How to use checksums
29289edd8be83ff38f8c5ff7b219c00f02502860fcdba1c2035b3630cb7bb927
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Security for ecb-fx-rates 0.1.0

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page