Access Layer¶
The access layer is the primary user-facing interface of pyBDL. It provides a clean, pandas DataFrame-based API that automatically handles data conversion and normalization.
Overview¶
The access layer sits on top of the raw API clients and provides:
- Automatic DataFrame conversion: All responses are converted to pandas DataFrames
- Column name normalization: camelCase API fields are converted to snake_case
- Data type inference: Proper types (integers, floats, booleans) are automatically detected
- Nested data normalization: Complex nested structures are flattened into tabular format
The main client provides two interfaces:
- Access layer (default): Returns pandas DataFrames - use
bdl.levels,bdl.data, etc. - API layer: Returns raw dictionaries - use
bdl.api.levels,bdl.api.data, etc.
For most users, the access layer is recommended as it provides a more Pythonic and data-analysis-friendly interface.
Quick Start¶
from pybdl import BDL, BDLConfig
# Initialize client
bdl = BDL(BDLConfig(api_key="your-api-key"))
# Access layer returns DataFrames
levels_df = bdl.levels.list_levels()
print(levels_df.head())
# Data is ready for analysis
print(levels_df.dtypes)
print(levels_df.columns)
Key Features¶
DataFrame Conversion¶
All access layer methods return pandas DataFrames, making data immediately ready for analysis:
# Get variables as DataFrame
variables_df = bdl.variables.list_variables()
# Use pandas operations directly
filtered = variables_df[variables_df['name'].str.contains('population', case=False)]
sorted_vars = variables_df.sort_values('name')
Column Name Normalization¶
API responses use camelCase (e.g., variableId, unitName), but the
access layer converts these to snake_case (e.g., variable_id,
unit_name) for Pythonic access:
df = bdl.variables.get_variable("3643")
# Columns are: variable_id, name, description (not variableId, Name, Description)
print(df.columns)
Data Type Inference¶
The access layer automatically infers and converts data types:
df = bdl.data.get_data_by_variable("3643", years=[2021])
# year column is Int64, val column is float
print(df.dtypes)
Nested Data Normalization¶
The data endpoints return nested structures. The access layer automatically flattens them:
# API returns: [{"id": "1", "name": "Warsaw",
# "values": [{"year": 2021, "val": 1000}, ...]}]
# Access layer returns flat DataFrame:
df = bdl.data.get_data_by_variable("3643", years=[2021])
# Columns: unit_id, unit_name, year, val, attr_id
print(df.head())
Available Endpoints¶
The access layer provides endpoints for all BDL API resources:
| Endpoint | Access Method | Description |
|---|---|---|
| Aggregates | bdl.aggregates |
Aggregation level metadata |
| Attributes | bdl.attributes |
Attribute metadata |
| Data | bdl.data |
Statistical data access |
| Levels | bdl.levels |
Administrative unit levels |
| Measures | bdl.measures |
Measure unit metadata |
| Subjects | bdl.subjects |
Subject hierarchy |
| Units | bdl.units |
Administrative units |
| Variables | bdl.variables |
Variable metadata |
| Years | bdl.years |
Available years |
Available Access Endpoints
Endpoint Details¶
Levels¶
Administrative unit aggregation levels (country, voivodeship, county, municipality):
# List all levels
levels_df = bdl.levels.list_levels()
# Get specific level
level_df = bdl.levels.get_level(1) # Level 1 = country
# Get metadata
metadata_df = bdl.levels.get_levels_metadata()
Subjects¶
Subject categories and hierarchy:
# List all top-level subjects
subjects_df = bdl.subjects.list_subjects()
# Get subjects under a parent
child_subjects = bdl.subjects.list_subjects(parent_id="P0001")
# Search subjects
results = bdl.subjects.search_subjects(name="population")
# Get specific subject
subject_df = bdl.subjects.get_subject("P0001")
Variables¶
Statistical variables (indicators):
# List all variables
variables_df = bdl.variables.list_variables()
# Filter variables
filtered = bdl.variables.list_variables(
category_id="P0001",
name="population"
)
# Search variables
results = bdl.variables.search_variables(name="unemployment")
# Get specific variable
variable_df = bdl.variables.get_variable("3643")
Data¶
Statistical data retrieval:
# Get data by variable (most common)
df = bdl.data.get_data_by_variable(
variable_id="3643",
years=[2021],
unit_level=2 # Voivodeship level
)
# Get data for multiple years
df = bdl.data.get_data_by_variable(
variable_id="3643",
years=[2020, 2021, 2022],
unit_level=2
)
# Get data with aggregate filter
df = bdl.data.get_data_by_variable(
variable_id="3643",
years=[2021],
aggregate_id=1
)
# Get data by administrative unit
df = bdl.data.get_data_by_unit(
unit_id="020000000000",
variable_ids=["3643"],
years=[2021]
)
# Get data for a locality
df = bdl.data.get_data_by_variable_locality(
variable_id="3643",
unit_parent_id="1465011",
years=[2021]
)
# Get data by unit locality
df = bdl.data.get_data_by_unit_locality(
unit_id="1465011",
variable_id="3643",
years=[2021]
)
The data endpoints automatically normalize nested values arrays into
flat rows.
Accessing Pagination Metadata¶
Use return_metadata=True to receive a (DataFrame, metadata) tuple
alongside the data. The metadata dictionary contains information from
the first response page, including pagination details such as
totalPages and totalRecords.
# Returns (DataFrame, metadata_dict)
df, meta = bdl.data.get_data_by_variable(
variable_id="3643",
years=[2021],
return_metadata=True,
)
print(meta.get("totalPages"))
print(meta.get("totalRecords"))
Convenience *_with_metadata wrappers always return a tuple:
df, meta = bdl.data.get_data_by_variable_with_metadata(variable_id="3643", years=[2021])
df, meta = bdl.data.get_data_by_unit_with_metadata(unit_id="020000000000", variable_ids=["3643"])
df, meta = bdl.data.get_data_by_variable_locality_with_metadata(
variable_id="3643", unit_parent_id="1465011", years=[2021]
)
df, meta = bdl.data.get_data_by_unit_locality_with_metadata(
unit_id="1465011", variable_ids=["3643"]
)
Units¶
Administrative units (regions, cities, etc.):
# List units by level
voivodeships = bdl.units.list_units(level=2) # Level 2 = voivodeship
# Search units
warsaw = bdl.units.search_units(name="Warsaw")
# Get specific unit
unit_df = bdl.units.get_unit("020000000000")
# List localities (statistical localities)
localities = bdl.units.list_localities(level=6) # Level 6 = municipality
# Search localities
warsaw_localities = bdl.units.search_localities(name="Warsaw", level=6)
# Get specific locality
locality_df = bdl.units.get_locality("1465011")
Attributes¶
Data attributes (dimensions):
# List all attributes
attributes_df = bdl.attributes.list_attributes()
# Get specific attribute
attr_df = bdl.attributes.get_attribute("1")
Measures¶
Measure units:
# List all measures
measures_df = bdl.measures.list_measures()
# Get specific measure
measure_df = bdl.measures.get_measure(1)
Aggregates¶
Aggregation types:
# List all aggregates
aggregates_df = bdl.aggregates.list_aggregates()
# Get specific aggregate
aggregate_df = bdl.aggregates.get_aggregate("1")
Years¶
Available years for data:
# List all available years
years_df = bdl.years.list_years()
# Get specific year metadata
year_df = bdl.years.get_year(2021)
Enrichment¶
Many access layer methods accept an enrich parameter (or individual
enrich_* flags) to automatically join human-readable reference data
into the returned DataFrame. Enrichment fetches the required lookup
table once per client session, caches it in memory, and left-joins the
resolved columns onto each result row.
Usage¶
Pass a list of dimension names to enrich:
# Enrich variables with level names, measure descriptions, and subject names
variables = bdl.variables.list_variables(enrich=["levels", "measures", "subjects"])
# Enrich data with unit details, attribute labels, and aggregate descriptions
data = bdl.data.get_data_by_variable(
variable_id="3643",
years=[2021],
enrich=["units", "attributes", "aggregates"],
)
Individual enrich_* boolean flags are also accepted (legacy style):
Supported Enrichment Dimensions¶
The available enrichment dimensions depend on the endpoint:
| Endpoint | enrich values |
Added columns |
|---|---|---|
Variables (bdl.variables.*) |
"levels", "measures", "subjects" |
level_name; measure_unit_description; subject_name |
Data (bdl.data.*) |
"units", "attributes", "aggregates" |
unit_name_enriched, unit_level, unit_parent_id, unit_kind; attr_name, attr_symbol, attr_description; aggregate_name, aggregate_description, aggregate_level |
Units (bdl.units.*) |
"levels" |
level_name |
Aggregates (bdl.aggregates.*) |
"levels" |
level_name |
Caching¶
Lookup tables are fetched once per access-layer instance and cached for the lifetime of the client session. Subsequent calls using the same enrichment dimension reuse the cached data without additional API requests.
bdl = BDL()
# First call: fetches the levels lookup table from the API
v1 = bdl.variables.list_variables(enrich=["levels"])
# Second call: reuses the cached levels table — no extra request
v2 = bdl.variables.get_variable("3643", enrich=["levels"])
Pagination¶
Most list methods support pagination:
# Fetch all pages (default, max_pages=None)
all_data = bdl.variables.list_variables()
# Fetch only first page
first_page = bdl.variables.list_variables(max_pages=1, page_size=50)
# Limit number of pages
limited = bdl.variables.list_variables(max_pages=5, page_size=100)
Parameters:
max_pages: Maximum number of pages to fetch.None(default) fetches all pages,1fetches only the first page,Nfetches up to N pages.page_size: Number of results per page (default: 100 from config or 100).show_progress: Display atqdmprogress bar while fetching pages (default:True). Set toFalseto suppress output in scripts or automated pipelines.
# Suppress progress bar
data = bdl.data.get_data_by_variable("3643", years=[2021], show_progress=False)
Async Usage¶
All access layer methods have async versions (prefixed with a):
import asyncio
from pybdl import BDL
async def main():
bdl = BDL()
# Async methods return DataFrames
levels_df = await bdl.levels.alist_levels()
variables_df = await bdl.variables.alist_variables()
# Can run multiple requests concurrently
levels_task = bdl.levels.alist_levels()
variables_task = bdl.variables.alist_variables()
levels_df, variables_df = await asyncio.gather(levels_task, variables_task)
return levels_df, variables_df
asyncio.run(main())
Available async methods:
alist_levels(),alist_variables(),alist_subjects(), etc.aget_level(),aget_variable(),aget_subject(), etc.aget_data_by_variable(),aget_data_by_unit(), etc.
Examples¶
Basic Usage¶
from pybdl import BDL, BDLConfig
bdl = BDL(BDLConfig(api_key="your-api-key"))
# Get administrative levels
levels = bdl.levels.list_levels()
print(f"Found {len(levels)} administrative levels")
# Get variables related to population
population_vars = bdl.variables.search_variables(name="population")
print(f"Found {len(population_vars)} population-related variables")
# Get data for a specific variable
data = bdl.data.get_data_by_variable(
variable_id="3643",
years=[2021],
unit_level=2 # Voivodeship level
)
print(data.head())
Filtering and Analysis¶
# Get all variables
variables = bdl.variables.list_variables()
# Filter using pandas
economic_vars = variables[variables['name'].str.contains('economic', case=False)]
# Get data for multiple variables
for var_id in economic_vars['id'].head(5):
data = bdl.data.get_data_by_variable(var_id, years=[2021])
print(f"Variable {var_id}: {len(data)} records")
Getting Data¶
# Get data
df = bdl.data.get_data_by_variable("3643", years=[2021])
# DataFrame includes IDs and values
print(df[['unit_name', 'attr_name', 'val']].head())
# Group by attribute name
by_attr = df.groupby('attr_name')['val'].mean()
print(by_attr)
Working with Nested Data¶
The data endpoints automatically normalize nested structures:
# API returns nested structure, but access layer flattens it
df = bdl.data.get_data_by_variable("3643", years=[2021])
# Each row represents one data point
# Columns: unit_id, unit_name, year, val, attr_id, attr_name
print(df.head())
# Easy to analyze
avg_by_unit = df.groupby('unit_name')['val'].mean()
print(avg_by_unit)
# Get data for multiple years
multi_year_df = bdl.data.get_data_by_variable("3643", years=[2020, 2021, 2022])
# Analyze trends over time
yearly_avg = multi_year_df.groupby('year')['val'].mean()
print(yearly_avg)
See examples for more comprehensive real-world examples.
API Reference¶
Module pybdl.access.base¶
base ¶
Base access class for converting API responses to DataFrames.
BaseAccess ¶
Base class for access layer implementations.
Supports per-function column renaming through the _column_renames class attribute.
Child classes can define column rename mappings that apply to both sync and async methods.
Example::
class MyAccess(BaseAccess):
_column_renames = {
"list_items": {
"id": "item_id",
"name": "item_name",
},
"get_item": {
"id": "item_id",
},
}
Initialize base access class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_client
|
Any
|
API client instance (e.g., LevelsAPI, AttributesAPI). |
required |
Source code in pybdl/access/base.py
Module pybdl.access.enrichment¶
enrichment ¶
Reusable enrichment decorator for access layer DataFrames.
AsyncEnrichmentLoader
module-attribute
¶
LEVELS_SPEC
module-attribute
¶
LEVELS_SPEC = EnrichmentSpec(
flag="enrich_levels",
id_column="level",
cache_key="levels",
sync_loader=_fetch_levels_sync,
async_loader=_fetch_levels_async,
rename_map={"name": "level_name"},
)
MEASURES_SPEC
module-attribute
¶
MEASURES_SPEC = EnrichmentSpec(
flag="enrich_measures",
id_column="measure_unit_id",
cache_key="measures",
sync_loader=_fetch_measures_sync,
async_loader=_fetch_measures_async,
rename_map={"description": "measure_unit_description"},
)
ATTRIBUTES_SPEC
module-attribute
¶
ATTRIBUTES_SPEC = EnrichmentSpec(
flag="enrich_attributes",
id_column="attr_id",
cache_key="attributes",
sync_loader=_fetch_attributes_sync,
async_loader=_fetch_attributes_async,
rename_map={
"name": "attr_name",
"symbol": "attr_symbol",
"description": "attr_description",
},
)
UNITS_SPEC
module-attribute
¶
UNITS_SPEC = EnrichmentSpec(
flag="enrich_units",
id_column="unit_id",
cache_key="units",
sync_loader=_fetch_units_sync,
async_loader=_fetch_units_async,
rename_map={
"name": "unit_name_enriched",
"level": "unit_level",
"parent_id": "unit_parent_id",
"kind": "unit_kind",
"has_description": "unit_has_description",
},
lookup_id_column="id",
)
AGGREGATES_SPEC
module-attribute
¶
AGGREGATES_SPEC = EnrichmentSpec(
flag="enrich_aggregates",
id_column="aggregate_id",
cache_key="aggregates",
sync_loader=_fetch_aggregates_sync,
async_loader=_fetch_aggregates_async,
rename_map={
"name": "aggregate_name",
"description": "aggregate_description",
"level": "aggregate_level",
},
)
SUBJECTS_SPEC
module-attribute
¶
SUBJECTS_SPEC = EnrichmentSpec(
flag="enrich_subjects",
id_column="subject_id",
cache_key="subjects",
sync_loader=_fetch_subjects_sync,
async_loader=_fetch_subjects_async,
rename_map={"name": "subject_name"},
lookup_id_column="id",
)
EnrichmentSpec
dataclass
¶
EnrichmentSpec(
flag,
id_column,
cache_key,
sync_loader,
async_loader,
rename_map=dict(),
lookup_id_column="id",
)
Configuration for a single enrichment dimension.
with_enrichment ¶
Decorator to enrich DataFrame results with reference metadata.
Adds boolean flags (e.g., enrich_levels) to the wrapped function's kwargs, fetches lookup tables once per access instance, and left-joins enriched columns.
Source code in pybdl/access/enrichment.py
Module pybdl.access.data¶
data ¶
Access layer for data API endpoints with nested data normalization.
DataAccess ¶
Bases: BaseAccess
Access layer for data API, converting responses to DataFrames with nested data normalization.
Initialize base access class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_client
|
Any
|
API client instance (e.g., LevelsAPI, AttributesAPI). |
required |
Source code in pybdl/access/base.py
get_data_by_variable ¶
get_data_by_variable(
variable_id,
years=None,
unit_parent_id=None,
unit_level=None,
aggregate_id=None,
page_size=None,
max_pages=None,
return_metadata=False,
**kwargs,
)
Retrieve statistical data for a specific variable as a DataFrame.
The nested 'values' array is normalized into separate rows, with each row containing: unit_id, unit_name, year, val, attr_id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable_id
|
str
|
Identifier of the variable. |
required |
years
|
list[int] | None
|
Optional list of years to filter by. |
None
|
unit_parent_id
|
str | None
|
Optional parent administrative unit ID. |
None
|
unit_level
|
int | None
|
Optional administrative unit aggregation level. |
None
|
aggregate_id
|
int | None
|
Optional aggregate ID. |
None
|
page_size
|
int | None
|
Number of results per page (defaults to config.page_size or 100). |
None
|
max_pages
|
int | None
|
Maximum number of pages to fetch (None for all pages). |
None
|
return_metadata
|
bool
|
If True, return tuple (DataFrame, metadata). |
False
|
**kwargs
|
Any
|
Additional parameters passed to API layer, including |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame | tuple[DataFrame, dict[str, Any]]
|
DataFrame with normalized data, or tuple (DataFrame, metadata) if return_metadata is True. |
Source code in pybdl/access/data.py
get_data_by_variable_with_metadata ¶
Retrieve data by variable and always return (dataframe, metadata).
Source code in pybdl/access/data.py
get_data_by_unit ¶
get_data_by_unit(
unit_id,
variable_ids=None,
years=None,
aggregate_id=None,
return_metadata=False,
**kwargs,
)
Retrieve statistical data for a specific administrative unit as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit_id
|
str
|
Identifier of the administrative unit. |
required |
variable_ids
|
Sequence[str | int] | str | int | None
|
Variable ID or sequence of variable IDs. |
None
|
years
|
list[int] | None
|
Optional list of years to filter by. |
None
|
aggregate_id
|
int | None
|
Optional aggregate ID. |
None
|
return_metadata
|
bool
|
If True, return tuple (DataFrame, metadata). |
False
|
**kwargs
|
Any
|
Additional parameters passed to API layer, including |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame | tuple[DataFrame, dict[str, Any]]
|
DataFrame with data, or tuple (DataFrame, metadata) if return_metadata=True. |
Source code in pybdl/access/data.py
get_data_by_unit_with_metadata ¶
Retrieve data by unit and always return (dataframe, metadata).
Source code in pybdl/access/data.py
get_data_by_variable_locality ¶
get_data_by_variable_locality(
variable_id,
unit_parent_id,
years=None,
page_size=None,
max_pages=None,
return_metadata=False,
**kwargs,
)
Retrieve data for a variable within a specific locality as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable_id
|
str
|
Identifier of the variable. |
required |
unit_parent_id
|
str
|
Parent unit ID (required). |
required |
years
|
list[int] | None
|
Optional list of years to filter by. |
None
|
page_size
|
int | None
|
Number of results per page (defaults to config.page_size or 100). |
None
|
max_pages
|
int | None
|
Maximum number of pages to fetch (None for all pages). |
None
|
return_metadata
|
bool
|
If True, return tuple (DataFrame, metadata). |
False
|
**kwargs
|
Any
|
Additional parameters passed to API layer, including |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame | tuple[DataFrame, dict[str, Any]]
|
DataFrame with data, or tuple (DataFrame, metadata) if return_metadata=True. |
Source code in pybdl/access/data.py
get_data_by_variable_locality_with_metadata ¶
Retrieve locality data by variable and always return (dataframe, metadata).
Source code in pybdl/access/data.py
get_data_by_unit_locality ¶
get_data_by_unit_locality(
unit_id,
variable_ids=None,
years=None,
aggregate_id=None,
page_size=None,
max_pages=None,
return_metadata=False,
**kwargs,
)
Retrieve data for a single statistical locality by unit as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit_id
|
str
|
Identifier of the statistical locality. |
required |
variable_ids
|
Sequence[str | int] | str | int | None
|
Variable ID or sequence of variable IDs. |
None
|
years
|
list[int] | None
|
Optional list of years to filter by. |
None
|
aggregate_id
|
int | None
|
Optional aggregate ID. |
None
|
page_size
|
int | None
|
Number of results per page (defaults to config.page_size or 100). |
None
|
max_pages
|
int | None
|
Maximum number of pages to fetch (None for all pages). |
None
|
return_metadata
|
bool
|
If True, return tuple (DataFrame, metadata). |
False
|
**kwargs
|
Any
|
Additional parameters passed to API layer, including |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame | tuple[DataFrame, dict[str, Any]]
|
DataFrame with data, or tuple (DataFrame, metadata) if return_metadata=True. |
Source code in pybdl/access/data.py
get_data_by_unit_locality_with_metadata ¶
Retrieve locality data by unit and always return (dataframe, metadata).
Source code in pybdl/access/data.py
aget_data_by_variable
async
¶
aget_data_by_variable(
variable_id,
years=None,
unit_parent_id=None,
unit_level=None,
aggregate_id=None,
page_size=None,
max_pages=None,
return_metadata=False,
**kwargs,
)
Asynchronously retrieve statistical data for a specific variable as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable_id
|
str
|
Identifier of the variable. |
required |
years
|
list[int] | None
|
Optional list of years to filter by. |
None
|
unit_parent_id
|
str | None
|
Optional parent administrative unit ID. |
None
|
unit_level
|
int | None
|
Optional administrative unit aggregation level. |
None
|
aggregate_id
|
int | None
|
Optional aggregate ID. |
None
|
page_size
|
int | None
|
Number of results per page (defaults to config.page_size or 100). |
None
|
max_pages
|
int | None
|
Maximum number of pages to fetch (None for all pages). |
None
|
return_metadata
|
bool
|
If True, return tuple (DataFrame, metadata). |
False
|
**kwargs
|
Any
|
Additional parameters passed to API layer, including |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame | tuple[DataFrame, dict[str, Any]]
|
DataFrame with normalized data, or tuple (DataFrame, metadata) if return_metadata is True. |
Source code in pybdl/access/data.py
aget_data_by_variable_with_metadata
async
¶
Asynchronously retrieve data by variable and always return (dataframe, metadata).
Source code in pybdl/access/data.py
aget_data_by_unit
async
¶
aget_data_by_unit(
unit_id,
variable_ids=None,
years=None,
aggregate_id=None,
return_metadata=False,
**kwargs,
)
Asynchronously retrieve statistical data for a specific administrative unit as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit_id
|
str
|
Identifier of the administrative unit. |
required |
variable_ids
|
Sequence[str | int] | str | int | None
|
Variable ID or sequence of variable IDs. |
None
|
years
|
list[int] | None
|
Optional list of years to filter by. |
None
|
aggregate_id
|
int | None
|
Optional aggregate ID. |
None
|
return_metadata
|
bool
|
If True, return tuple (DataFrame, metadata). |
False
|
**kwargs
|
Any
|
Additional parameters passed to API layer, including |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame | tuple[DataFrame, dict[str, Any]]
|
DataFrame with data, or tuple (DataFrame, metadata) if return_metadata=True. |
Source code in pybdl/access/data.py
aget_data_by_unit_with_metadata
async
¶
Asynchronously retrieve data by unit and always return (dataframe, metadata).
Source code in pybdl/access/data.py
aget_data_by_variable_locality
async
¶
aget_data_by_variable_locality(
variable_id,
unit_parent_id,
years=None,
page_size=None,
max_pages=None,
return_metadata=False,
**kwargs,
)
Asynchronously retrieve data for a variable within a specific locality as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable_id
|
str
|
Identifier of the variable. |
required |
unit_parent_id
|
str
|
Parent unit ID (required). |
required |
years
|
list[int] | None
|
Optional list of years to filter by. |
None
|
page_size
|
int | None
|
Number of results per page (defaults to config.page_size or 100). |
None
|
max_pages
|
int | None
|
Maximum number of pages to fetch (None for all pages). |
None
|
return_metadata
|
bool
|
If True, return tuple (DataFrame, metadata). |
False
|
**kwargs
|
Any
|
Additional parameters passed to API layer, including |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame | tuple[DataFrame, dict[str, Any]]
|
DataFrame with data, or tuple (DataFrame, metadata) if return_metadata=True. |
Source code in pybdl/access/data.py
aget_data_by_variable_locality_with_metadata
async
¶
Asynchronously retrieve locality data by variable and always return (dataframe, metadata).
Source code in pybdl/access/data.py
aget_data_by_unit_locality
async
¶
aget_data_by_unit_locality(
unit_id,
variable_ids=None,
years=None,
aggregate_id=None,
page_size=None,
max_pages=None,
return_metadata=False,
**kwargs,
)
Asynchronously retrieve data for a single statistical locality by unit as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit_id
|
str
|
Identifier of the statistical locality. |
required |
variable_ids
|
Sequence[str | int] | str | int | None
|
Variable ID or sequence of variable IDs. |
None
|
years
|
list[int] | None
|
Optional list of years to filter by. |
None
|
aggregate_id
|
int | None
|
Optional aggregate ID. |
None
|
page_size
|
int | None
|
Number of results per page (defaults to config.page_size or 100). |
None
|
max_pages
|
int | None
|
Maximum number of pages to fetch (None for all pages). |
None
|
return_metadata
|
bool
|
If True, return tuple (DataFrame, metadata). |
False
|
**kwargs
|
Any
|
Additional parameters passed to API layer, including |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame | tuple[DataFrame, dict[str, Any]]
|
DataFrame with data, or tuple (DataFrame, metadata) if return_metadata=True. |
Source code in pybdl/access/data.py
aget_data_by_unit_locality_with_metadata
async
¶
Asynchronously retrieve locality data by unit and always return (dataframe, metadata).
Source code in pybdl/access/data.py
Module pybdl.access.variables¶
variables ¶
Access layer for variables API endpoints.
VariablesAccess ¶
Bases: BaseAccess
Access layer for variables API, converting responses to DataFrames.
Initialize base access class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_client
|
Any
|
API client instance (e.g., LevelsAPI, AttributesAPI). |
required |
Source code in pybdl/access/base.py
list_variables ¶
list_variables(
subject_id=None,
level=None,
years=None,
page_size=None,
max_pages=None,
**kwargs,
)
List all variables as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subject_id
|
str | None
|
Optional subject ID to filter variables. |
None
|
level
|
int | None
|
Optional level to filter variables. |
None
|
years
|
list[int] | None
|
Optional list of years to filter variables. |
None
|
page_size
|
int | None
|
Number of results per page (defaults to config.page_size or 100). |
None
|
max_pages
|
int | None
|
Maximum number of pages to fetch (None for all pages). |
None
|
**kwargs
|
Any
|
Additional parameters passed to API layer, including |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with variables data. |
Source code in pybdl/access/variables.py
get_variable ¶
Retrieve metadata details for a specific variable as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable_id
|
str
|
Variable identifier. |
required |
**kwargs
|
Any
|
Additional parameters passed to API layer, including |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with variable metadata. |
Source code in pybdl/access/variables.py
search_variables ¶
search_variables(
name=None,
subject_id=None,
level=None,
years=None,
page_size=None,
max_pages=None,
**kwargs,
)
Search for variables by name and optional filters as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
Optional substring to search in variable name. |
None
|
subject_id
|
str | None
|
Optional subject ID to filter variables. |
None
|
level
|
int | None
|
Optional level to filter variables. |
None
|
years
|
list[int] | None
|
Optional list of years to filter variables. |
None
|
page_size
|
int | None
|
Number of results per page (defaults to config.page_size or 100). |
None
|
max_pages
|
int | None
|
Maximum number of pages to fetch (None for all pages). |
None
|
**kwargs
|
Any
|
Additional parameters passed to API layer, including |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with matching variables. |
Source code in pybdl/access/variables.py
alist_variables
async
¶
alist_variables(
subject_id=None,
level=None,
years=None,
page_size=None,
max_pages=None,
**kwargs,
)
Asynchronously list all variables as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subject_id
|
str | None
|
Optional subject ID to filter variables. |
None
|
level
|
int | None
|
Optional level to filter variables. |
None
|
years
|
list[int] | None
|
Optional list of years to filter variables. |
None
|
page_size
|
int | None
|
Number of results per page (defaults to config.page_size or 100). |
None
|
max_pages
|
int | None
|
Maximum number of pages to fetch (None for all pages). |
None
|
**kwargs
|
Any
|
Additional parameters passed to API layer, including |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with variables data. |
Source code in pybdl/access/variables.py
aget_variable
async
¶
Asynchronously retrieve metadata details for a specific variable as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable_id
|
str
|
Variable identifier. |
required |
**kwargs
|
Any
|
Additional parameters passed to API layer, including |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with variable metadata. |
Source code in pybdl/access/variables.py
asearch_variables
async
¶
asearch_variables(
name=None,
subject_id=None,
level=None,
years=None,
page_size=None,
max_pages=None,
**kwargs,
)
Asynchronously search for variables by name and optional filters as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
Optional substring to search in variable name. |
None
|
subject_id
|
str | None
|
Optional subject ID to filter variables. |
None
|
level
|
int | None
|
Optional level to filter variables. |
None
|
years
|
list[int] | None
|
Optional list of years to filter variables. |
None
|
page_size
|
int | None
|
Number of results per page (defaults to config.page_size or 100). |
None
|
max_pages
|
int | None
|
Maximum number of pages to fetch (None for all pages). |
None
|
**kwargs
|
Any
|
Additional parameters passed to API layer, including |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with matching variables. |
Source code in pybdl/access/variables.py
Module pybdl.access.subjects¶
subjects ¶
Access layer for subjects API endpoints.
SubjectsAccess ¶
Bases: BaseAccess
Access layer for subjects API, converting responses to DataFrames.
Initialize base access class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_client
|
Any
|
API client instance (e.g., LevelsAPI, AttributesAPI). |
required |
Source code in pybdl/access/base.py
list_subjects ¶
List all subjects as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_id
|
str | None
|
Optional parent subject ID. If not specified, returns all top-level subjects. |
None
|
page_size
|
int | None
|
Number of results per page (defaults to config.page_size or 100). |
None
|
max_pages
|
int | None
|
Maximum number of pages to fetch (None for all pages). |
None
|
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., sort, lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with subjects data. |
Source code in pybdl/access/subjects.py
get_subject ¶
Retrieve metadata for a specific subject as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subject_id
|
str
|
Subject identifier. |
required |
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with subject metadata. |
Source code in pybdl/access/subjects.py
search_subjects ¶
Search for subjects by name as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Subject name to search for. |
required |
page_size
|
int | None
|
Number of results per page (defaults to config.page_size or 100). |
None
|
max_pages
|
int | None
|
Maximum number of pages to fetch (None for all pages). |
None
|
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., sort, lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with matching subjects. |
Source code in pybdl/access/subjects.py
alist_subjects
async
¶
Asynchronously list all subjects as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_id
|
str | None
|
Optional parent subject ID. If not specified, returns all top-level subjects. |
None
|
page_size
|
int | None
|
Number of results per page (defaults to config.page_size or 100). |
None
|
max_pages
|
int | None
|
Maximum number of pages to fetch (None for all pages). |
None
|
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., sort, lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with subjects data. |
Source code in pybdl/access/subjects.py
aget_subject
async
¶
Asynchronously retrieve metadata for a specific subject as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subject_id
|
str
|
Subject identifier. |
required |
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with subject metadata. |
Source code in pybdl/access/subjects.py
asearch_subjects
async
¶
Asynchronously search for subjects by name as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Subject name to search for. |
required |
page_size
|
int | None
|
Number of results per page (defaults to config.page_size or 100). |
None
|
max_pages
|
int | None
|
Maximum number of pages to fetch (None for all pages). |
None
|
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., sort, lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with matching subjects. |
Source code in pybdl/access/subjects.py
Module pybdl.access.units¶
units ¶
Access layer for units API endpoints.
UnitsAccess ¶
Bases: BaseAccess
Access layer for units API, converting responses to DataFrames.
Initialize base access class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_client
|
Any
|
API client instance (e.g., LevelsAPI, AttributesAPI). |
required |
Source code in pybdl/access/base.py
list_units ¶
List all administrative units as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_id
|
str | None
|
Optional parent unit ID. |
None
|
level
|
int | list[int] | None
|
Optional administrative level (integer or list of integers). |
None
|
page_size
|
int | None
|
Number of results per page (defaults to config.page_size or 100). |
None
|
max_pages
|
int | None
|
Maximum number of pages to fetch (None for all pages). |
None
|
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., name, sort, lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with units data. |
Source code in pybdl/access/units.py
get_unit ¶
Retrieve metadata details for a specific administrative unit as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit_id
|
str
|
Administrative unit identifier. |
required |
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with unit metadata. |
Source code in pybdl/access/units.py
search_units ¶
search_units(
name=None,
level=None,
years=None,
kind=None,
page_size=None,
max_pages=None,
**kwargs,
)
Search for administrative units by name and optional filters as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
Optional substring to search in unit name. |
None
|
level
|
int | list[int] | None
|
Optional administrative level (integer or list of integers). |
None
|
years
|
list[int] | None
|
Optional list of years to filter by. |
None
|
kind
|
str | None
|
Optional unit kind filter. |
None
|
page_size
|
int | None
|
Number of results per page (defaults to config.page_size or 100). |
None
|
max_pages
|
int | None
|
Maximum number of pages to fetch (None for all pages). |
None
|
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., sort, lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with matching units. |
Source code in pybdl/access/units.py
list_localities ¶
List all statistical localities as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_id
|
str | None
|
Optional parent unit ID. |
None
|
page_size
|
int | None
|
Number of results per page (defaults to config.page_size or 100). |
None
|
max_pages
|
int | None
|
Maximum number of pages to fetch (None for all pages). |
None
|
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., name, level, sort, lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with localities data. |
Source code in pybdl/access/units.py
get_locality ¶
Retrieve metadata details for a specific statistical locality as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
locality_id
|
str
|
Locality identifier. |
required |
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with locality metadata. |
Source code in pybdl/access/units.py
search_localities ¶
Search for statistical localities by name and optional filters as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
Optional substring to search in locality name. |
None
|
years
|
list[int] | None
|
Optional list of years to filter by. |
None
|
page_size
|
int | None
|
Number of results per page (defaults to config.page_size or 100). |
None
|
max_pages
|
int | None
|
Maximum number of pages to fetch (None for all pages). |
None
|
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., level, parent_id, sort, lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with matching localities. |
Source code in pybdl/access/units.py
alist_units
async
¶
Asynchronously list all administrative units as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_id
|
str | None
|
Optional parent unit ID. |
None
|
level
|
int | list[int] | None
|
Optional administrative level (integer or list of integers). |
None
|
page_size
|
int | None
|
Number of results per page (defaults to config.page_size or 100). |
None
|
max_pages
|
int | None
|
Maximum number of pages to fetch (None for all pages). |
None
|
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., name, sort, lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with units data. |
Source code in pybdl/access/units.py
aget_unit
async
¶
Asynchronously retrieve metadata details for a specific administrative unit as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit_id
|
str
|
Administrative unit identifier. |
required |
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with unit metadata. |
Source code in pybdl/access/units.py
asearch_units
async
¶
asearch_units(
name=None,
level=None,
years=None,
kind=None,
page_size=None,
max_pages=None,
**kwargs,
)
Asynchronously search for administrative units by name and optional filters as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
Optional substring to search in unit name. |
None
|
level
|
int | list[int] | None
|
Optional administrative level (integer or list of integers). |
None
|
years
|
list[int] | None
|
Optional list of years to filter by. |
None
|
kind
|
str | None
|
Optional unit kind filter. |
None
|
page_size
|
int | None
|
Number of results per page (defaults to config.page_size or 100). |
None
|
max_pages
|
int | None
|
Maximum number of pages to fetch (None for all pages). |
None
|
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., sort, lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with matching units. |
Source code in pybdl/access/units.py
alist_localities
async
¶
Asynchronously list all statistical localities as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_id
|
str | None
|
Optional parent unit ID. |
None
|
page_size
|
int | None
|
Number of results per page (defaults to config.page_size or 100). |
None
|
max_pages
|
int | None
|
Maximum number of pages to fetch (None for all pages). |
None
|
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., name, level, sort, lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with localities data. |
Source code in pybdl/access/units.py
aget_locality
async
¶
Asynchronously retrieve metadata details for a specific statistical locality as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
locality_id
|
str
|
Locality identifier. |
required |
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with locality metadata. |
Source code in pybdl/access/units.py
asearch_localities
async
¶
Asynchronously search for statistical localities by name and optional filters as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
Optional substring to search in locality name. |
None
|
years
|
list[int] | None
|
Optional list of years to filter by. |
None
|
page_size
|
int | None
|
Number of results per page (defaults to config.page_size or 100). |
None
|
max_pages
|
int | None
|
Maximum number of pages to fetch (None for all pages). |
None
|
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., level, parent_id, sort, lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with matching localities. |
Source code in pybdl/access/units.py
Module pybdl.access.levels¶
levels ¶
Access layer for levels API endpoints.
LevelsAccess ¶
Bases: BaseAccess
Access layer for levels API, converting responses to DataFrames.
Initialize base access class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_client
|
Any
|
API client instance (e.g., LevelsAPI, AttributesAPI). |
required |
Source code in pybdl/access/base.py
list_levels ¶
List all administrative unit aggregation levels as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_size
|
int | None
|
Number of results per page (defaults to config.page_size or 100). |
None
|
max_pages
|
int | None
|
Maximum number of pages to fetch (None for all pages). |
None
|
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., sort, lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with levels data. |
Source code in pybdl/access/levels.py
get_level ¶
Retrieve metadata for a specific aggregation level as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level_id
|
int
|
Aggregation level identifier (integer). |
required |
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with level metadata. |
Source code in pybdl/access/levels.py
alist_levels
async
¶
Asynchronously list all administrative unit aggregation levels as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_size
|
int | None
|
Number of results per page (defaults to config.page_size or 100). |
None
|
max_pages
|
int | None
|
Maximum number of pages to fetch (None for all pages). |
None
|
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., sort, lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with levels data. |
Source code in pybdl/access/levels.py
aget_level
async
¶
Asynchronously retrieve metadata for a specific aggregation level as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level_id
|
int
|
Aggregation level identifier (integer). |
required |
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with level metadata. |
Source code in pybdl/access/levels.py
Module pybdl.access.measures¶
measures ¶
Access layer for measures API endpoints.
MeasuresAccess ¶
Bases: BaseAccess
Access layer for measures API, converting responses to DataFrames.
Initialize base access class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_client
|
Any
|
API client instance (e.g., LevelsAPI, AttributesAPI). |
required |
Source code in pybdl/access/base.py
list_measures ¶
List all measure units as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_size
|
int | None
|
Number of results per page (defaults to config.page_size or 100). |
None
|
max_pages
|
int | None
|
Maximum number of pages to fetch (None for all pages). |
None
|
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., sort, lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with measures data. |
Source code in pybdl/access/measures.py
get_measure ¶
Retrieve metadata for a specific measure unit as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
measure_id
|
int
|
Measure unit identifier (integer). |
required |
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with measure unit metadata. |
Source code in pybdl/access/measures.py
alist_measures
async
¶
Asynchronously list all measure units as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_size
|
int | None
|
Number of results per page (defaults to config.page_size or 100). |
None
|
max_pages
|
int | None
|
Maximum number of pages to fetch (None for all pages). |
None
|
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., sort, lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with measures data. |
Source code in pybdl/access/measures.py
aget_measure
async
¶
Asynchronously retrieve metadata for a specific measure unit as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
measure_id
|
int
|
Measure unit identifier (integer). |
required |
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with measure unit metadata. |
Source code in pybdl/access/measures.py
Module pybdl.access.attributes¶
attributes ¶
Access layer for attributes API endpoints.
AttributesAccess ¶
Bases: BaseAccess
Access layer for attributes API, converting responses to DataFrames.
Initialize base access class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_client
|
Any
|
API client instance (e.g., LevelsAPI, AttributesAPI). |
required |
Source code in pybdl/access/base.py
list_attributes ¶
List all attributes as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_size
|
int | None
|
Number of results per page (defaults to config.page_size or 100). |
None
|
max_pages
|
int | None
|
Maximum number of pages to fetch (None for all pages). |
None
|
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with attributes data. |
Source code in pybdl/access/attributes.py
get_attribute ¶
Retrieve metadata details for a specific attribute as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attribute_id
|
str
|
Attribute identifier. |
required |
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with attribute metadata. |
Source code in pybdl/access/attributes.py
alist_attributes
async
¶
Asynchronously list all attributes as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_size
|
int | None
|
Number of results per page (defaults to config.page_size or 100). |
None
|
max_pages
|
int | None
|
Maximum number of pages to fetch (None for all pages). |
None
|
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with attributes data. |
Source code in pybdl/access/attributes.py
aget_attribute
async
¶
Asynchronously retrieve metadata details for a specific attribute as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attribute_id
|
str
|
Attribute identifier. |
required |
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with attribute metadata. |
Source code in pybdl/access/attributes.py
Module pybdl.access.aggregates¶
aggregates ¶
Access layer for aggregates API endpoints.
AggregatesAccess ¶
Bases: BaseAccess
Access layer for aggregates API, converting responses to DataFrames.
Example column renaming::
_column_renames = {
"list_aggregates": {
"id": "aggregate_id",
"name": "aggregate_name",
},
"get_aggregate": {
"id": "aggregate_id",
},
}
Initialize base access class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_client
|
Any
|
API client instance (e.g., LevelsAPI, AttributesAPI). |
required |
Source code in pybdl/access/base.py
list_aggregates ¶
List all aggregates as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_size
|
int | None
|
Number of results per page (defaults to config.page_size or 100). |
None
|
max_pages
|
int | None
|
Maximum number of pages to fetch (None for all pages). |
None
|
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., sort, lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with aggregates data. |
Source code in pybdl/access/aggregates.py
get_aggregate ¶
Retrieve metadata details for a specific aggregate as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
aggregate_id
|
str
|
Aggregate identifier. |
required |
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with aggregate metadata. |
Source code in pybdl/access/aggregates.py
alist_aggregates
async
¶
Asynchronously list all aggregates as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_size
|
int | None
|
Number of results per page (defaults to config.page_size or 100). |
None
|
max_pages
|
int | None
|
Maximum number of pages to fetch (None for all pages). |
None
|
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., sort, lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with aggregates data. |
Source code in pybdl/access/aggregates.py
aget_aggregate
async
¶
Asynchronously retrieve metadata details for a specific aggregate as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
aggregate_id
|
str
|
Aggregate identifier. |
required |
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with aggregate metadata. |
Source code in pybdl/access/aggregates.py
Module pybdl.access.years¶
years ¶
Access layer for years API endpoints.
YearsAccess ¶
Bases: BaseAccess
Access layer for years API, converting responses to DataFrames.
Initialize base access class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_client
|
Any
|
API client instance (e.g., LevelsAPI, AttributesAPI). |
required |
Source code in pybdl/access/base.py
list_years ¶
List all available years as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_size
|
int | None
|
Number of results per page (defaults to config.page_size or 100). |
None
|
max_pages
|
int | None
|
Maximum number of pages to fetch (None for all pages). |
None
|
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., sort, lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with available years. |
Source code in pybdl/access/years.py
get_year ¶
Retrieve metadata for a specific year as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year_id
|
int
|
Year identifier (integer, e.g. 2020). |
required |
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with year metadata. |
Source code in pybdl/access/years.py
alist_years
async
¶
Asynchronously list all available years as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_size
|
int | None
|
Number of results per page (defaults to config.page_size or 100). |
None
|
max_pages
|
int | None
|
Maximum number of pages to fetch (None for all pages). |
None
|
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., sort, lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with available years. |
Source code in pybdl/access/years.py
aget_year
async
¶
Asynchronously retrieve metadata for a specific year as a DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year_id
|
int
|
Year identifier (integer, e.g. 2020). |
required |
**kwargs
|
Any
|
Additional parameters passed to API layer (e.g., lang, format, extra_query). |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with year metadata. |
Source code in pybdl/access/years.py
Seealso