Skip to main content

sdmxlib-rest

PyPI Python License Docs uv Ruff CI

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.

A generic SDMX-REST HTTP surface over a sdmxlib EditionRegistry.

It owns the parts of an SDMX-REST service that are the same everywhere — URL grammar, content negotiation, localisation, streaming, response assembly — and leaves everything catalog-specific to the consumer, behind explicit seams.

Documentation: https://statcat-suite.github.io/sdmxlib-rest/

from sdmxlib_rest.app import RestSettings, create_app, library_routers
from sdmxlib_rest.runtime import CatalogRuntime

runtime = CatalogRuntime(MyCatalogProvider())
app = create_app(
    runtime,
    RestSettings(title="my-sdmx-api", version="1.0.0"),
    routers=list(library_routers()),
)

That serves the structure, metadata and availability planes. The consumer writes the /data route; see Data-plane helpers below.

What you supply

Each catalog-specific behaviour is a Protocol on CatalogRuntime. A consumer must implement CatalogProvider; every other seam has an inert default.

Seam Purpose Default
CatalogProvider how the registry is opened required
SpliceRegistry post-serialise JSON transforms empty
StructureCache cache rendered structure responses never caches
AvailabilityValues precomputed availability values, for unfiltered requests always scans
MetadataStore reference-metadata lookups returns nothing
ComponentFilterShaper rewrite a parsed filter before it is queried identity
MessageAnnotator pre-serialise message annotation; with SupportsFingerprint, annotations that change at runtime re-key the structure cache and ETags. OverlayAnnotator applies sdmxlib annotation overlays no-op

A consumer that installs none of the optional seams gets a correct service that recomputes more than it needs to.

The registry has to reach its own observations. /availability reads rows through sdmxlib's query DSL (registry.obs(flow)), which runs on the registry's own connection and attaches the lake there. Open an edition with LocalRegistry.edition(path), or any opener that does the same (statcatlib's Catalog does). The DSL sees only lakes attached to the registry's own connection. This holds since 0.6.0; earlier versions ran /availability SQL on meta_conn.

What create_app gives you

Besides the routes, create_app assembles:

  • The middleware stack in a fixed order. The chain has real adjacency constraints — ?lang= has to rewrite the header before the ETag layer reads it; the version rewrite has to land before compression decides; CORS has to be outermost or preflights fall through to a 404 that browsers report as a CORS failure. Each constraint is documented at _install_middleware. Only successful responses carry an ETag and Cache-Control, so clients cache and revalidate successes only.
  • A 500 that names unwritable catalogue content. sdmxlib refuses to serialise content no format can carry (a component with no concept, say). The response lists each artefact path and the rule it breaks, on the app and every mount.
  • Runtime sharing across mounts, so a service exposing several surfaces (a canonical one plus compatibility variants) opens the registry once.
  • A multi-spec docs page, built by hand because FastAPI's helper emits a single-spec page and Swagger UI renders nothing when given both url and urls.

Data-plane helpers

The library owns data-plane helpers — key and query-parameter parsing, projection, paging headers, binding-driven SQL fragments, and the arrow→CSV/parquet encoders, all under sdmxlib_rest.data. Each consumer writes its own /data handler around them.

The handler orchestrates response caching, partition pushdown and vendor extensions, and every catalog shapes those differently: one catalog's hierarchy descent and partition pruning fit that catalog alone.

Status

Extracted from a production SDMX-REST service and versioned independently from 0.1.0. The seam set is settled; the create_app signature may still move before 1.0.

Issues are tracked on GitHub. The project started on GitLab, so a bare #7 in code, comments or docs means an issue in the GitLab tracker, which stays readable as an archive. GitHub issues are written GH-12.

Licence

Apache-2.0.

Metadata

Release files for sdmxlib-rest 0.10.2

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

Source distribution (sdist)

Source distribution for sdmxlib-rest 0.10.2
File Size Uploaded Provenance Actions
sdmxlib_rest-0.10.2.tar.gz 118.9 kB Without provenance Details for sdmxlib_rest-0.10.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sdmxlib-rest 0.10.2
File Interpreter ABI Platform Actions
sdmxlib_rest-0.10.2-py3-none-any.whl Python 3 none any Details for sdmxlib_rest-0.10.2-py3-none-any.whl

Total release size: 236.1 kB

Release files / sdmxlib_rest-0.10.2.tar.gz

Download URL sdmxlib_rest-0.10.2.tar.gz
Size 118.9 kB
Tags Source
SHA-256 checksum
How to use checksums
9212bab7112191e31b77d426f6d9c827bbd7adbdc4f1642d93cd69202cdf9aa7
BLAKE2b-256 checksum
How to use checksums
f1ed8f1704a40a8b2949335e9f7ea3d1be16ab2f04b6d8e5a7b7a9e5ef2a1774
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","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}

Release files / sdmxlib_rest-0.10.2-py3-none-any.whl

Download URL sdmxlib_rest-0.10.2-py3-none-any.whl
Size 117.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b146b8e2b536f4cb756f0d5ea80dc2dcb27ecff95d854a042b92b7443bbeae1c
BLAKE2b-256 checksum
How to use checksums
7ac811afe73f13d8e68edf32148a134dd3b9722f0acff8a9d7a9b4f16416af24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","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}

Security for sdmxlib-rest 0.10.2

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.

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