Skip to main content

A Pythonic interface for Polish GUS Local Data Bank datasets.

Project description

pyBDL

pyBDL is a Python client for the Polish GUS Local Data Bank (Bank Danych Lokalnych, BDL). It offers two complementary interfaces:

  • BDL access layer: convenient pandas.DataFrame results for exploratory analysis.
  • BDL.api layer: low-level endpoint clients that return raw JSON-compatible dictionaries.

Installation

pip install pyBDL

Quick Start

from pybdl import BDL, BDLConfig

with BDL(BDLConfig(api_key="your-api-key")) as bdl:
    levels = bdl.levels.list_levels()
    variables = bdl.variables.search_variables(
        name="population",
        enrich=["levels", "subjects"],
    )
    data = bdl.data.get_data_by_variable(
        variable_id="3643",
        years=[2022, 2023],
        unit_level=2,
        enrich=["units", "attributes"],
    )

Configuration

BDLConfig supports direct constructor arguments and environment variables:

  • BDL_API_KEY
  • BDL_LANGUAGE
  • BDL_FORMAT
  • BDL_USE_CACHE
  • BDL_CACHE_EXPIRY
  • BDL_PROXY_URL
  • BDL_PROXY_USERNAME
  • BDL_PROXY_PASSWORD
  • BDL_PAGE_SIZE
  • BDL_REQUEST_RETRIES
  • BDL_RETRY_BACKOFF_FACTOR
  • BDL_MAX_RETRY_DELAY
  • BDL_RETRY_STATUS_CODES

Explicit constructor arguments take precedence over environment variables.

API Layers

Access Layer

Use the default BDL attributes for DataFrame output:

from pybdl import BDL

bdl = BDL()
subjects = bdl.subjects.list_subjects()
data, metadata = bdl.data.get_data_by_variable_with_metadata(
    variable_id="3643",
    max_pages=1,
)

Raw API Layer

Use bdl.api when you want direct control over the underlying payloads:

from pybdl import BDL

bdl = BDL()
payload = bdl.api.data.get_data_by_variable(
    variable_id="3643",
    max_pages=1,
)
payload_with_meta = bdl.api.data.get_data_by_variable_with_metadata(
    variable_id="3643",
    max_pages=1,
)

Highlights

  • Automatic pagination helpers for collection endpoints
  • Sync and async endpoint clients
  • Built-in rate limiting with persistent quota tracking
  • Configurable retry/backoff for transient HTTP failures
  • Reference-data enrichment via enrich=[...]
  • Context-manager support for clean session lifecycle management

Documentation

Documentation uses MkDocs Material with mkdocstrings and mike for versioned GitHub Pages (gh-pages branch). To build locally:

uv sync --group docs
make docs
# or: uv run mkdocs serve   # live reload at http://127.0.0.1:8000

The static site is written to site/ (gitignored). On GitHub Pages (gh-pages branch, / root):

  • Pushes to main update the main mike version (tip-of-tree docs).
  • A successful Release workflow run deploys {semver} and moves the latest alias to that release; the site root redirects to latest.

Key documentation pages:

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

pybdl-1.1.0.tar.gz (254.9 kB view details)

Uploaded Source

Built Distribution

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

pybdl-1.1.0-py3-none-any.whl (52.3 kB view details)

Uploaded Python 3

File details

Details for the file pybdl-1.1.0.tar.gz.

File metadata

  • Download URL: pybdl-1.1.0.tar.gz
  • Upload date:
  • Size: 254.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pybdl-1.1.0.tar.gz
Algorithm Hash digest
SHA256 160a8f53713a18c9707c4ee9e8ce0f31d8d910acfee1af8743cecb52e15a8e78
MD5 88e13ed5824f00255cb11c6c6212a2e7
BLAKE2b-256 79398dd7407e05bafde976cb324efda7cb6fdfc6f8b51787b83fb8c7be1c76b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pybdl-1.1.0.tar.gz:

Publisher: release.yml on AN0DA/pyBDL

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pybdl-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: pybdl-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 52.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pybdl-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 77c597822f51fc50a1b0e60d31d3de1d0f01ec5ba2e31dda24594a34435378fc
MD5 29fc6f9ed9e8a4ccb0e9863051a95fba
BLAKE2b-256 5f722af23dd32943fb3e05cbcdba9f49227061d1ab60fbce22df9725bd72c3b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pybdl-1.1.0-py3-none-any.whl:

Publisher: release.yml on AN0DA/pyBDL

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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