Skip to main content

sdmxlib-rest

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

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.

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. Serving data is the consumer's job — see Why there is no data route below.

What you supply

Everything catalog-shaped is a Protocol on CatalogRuntime, each with a no-op default. A bare consumer implements only the first one.

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 no-op

The defaults are all inert, not broken: a consumer that installs none of them gets a correct service, just one 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 a bundle with LocalRegistry.bundle(path), or any opener that does the same (statcatlib's Catalog does). A lake attached only to some other connection is invisible to it. Since 0.6.0; before, /availability ran its own SQL on meta_conn.

What create_app gives you

Routes are the easy part. The assembly is what's worth not rewriting:

  • The middleware stack, in the one order that works. 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 are stamped with an ETag and Cache-Control, so an error is never cached or revalidated.
  • Unwritable catalogue content as a 500 that says what failed. 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, instead of a bare server error.
  • 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, which has to be hand-rolled because FastAPI's helper emits a single-spec page and Swagger UI renders nothing when given both url and urls.

Why there is no data route

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. It does not own the /data route itself.

That is deliberate. Orchestration is where response caching, partition pushdown and vendor extensions live, and every catalog shapes those differently — one catalog's hierarchy descent and partition-pruning tricks are noise to the next. A second consumer gets the hard, fiddly parts and writes its own handler around them.

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.7.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 sdmxlib-rest 0.7.0
File Size Uploaded Provenance
sdmxlib_rest-0.7.0.tar.gz 94.8 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 206.6 kB

Release files / sdmxlib_rest-0.7.0.tar.gz

Download URL sdmxlib_rest-0.7.0.tar.gz
Size 94.8 kB
Tags Source
SHA-256 checksum
How to use checksums
860a117e556a87ad1fd24631f2947fed699fae76e08e601ec590341178290794
BLAKE2b-256 checksum
How to use checksums
5284be23f6916a124ce1ba01ee947252377201daab51bc3dd8eea46fef677804
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","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.7.0-py3-none-any.whl

Download URL sdmxlib_rest-0.7.0-py3-none-any.whl
Size 111.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9451889e4272a09569ca06cdd141cda86add2cb0fe23f70d7f8211f613b44ef0
BLAKE2b-256 checksum
How to use checksums
94117d1e5e9bf927304a00309530e53871c22062a82cb8640a25966c52728a01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","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.7.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.

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