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

Optional visualization dependencies used in notebooks and examples:

pip install "pyBDL[viz]"

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

Full documentation is built with Sphinx. To build locally:

make docs
# or: cd docs && make html

The built HTML is written to docs/_build/html/.

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.0.0.tar.gz (279.5 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.0.0-py3-none-any.whl (51.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pybdl-1.0.0.tar.gz
Algorithm Hash digest
SHA256 62cc2178fac5a471ff901b5033bdeb792db21d71f3f8e0928e21b582eb4276c6
MD5 47d7169e8b346eba34b50c3bd0b71d7c
BLAKE2b-256 231a4c9bf9aade52632182e8bfd0f3f675d86873c784c6d85b7bfb9dce817df3

See more details on using hashes here.

Provenance

The following attestation bundles were made for pybdl-1.0.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.0.0-py3-none-any.whl.

File metadata

  • Download URL: pybdl-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 51.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.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7a67571390608302435907daa6d8e94e4e61bb0f459b3c349f3a1848252fdfe3
MD5 50d54fdf4b935edc82fd477d0e9438aa
BLAKE2b-256 1cec0d2691439261982cc3dedd8d0f2f8dcfa048e8fd8216f46d59aa4ded1f92

See more details on using hashes here.

Provenance

The following attestation bundles were made for pybdl-1.0.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