SDMX structural metadata library for Python
Project description
sdmxlib
Note: This library has been written extensively with AI assistance (Claude Code). Users who are not comfortable with AI-generated code should take that into account before adopting it.
SDMX structural metadata library for Python. Fetch and navigate Data Structure Definitions, Codelists, Dataflows, and related artefacts from any SDMX REST endpoint — with plain attribute access, no XML or URN chasing required.
Quick start
import sdmxlib as sl
with sl.RestRegistry(sl.Provider.BIS) as reg:
dsd = reg.get(sl.DataStructure, agency="BIS", id="WS_CBPOL").resolve()
for dim in dsd.dimensions:
if dim.is_enumerated:
cl = dim.representation()
print(f"{dim.id}: {cl.id} ({len(cl.codes)} codes)")
FREQ: CL_FREQ (7 codes)
REF_AREA: CL_BIS_IF_REF_AREA (44 codes)
INSTR_ASSET: CL_INSTR_ASSET (12 codes)
BORROWER_CTY: CL_BIS_IF_REF_AREA (44 codes)
Installation
uv add "sdmxlib @ git+https://gitlab.com/gabrielgellner/sdmxlib.git"
What it does
- Connects to any SDMX 2.1 or 3.0 REST endpoint; built-in shortcuts for ECB,
BIS, ESTAT, IMF, OECD, and the SDMX Global Registry via
sl.Provider - Three resolution modes:
browse()for catalogue scanning,fetch()for unresolved artefacts,resolve()for the full reference graph (with optional constraint-trimming viapartial=True/False) - Returns fully resolved domain objects with plain attribute access — no XML, no URN chasing
- Filter collections with lambdas or the
item()expression API - Build SDMX artefacts locally and serialise to SDMX-ML or SDMX-JSON
LocalRegistry-- a DuckDB-backed persistent store for offline access with lazy codelist loading, automatic Ref resolution, and direct SQL code maps; supports shared connections and any-language queries- Reference metadata via
MetadataStructure(MSD),Metadataflow, andMetadataSet— attach typed footnotes, methodology notes, or quality reports to any identifiable artefact. Definitions ride inStructureMessage; populated payloads ride inMetadataMessage(<mes:GenericMetadata>in SDMX-ML 3.0; metadata-schema envelope in SDMX-JSON 2.0). Both message kinds round-trip throughLocalRegistry, JSON, and XML. - Integrates with Polars for schema generation and data validation
- Fully typed — IDE completion and static analysis work throughout
Documentation
See the docs for the full cookbook, including:
- Connecting to registries and choosing a resolution mode
- Persisting artefacts in a local DuckDB store with
LocalRegistry - Fetching observation data with
sl.dim()filters and pivoting to wide format - Inspecting DSDs and building code maps for ETL pipelines
- Generating Polars schemas from SDMX Data Structure Definitions
- Browsing data catalogs and filtering dataflows
- Working with constraints, hierarchies, and serialisation
Development
just check # lint + typecheck
just test # unit tests
just test-integration # live endpoint tests (requires network)
just ci # full pre-commit gate
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sdmxlib-0.20.0.tar.gz.
File metadata
- Download URL: sdmxlib-0.20.0.tar.gz
- Upload date:
- Size: 159.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
09e2deec9db12968a9e1fb31dbd63dca8f6795112b58db91fff0f70da0cd663b
|
|
| MD5 |
22a91ed6acb74780bb035a81468ce9c1
|
|
| BLAKE2b-256 |
717d823e8f991f28b29f5797d415e781efcf14349c6d4a129fe0fc87540185e6
|
File details
Details for the file sdmxlib-0.20.0-py3-none-any.whl.
File metadata
- Download URL: sdmxlib-0.20.0-py3-none-any.whl
- Upload date:
- Size: 195.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a820d08062606a90ee7ea3f13aafa2180f31d0aeb5f4f52a589385edd6e3021a
|
|
| MD5 |
6d9c8ba07eee8e588b672673c2d84a8a
|
|
| BLAKE2b-256 |
e1ecfbe7b5120077481fa418a6660200a2bea4c5905312b421d9dd1222e8be32
|