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 for Python: structures, reference metadata and observation data, from REST, files or a local DuckDB store. Navigate Data Structure Definitions, Codelists, Dataflows and related artefacts with plain attribute access, query catalogues and observations with one path language, and read and write SDMX-ML, SDMX-JSON and SDMX-CSV.
Quick start
import sdmxlib as sl
with sl.RestRegistry(sl.Provider.BIS) as reg:
urn = sl.DataStructure.urn_for(agency="BIS", id="WS_CBPOL")
dsd = reg.get(urn, resolve=True)
for dim in dsd.dimensions:
if dim.is_enumerated:
print(f"{dim.id}: {dim.codelist.id} ({len(dim.code_ids())} 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
# or: pip install sdmxlib
sdmxlib needs Python 3.14 or later.
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 - One read, with resolution depth as a parameter:
get(urn)for a skeleton,get(urn, resolve=True)for the full reference graph,resolve=[sl.Codelist]for named types only, andpartial=Falsefor untrimmed schemes - 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 — frozen, checked as they are built — and serialise to SDMX-ML 2.1, 3.0 and 3.1 or SDMX-JSON 2.0
LocalRegistry— a DuckDB-backed persistent store with lazy codelists and hierarchies and direct SQL code maps; pass it as aRestRegistry'sstore=and everything fetched is kept for offline use- A path query language over both planes, on a
LocalRegistryor straight against REST:reg.query(sl.q.dataflow)for structures,reg.obs(flow)for rows,reg.sql(...)as the escape hatch - Uniform SKOS-aligned tree API (
roots/leaves/narrower/broader/*_transitive/depth_ofplus bulk projectionsdepths/broader_map/ancestors_map/inherit_along_broader) onCodelist,Hierarchy,CategoryScheme,MetadataStructure— and their lazy SQL variantsLazyCodelist/LazyHierarchy. A codelist is keyed by code id; the other trees by path (h["CA.ON"]), since a node id may repeat across branches - 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
For AI assistants
Two condensed reference files at the repo root are written for LLM tools (Claude Code, Cursor, Copilot, etc.):
llms.txt— the whole library in one pass: registries andget, navigation, building artefacts, the local store, trees, observation data, reading and writing SDMX, reference metadata, and the type tablellms-dsl.txt— the path query language in depth:sl.q,Query/Select, projection and aggregation, edges, windows, observation queries (ObsQuery), andreg.sql()
Every Python block in both is executed by the test suite, so they track the library's actual surface. Point your assistant at them.
Upgrading
sdmxlib is pre-stability and breaks cleanly rather than carrying two spellings
of the same idea. Upgrading
lists every breaking change since 0.48, with the old and new spelling of each —
sl.Registry is now sl.LocalRegistry, get() takes a URN and a resolution
depth, the four query DSLs are one path language, and every model class is
frozen.
Documentation
See the docs for the full cookbook, including:
- Connecting to registries and choosing a resolution depth
- Persisting artefacts in a local DuckDB store with
LocalRegistry - Querying structures and observations with the
sl.qpath language - Fetching observation data 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 # end-to-end tests, replayed from recorded cassettes
just ci # the full gate: lint, typecheck, unit, docs, integration
Issues are tracked on GitHub.
The project started on GitLab, so a bare #492 in code, comments or docs means
an issue in the GitLab tracker,
which stays readable as an archive. GitHub issues are written GH-12.
Contributing
CONTRIBUTING.md says how to propose a change, and everyone taking part follows the Code of Conduct. Report a security issue privately, as SECURITY.md describes, and never in a public issue.
Metadata
Release files for sdmxlib 0.84.0
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 |
|---|---|---|---|---|
| sdmxlib-0.84.0.tar.gz | 1.1 MB | With provenance | Details for sdmxlib-0.84.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sdmxlib-0.84.0-py3-none-any.whl | Python 3 | none | any | Details for sdmxlib-0.84.0-py3-none-any.whl |
Total release size: 2.2 MB
Release files / sdmxlib-0.84.0.tar.gz
| Download URL | sdmxlib-0.84.0.tar.gz |
|---|---|
| Size | 1.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2df9c42c8654ecc09f203fc735cb1ee9cd4033c8ee78f015cbfc4881ea5ed617
|
|
BLAKE2b-256 checksum How to use checksums |
2d524b14748285d38e34cbd3d806eb9994bdf306672b5fa48d54bd22d31ccba8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logRelease files / sdmxlib-0.84.0-py3-none-any.whl
| Download URL | sdmxlib-0.84.0-py3-none-any.whl |
|---|---|
| Size | 1.1 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7ab9b50543b8211c34cc6a219b3287b6b12cd1afbaef2a02e702078b9b313c6a
|
|
BLAKE2b-256 checksum How to use checksums |
6e112277027beb9c83cde190fa21c6fc39d4bacbab57a9b634ec3da611a0e600
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logSecurity for sdmxlib 0.84.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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for sdmxlib-0.84.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logA 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.