Metadata-Version: 2.5
Name: centralbank-data
Version: 0.8.1
Summary: Unified Python SDK, CLI, local metadata catalog, and MCP server for European and UK central bank data warehouses.
Project-URL: Homepage, https://github.com/benjamin-di/centralbank-data
Project-URL: Repository, https://github.com/benjamin-di/centralbank-data
Project-URL: Documentation, https://github.com/benjamin-di/centralbank-data/blob/main/docs/DESIGN.md
Project-URL: Issues, https://github.com/benjamin-di/centralbank-data/issues
License: Apache-2.0
License-File: LICENSE
Keywords: bank-of-england,central-bank,ecb,macroeconomics,mcp,mcp-server,sdmx,time-series
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.11
Requires-Dist: defusedxml>=0.7.1
Requires-Dist: httpx>=0.28.0
Provides-Extra: dev
Requires-Dist: hypothesis>=6.120.0; extra == 'dev'
Requires-Dist: mypy>=1.14.0; extra == 'dev'
Requires-Dist: pytest>=8.3.0; extra == 'dev'
Requires-Dist: ruff>=0.9.0; extra == 'dev'
Requires-Dist: types-defusedxml>=0.7.0; extra == 'dev'
Provides-Extra: mcp
Requires-Dist: fastmcp>=4.0.0; extra == 'mcp'
Requires-Dist: pydantic>=2.10.0; extra == 'mcp'
Description-Content-Type: text/markdown

# centralbank-data

Unified **Python SDK**, **CLI**, **local metadata catalog & cache**, and **MCP server** for European and UK central bank data warehouses — starting with the **European Central Bank (ECB)**.

`centralbank-data` is built **library-first** with a **2-dependency pure-Python core** (`httpx` + `defusedxml`): downstream Python applications, risk/analytics pipelines, and notebooks can import the core package directly with zero MCP, pandas, pyarrow, or lxml overhead, while AI agents query the exact same normalized service through a compact, read-only MCP surface.

> **Status:** `v0.3.0` — All 10 roadmap providers (**ECB, Bank of England, BIS, Bundesbank, Norges Bank, Eurostat, NBB, SNB, Sveriges Riksbank, Danmarks Nationalbank**), `cbdata` CLI, and 6-tool FastMCP 4 MCP server are implemented and verified.

## Quick Start

```bash
# Core Python SDK + CLI (only httpx + defusedxml, Python >=3.11)
uv add centralbank-data

# With optional FastMCP 4 MCP server
uv add "centralbank-data[mcp]"
```

```python
from centralbank_data import CentralBankService

cb = CentralBankService()
hits = cb.search("EUR/USD")
exr = cb.get_series("ecb:EXR:D.USD.EUR.SP00.A", last_n=5)
```

```bash
cbdata search "Deposit Facility Rate"
cbdata fetch ecb:FM:D.U2.EUR.4F.KR.DFR.LEV --last-n 5 --format csv
centralbank-data-mcp --transport stdio
```

## Why this exists

European and UK central banks publish rich, free, authoritative macroeconomic and financial datasets — policy rates, yield curves, exchange rates, HICP inflation, money supply, bank lending surveys, credit aggregates, and balance sheets — but their data warehouses are fragmented across:

- **SDMX 2.1 / 3.0 REST APIs** (ECB, Deutsche Bundesbank, Norges Bank, National Bank of Belgium, BIS, Eurostat)
- **Custom REST / Cube & StatBank APIs** (Swiss National Bank, Sveriges Riksbank, Danmarks Nationalbank)
- **Legacy CSV endpoints** (Bank of England IADB)

Working directly against these warehouses has two recurring friction points:
1. **Cryptic series keys & heavy metadata**: querying ECB requires knowing keys like `FM.D.U2.EUR.4F.KR.DFR.LEV` across 215 SDMX dataflows; Bank of England IADB has no search API at all; Eurostat's dataflow catalog alone is 7.08 MB (8,167 datasets).
2. **Inconsistent wire formats & dialects**: CSV delimiters (`,` vs `;`, locale-dependent on Bundesbank), UTF-8 BOMs, missing-value tokens (`"."` on Bundesbank, blank cells on BoE), non-ISO dates (`02 Jan 2026`, `2026M11D26`), and historical revisions vary by bank.

`centralbank-data` solves both once:
- **Normalized data model**: exact-key `SeriesID` (`<provider>:<dataset>:<key>`), one `Observation` schema with full-series atomic replace caching, and canonical cross-bank indicator mappings.
- **Local SQLite FTS5 catalog & observation cache**: plain-English search (sanitized against FTS5 syntax errors) across dataflows, codelists, and curated series without dumping megabytes of SDMX XML into LLM context.
- **Multiple thin interfaces over one synchronous core**:
  - **Python SDK** (`pip install centralbank-data`) — 2 pure-Python deps (`httpx`, `defusedxml`), zero MCP/pandas/pyarrow/lxml bloat.
  - **CLI** (`cbdata`) — ad-hoc inspection, catalog sync, CSV/JSON output.
  - **MCP server** (`pip install "centralbank-data[mcp]"`) — compact, read-only 5-tool FastMCP 4 server over stdio or Streamable HTTP.

## Roadmap (10 High-Signal Providers)

| Phase | Central Banks / Hubs | Protocol Family |
|---|---|---|
| **Phase 1 (`v0.1.0`)** | **ECB** (215 dataflows on `data-api.ecb.europa.eu`) | SDMX 2.1 dialect engine (`defusedxml` + `csv`) |
| **Phase 2 (`v0.2.0`)** | **Bank of England (BoE IADB)** + **BIS**, **Bundesbank**, **Norges Bank**, **Eurostat**, **NBB** | BoE IADB CSV adapter + 5 SDMX profiles + `cb_compare_indicators` |
| **Phase 3 (`v0.3.0`)** | **SNB**, **Sveriges Riksbank** (SWEA + SWESTR), **Danmarks Nationalbank** | Non-Eurozone sovereign REST / Cube / StatBank adapters |

*(Narrow FX-only/SOAP adapters and redundant/WAF-blocked Eurozone NCBs are documented in [docs/CENTRAL_BANKS.md](docs/CENTRAL_BANKS.md) and intentionally parked — their headline FX and policy rates are already covered via ECB and BIS.)*

## Documentation

- [Architecture & Design](docs/DESIGN.md) — system layers, exact-key data model, full-replace SQLite WAL cache, SDMX dialect profiles, CLI/MCP contracts, verification bar, and prior-art record.
- [Central Bank Data Warehouses](docs/CENTRAL_BANKS.md) — live-verified technical reference of the 10 target institutions plus parked/blocked European central banks.
- [Provider Capability Matrix](docs/PROVIDERS.md) — per-provider scope, status, dialect quirks, and documented limits.
- [Permissions & Multi-User Model](docs/PERMISSIONS.md) — read-only public-data boundary and HTTP bearer contract.
- [Contributing](CONTRIBUTING.md) · [Security](SECURITY.md) · [Changelog](CHANGELOG.md)

## License

Apache-2.0 — see [LICENSE](LICENSE).
