Skip to main content

statwrapper

statwrapper is a dependency-free Python library that provides a unified interface for common statistical API families. It currently ships wrapper support for:

  • pxweb
  • pxweb2
  • dst
  • eurostat

The package standardizes three operations across providers:

  • health checks
  • dataset discovery
  • dataset metadata resolution

Installation

pip install statwrapper

Quick Start

import asyncio

from statwrapper import StatWrapper


async def main() -> None:
    wrapper = StatWrapper()

    discovered = await wrapper.discover_datasets("scb", "en")
    first = discovered[0]

    metadata = await wrapper.resolve_dataset_metadata(first)
    print(metadata.label)
    print(metadata.dimension_ids)


asyncio.run(main())

Public API

StatWrapper

from statwrapper import StatWrapper

wrapper = StatWrapper()

Methods:

  • await wrapper.discover_datasets(provider_code, language, task_id=None)
  • await wrapper.resolve_dataset_metadata(discovered, task_id=None)
  • wrapper.get_provider(provider_code)
  • wrapper.get_wrapper(provider_code, language)

Convenience Functions

from statwrapper import discover_provider_datasets, get_datasets
  • await discover_provider_datasets(provider_code, language)
  • get_datasets(provider_code, language)

Request Layer

The default request layer is a stdlib-backed async helper:

from statwrapper import RateLimitedSession

StatWrapper uses RateLimitedSession automatically, but you can inject your own session object if it exposes:

  • async def get_json(url, **kwargs)
  • async def get_text(url, **kwargs)
  • async def get_bytes(url, **kwargs)

Provider Registry

Provider metadata is loaded from PROVIDERS.json. During development, the package reads the repository file. In built distributions, the same data is bundled inside the package.

Development

Run tests:

python -m pytest tests/unit tests/integration -q

Build locally:

python -m build

Publishing

PyPI publishing is handled by GitHub Actions through .github/workflows/pypi_publish.yml and the repository secret PYPI_API_TOKEN.

Metadata

Release files for statwrapper 0.1.1

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

Source distribution (sdist)

Source distribution for statwrapper 0.1.1
File Size Uploaded Provenance
statwrapper-0.1.1.tar.gz 21.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for statwrapper 0.1.1
File Interpreter ABI Platform
statwrapper-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 47.1 kB

Release files / statwrapper-0.1.1.tar.gz

Download URL statwrapper-0.1.1.tar.gz
Size 21.0 kB
Tags Source
SHA-256 checksum
How to use checksums
6d0735259b4744d9f85fe380c514d22041ef63796597fbf0d8bef90888d43e2e
BLAKE2b-256 checksum
How to use checksums
96d32082362e7c876b14bce96587f1890b9c09e72a02f0efbf5e80c8abd3b6d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / statwrapper-0.1.1-py3-none-any.whl

Download URL statwrapper-0.1.1-py3-none-any.whl
Size 26.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
af0ec77dffdaaa74c6960cfe61a4ac3756cf582ed60a35d05a9311540675b7b2
BLAKE2b-256 checksum
How to use checksums
8aef2f7bb470353b1a2d5d3f6641cdafa561246c76aad7f12ec63fe49ddf2a82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Security for statwrapper 0.1.1

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

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