A completely dependency-free unified wrapper around common statistical api types
Project description
statwrapper
statwrapper is a dependency-free Python library that provides a unified interface for common statistical API families. It currently ships wrapper support for:
pxwebpxweb2dsteurostat
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.
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 statwrapper-0.1.0.tar.gz.
File metadata
- Download URL: statwrapper-0.1.0.tar.gz
- Upload date:
- Size: 20.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1618ad7bc4b9859678e1fb08466e393e2fe1d58fcb410a7835d021352e50294a
|
|
| MD5 |
f22a70c76e05a21c15490b481c9ba450
|
|
| BLAKE2b-256 |
8de7b8c6e0eb3e5b732ec1b2d3e6faa54cc2868180f747b40b2db6bbd2625099
|
File details
Details for the file statwrapper-0.1.0-py3-none-any.whl.
File metadata
- Download URL: statwrapper-0.1.0-py3-none-any.whl
- Upload date:
- Size: 26.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37b5a532b818a9d6b02f70643e09cdfca6d31375d7b72ffa806f1674e6fbf87e
|
|
| MD5 |
69cb23847413379406244626547ccce4
|
|
| BLAKE2b-256 |
160c859898d550b077845e27a40364dc5d3f24f273a3eb7e9c8f0400494e8f4f
|