Skip to main content

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:

  • 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

statwrapper-0.1.1.tar.gz (21.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

statwrapper-0.1.1-py3-none-any.whl (26.1 kB view details)

Uploaded Python 3

File details

Details for the file statwrapper-0.1.1.tar.gz.

File metadata

  • Download URL: statwrapper-0.1.1.tar.gz
  • Upload date:
  • Size: 21.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for statwrapper-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6d0735259b4744d9f85fe380c514d22041ef63796597fbf0d8bef90888d43e2e
MD5 a07be343734799f74629782c2e238680
BLAKE2b-256 96d32082362e7c876b14bce96587f1890b9c09e72a02f0efbf5e80c8abd3b6d7

See more details on using hashes here.

File details

Details for the file statwrapper-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: statwrapper-0.1.1-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

Hashes for statwrapper-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 af0ec77dffdaaa74c6960cfe61a4ac3756cf582ed60a35d05a9311540675b7b2
MD5 c688ed8a87bc36c143f0728afd3b0c09
BLAKE2b-256 8aef2f7bb470353b1a2d5d3f6641cdafa561246c76aad7f12ec63fe49ddf2a82

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page