API Clients¶
[!NOTE] For most users, the access layer is recommended. This section documents the low-level API client interface that returns raw dictionaries. The access layer (documented in access layer) returns pandas DataFrames and is easier to use for data analysis.
Use the API layer (
bdl.api.*) when you need: - Raw API response structure - Custom response processing - Direct access to API metadata - Integration with non-pandas workflowsUse the access layer (
bdl.*) when you need: - Pandas DataFrames for data analysis - Automatic column normalization and type inference - Nested data flattening
The pyBDL library provides a comprehensive set of API clients for
interacting with the Local Data Bank (BDL) API. All API endpoints are
accessible through the main client's .api
attribute. See Main client for details about the main
client.
| Endpoint | Class | Description |
|---|---|---|
| Aggregates | pybdl.api.aggregates.AggregatesAPI |
Aggregation level metadata and details |
| Attributes | pybdl.api.attributes.AttributesAPI |
Attribute metadata and details |
| Data | pybdl.api.data.DataAPI |
Statistical data access (variables, units, localities) |
| Levels | pybdl.api.levels.LevelsAPI |
Administrative unit aggregation levels |
| Measures | pybdl.api.measures.MeasuresAPI |
Measure unit metadata |
| Subjects | pybdl.api.subjects.SubjectsAPI |
Subject hierarchy and metadata |
| Units | pybdl.api.units.UnitsAPI |
Administrative unit metadata |
| Variables | pybdl.api.variables.VariablesAPI |
Variable metadata and details |
| Version | pybdl.api.version.VersionAPI |
API version and build info |
| Years | pybdl.api.years.YearsAPI |
Available years for data |
Available API Endpoints
[!NOTE] All API clients are accessible via
bdl.api.<endpoint>(e.g.,bdl.api.data.get_data_by_variable(...)).
Seealso
- Configuration — configuration options
- Main client — main client usage
Async Usage¶
All API clients support async methods for high-performance and
concurrent applications. Async methods are named with an
a prefix (e.g.,
aget_data_by_variable).
import asyncio
from pybdl import BDL
async def main():
bdl = BDL()
data = await bdl.api.data.aget_data_by_variable(variable_id="3643", years=[2021])
print(data)
asyncio.run(main())
[!NOTE] Async methods are available for all endpoints. See the API reference below for details.
Format and Language Parameters¶
API clients support format and language parameters for controlling response content:
Format Options (FormatLiteral): - "json" - JSON format
(default) - "jsonapi" - JSON:API format - "xml" - XML format
Language Options (LanguageLiteral): - "pl" - Polish (default if
configured) - "en" - English
The format and language parameters automatically set the appropriate
HTTP headers: - Accept header is set based on the format parameter -
Accept-Language header is set based on the language parameter
from pybdl import BDL
bdl = BDL()
# Request data in XML format
data = bdl.api.data.get_data_by_variable(
variable_id="3643",
years=[2021],
format="xml"
)
# Request data in Polish
data = bdl.api.data.get_data_by_variable(
variable_id="3643",
years=[2021],
lang="pl"
)
Aggregates¶
aggregates ¶
AggregatesAPI ¶
Bases: BaseAPIClient
Client for the BDL /aggregates endpoints.
Initialize base API client for BDL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
BDLConfig
|
BDL configuration object. |
required |
extra_headers
|
dict[str, str] | None
|
Optional extra headers (e.g., Accept-Language) to include in requests. |
None
|
Source code in pybdl/api/client.py
session
instance-attribute
¶
session = build_sync_http_client(
cache_backend=cache_backend,
http_cache_db_path=_http_cache_path,
default_headers=default_headers,
proxy=_proxy_url,
)
list_aggregates ¶
list_aggregates(
sort=None,
page_size=100,
max_pages=None,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/aggregates.py
get_aggregate ¶
get_aggregate(
aggregate_id,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/aggregates.py
get_aggregates_metadata ¶
get_aggregates_metadata(
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/aggregates.py
alist_aggregates
async
¶
alist_aggregates(
sort=None,
page_size=100,
max_pages=None,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/aggregates.py
aget_aggregate
async
¶
aget_aggregate(
aggregate_id,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/aggregates.py
aget_aggregates_metadata
async
¶
aget_aggregates_metadata(
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/aggregates.py
close ¶
aclose
async
¶
__enter__ ¶
__exit__ ¶
__aenter__
async
¶
__aexit__
async
¶
fetch_all_results ¶
fetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[False] = False,
show_progress: bool = True,
) -> list[dict[str, Any]]
fetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[True],
show_progress: bool = True,
) -> tuple[list[dict[str, Any]], dict[str, Any]]
fetch_all_results(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
return_metadata=False,
show_progress=True,
)
Fetch paginated results synchronously and combine them into a single list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
method
|
str
|
HTTP method (default: GET). |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
results_key
|
str
|
Key for extracting data from each page. |
'results'
|
page_size
|
int
|
Items per page. |
100
|
max_pages
|
int | None
|
Optional limit of pages. |
None
|
return_metadata
|
bool
|
If True, return (results, metadata). |
False
|
show_progress
|
bool
|
Display progress via tqdm. |
True
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]]
|
Combined list of results, optionally with metadata. |
Source code in pybdl/api/client.py
fetch_all_results_with_metadata ¶
fetch_all_results_with_metadata(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
show_progress=True,
)
Source code in pybdl/api/client.py
fetch_single_result ¶
fetch_single_result(
endpoint: str,
*,
results_key: None = None,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> dict[str, Any]
fetch_single_result(
endpoint: str,
*,
results_key: str,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> list[dict[str, Any]]
fetch_single_result(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
return_metadata=False,
)
Fetch a single result, non-paginated (sync).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
results_key
|
str | None
|
If not None, extract this key from the JSON. |
None
|
method
|
str
|
HTTP method. |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
return_metadata
|
bool
|
Also return metadata if True. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | list[dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]] | tuple[dict[str, Any], dict[str, Any]]
|
Dictionary or list, optionally with separate metadata. |
Source code in pybdl/api/client.py
fetch_single_result_with_metadata ¶
fetch_single_result_with_metadata(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
)
Source code in pybdl/api/client.py
afetch_all_results
async
¶
afetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[False] = False,
show_progress: bool = True,
) -> list[dict[str, Any]]
afetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[True],
show_progress: bool = True,
) -> tuple[list[dict[str, Any]], dict[str, Any]]
afetch_all_results(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
return_metadata=False,
show_progress=True,
)
Asynchronously fetch paginated results and combine them into a single list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
method
|
str
|
HTTP method (default: GET). |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
results_key
|
str
|
Key for extracting data from each page. |
'results'
|
page_size
|
int
|
Items per page. |
100
|
max_pages
|
int | None
|
Optional limit of pages. |
None
|
return_metadata
|
bool
|
If True, return (results, metadata). |
False
|
show_progress
|
bool
|
Display progress via tqdm. |
True
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]]
|
Combined list of results, optionally with metadata. |
Source code in pybdl/api/client.py
afetch_all_results_with_metadata
async
¶
afetch_all_results_with_metadata(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
show_progress=True,
)
Source code in pybdl/api/client.py
afetch_single_result
async
¶
afetch_single_result(
endpoint: str,
*,
method: str = "GET",
results_key: Literal[None] = None,
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> dict[str, Any]
afetch_single_result(
endpoint: str,
*,
results_key: str,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> list[dict[str, Any]]
afetch_single_result(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
return_metadata=False,
)
Asynchronously fetch a single result, non-paginated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
results_key
|
str | None
|
If not None, extract this key from the JSON. |
None
|
method
|
str
|
HTTP method. |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
return_metadata
|
bool
|
Also return metadata if True. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | list[dict[str, Any]] | tuple[dict[str, Any], dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]]
|
Dictionary or list, optionally with separate metadata. |
Source code in pybdl/api/client.py
afetch_single_result_with_metadata
async
¶
afetch_single_result_with_metadata(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
)
Source code in pybdl/api/client.py
Attributes¶
attributes ¶
AttributesAPI ¶
Bases: BaseAPIClient
Client for the BDL /attributes endpoints.
Initialize base API client for BDL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
BDLConfig
|
BDL configuration object. |
required |
extra_headers
|
dict[str, str] | None
|
Optional extra headers (e.g., Accept-Language) to include in requests. |
None
|
Source code in pybdl/api/client.py
session
instance-attribute
¶
session = build_sync_http_client(
cache_backend=cache_backend,
http_cache_db_path=_http_cache_path,
default_headers=default_headers,
proxy=_proxy_url,
)
list_attributes ¶
list_attributes(
sort=None,
page_size=100,
max_pages=None,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/attributes.py
get_attribute ¶
get_attribute(
attribute_id,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/attributes.py
get_attributes_metadata ¶
get_attributes_metadata(
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/attributes.py
alist_attributes
async
¶
alist_attributes(
sort=None,
page_size=100,
max_pages=None,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/attributes.py
aget_attribute
async
¶
aget_attribute(
attribute_id,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/attributes.py
aget_attributes_metadata
async
¶
aget_attributes_metadata(
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/attributes.py
close ¶
aclose
async
¶
__enter__ ¶
__exit__ ¶
__aenter__
async
¶
__aexit__
async
¶
fetch_all_results ¶
fetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[False] = False,
show_progress: bool = True,
) -> list[dict[str, Any]]
fetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[True],
show_progress: bool = True,
) -> tuple[list[dict[str, Any]], dict[str, Any]]
fetch_all_results(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
return_metadata=False,
show_progress=True,
)
Fetch paginated results synchronously and combine them into a single list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
method
|
str
|
HTTP method (default: GET). |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
results_key
|
str
|
Key for extracting data from each page. |
'results'
|
page_size
|
int
|
Items per page. |
100
|
max_pages
|
int | None
|
Optional limit of pages. |
None
|
return_metadata
|
bool
|
If True, return (results, metadata). |
False
|
show_progress
|
bool
|
Display progress via tqdm. |
True
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]]
|
Combined list of results, optionally with metadata. |
Source code in pybdl/api/client.py
fetch_all_results_with_metadata ¶
fetch_all_results_with_metadata(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
show_progress=True,
)
Source code in pybdl/api/client.py
fetch_single_result ¶
fetch_single_result(
endpoint: str,
*,
results_key: None = None,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> dict[str, Any]
fetch_single_result(
endpoint: str,
*,
results_key: str,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> list[dict[str, Any]]
fetch_single_result(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
return_metadata=False,
)
Fetch a single result, non-paginated (sync).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
results_key
|
str | None
|
If not None, extract this key from the JSON. |
None
|
method
|
str
|
HTTP method. |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
return_metadata
|
bool
|
Also return metadata if True. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | list[dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]] | tuple[dict[str, Any], dict[str, Any]]
|
Dictionary or list, optionally with separate metadata. |
Source code in pybdl/api/client.py
fetch_single_result_with_metadata ¶
fetch_single_result_with_metadata(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
)
Source code in pybdl/api/client.py
afetch_all_results
async
¶
afetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[False] = False,
show_progress: bool = True,
) -> list[dict[str, Any]]
afetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[True],
show_progress: bool = True,
) -> tuple[list[dict[str, Any]], dict[str, Any]]
afetch_all_results(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
return_metadata=False,
show_progress=True,
)
Asynchronously fetch paginated results and combine them into a single list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
method
|
str
|
HTTP method (default: GET). |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
results_key
|
str
|
Key for extracting data from each page. |
'results'
|
page_size
|
int
|
Items per page. |
100
|
max_pages
|
int | None
|
Optional limit of pages. |
None
|
return_metadata
|
bool
|
If True, return (results, metadata). |
False
|
show_progress
|
bool
|
Display progress via tqdm. |
True
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]]
|
Combined list of results, optionally with metadata. |
Source code in pybdl/api/client.py
afetch_all_results_with_metadata
async
¶
afetch_all_results_with_metadata(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
show_progress=True,
)
Source code in pybdl/api/client.py
afetch_single_result
async
¶
afetch_single_result(
endpoint: str,
*,
method: str = "GET",
results_key: Literal[None] = None,
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> dict[str, Any]
afetch_single_result(
endpoint: str,
*,
results_key: str,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> list[dict[str, Any]]
afetch_single_result(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
return_metadata=False,
)
Asynchronously fetch a single result, non-paginated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
results_key
|
str | None
|
If not None, extract this key from the JSON. |
None
|
method
|
str
|
HTTP method. |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
return_metadata
|
bool
|
Also return metadata if True. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | list[dict[str, Any]] | tuple[dict[str, Any], dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]]
|
Dictionary or list, optionally with separate metadata. |
Source code in pybdl/api/client.py
afetch_single_result_with_metadata
async
¶
afetch_single_result_with_metadata(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
)
Source code in pybdl/api/client.py
Data¶
data ¶
DataAPI ¶
Bases: BaseAPIClient
Client for all BDL /data endpoints.
Provides Pythonic, paginated, and DataFrame-ready access to all public data endpoints in the Local Data Bank (BDL) API. Supports flexible parameterization, pagination, and format options for robust data retrieval.
Methods map directly to documented BDL endpoints under the /data namespace, enabling users to fetch statistical data by variable, unit, and locality.
Initialize base API client for BDL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
BDLConfig
|
BDL configuration object. |
required |
extra_headers
|
dict[str, str] | None
|
Optional extra headers (e.g., Accept-Language) to include in requests. |
None
|
Source code in pybdl/api/client.py
session
instance-attribute
¶
session = build_sync_http_client(
cache_backend=cache_backend,
http_cache_db_path=_http_cache_path,
default_headers=default_headers,
proxy=_proxy_url,
)
get_data_by_variable ¶
get_data_by_variable(
variable_id,
years=None,
unit_parent_id=None,
unit_level=None,
aggregate_id=None,
page=None,
page_size=100,
max_pages=None,
format=None,
lang=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
return_metadata=False,
)
Source code in pybdl/api/data.py
get_data_by_variable_with_metadata ¶
Retrieve data by variable and always return (results, metadata).
Source code in pybdl/api/data.py
get_data_by_unit ¶
get_data_by_unit(
unit_id,
variable_ids=None,
*,
variable_id=None,
years=None,
aggregate_id=None,
page=None,
page_size=100,
format=None,
lang=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
return_metadata=False,
)
Source code in pybdl/api/data.py
get_data_by_unit_with_metadata ¶
Retrieve data by unit and always return (results, metadata).
Source code in pybdl/api/data.py
get_data_by_variable_locality ¶
get_data_by_variable_locality(
variable_id,
unit_parent_id,
years=None,
page=None,
page_size=100,
max_pages=None,
format=None,
lang=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
return_metadata=False,
)
Source code in pybdl/api/data.py
get_data_by_variable_locality_with_metadata ¶
Retrieve locality data by variable and always return (results, metadata).
Source code in pybdl/api/data.py
get_data_by_unit_locality ¶
get_data_by_unit_locality(
unit_id,
variable_ids=None,
*,
variable_id=None,
years=None,
aggregate_id=None,
page=None,
page_size=100,
max_pages=None,
format=None,
lang=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
return_metadata=False,
)
Source code in pybdl/api/data.py
get_data_by_unit_locality_with_metadata ¶
Retrieve locality data by unit and always return (results, metadata).
Source code in pybdl/api/data.py
get_data_metadata ¶
get_data_metadata(
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/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=None,
page_size=100,
max_pages=None,
format=None,
lang=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
return_metadata=False,
)
Source code in pybdl/api/data.py
aget_data_by_variable_with_metadata
async
¶
Asynchronously retrieve data by variable and always return (results, metadata).
Source code in pybdl/api/data.py
aget_data_by_unit
async
¶
aget_data_by_unit(
unit_id,
variable_ids=None,
*,
variable_id=None,
years=None,
aggregate_id=None,
page=None,
page_size=100,
format=None,
lang=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
return_metadata=False,
)
Source code in pybdl/api/data.py
aget_data_by_unit_with_metadata
async
¶
Asynchronously retrieve data by unit and always return (results, metadata).
Source code in pybdl/api/data.py
aget_data_by_variable_locality
async
¶
aget_data_by_variable_locality(
variable_id,
unit_parent_id,
years=None,
page=None,
page_size=100,
max_pages=None,
format=None,
lang=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
return_metadata=False,
)
Source code in pybdl/api/data.py
aget_data_by_variable_locality_with_metadata
async
¶
Asynchronously retrieve locality data by variable and always return (results, metadata).
Source code in pybdl/api/data.py
aget_data_by_unit_locality
async
¶
aget_data_by_unit_locality(
unit_id,
variable_ids=None,
*,
variable_id=None,
years=None,
aggregate_id=None,
page=None,
page_size=100,
max_pages=None,
format=None,
lang=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
return_metadata=False,
)
Source code in pybdl/api/data.py
aget_data_by_unit_locality_with_metadata
async
¶
Asynchronously retrieve locality data by unit and always return (results, metadata).
Source code in pybdl/api/data.py
aget_data_metadata
async
¶
aget_data_metadata(
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/data.py
close ¶
aclose
async
¶
__enter__ ¶
__exit__ ¶
__aenter__
async
¶
__aexit__
async
¶
fetch_all_results ¶
fetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[False] = False,
show_progress: bool = True,
) -> list[dict[str, Any]]
fetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[True],
show_progress: bool = True,
) -> tuple[list[dict[str, Any]], dict[str, Any]]
fetch_all_results(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
return_metadata=False,
show_progress=True,
)
Fetch paginated results synchronously and combine them into a single list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
method
|
str
|
HTTP method (default: GET). |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
results_key
|
str
|
Key for extracting data from each page. |
'results'
|
page_size
|
int
|
Items per page. |
100
|
max_pages
|
int | None
|
Optional limit of pages. |
None
|
return_metadata
|
bool
|
If True, return (results, metadata). |
False
|
show_progress
|
bool
|
Display progress via tqdm. |
True
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]]
|
Combined list of results, optionally with metadata. |
Source code in pybdl/api/client.py
fetch_all_results_with_metadata ¶
fetch_all_results_with_metadata(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
show_progress=True,
)
Source code in pybdl/api/client.py
fetch_single_result ¶
fetch_single_result(
endpoint: str,
*,
results_key: None = None,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> dict[str, Any]
fetch_single_result(
endpoint: str,
*,
results_key: str,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> list[dict[str, Any]]
fetch_single_result(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
return_metadata=False,
)
Fetch a single result, non-paginated (sync).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
results_key
|
str | None
|
If not None, extract this key from the JSON. |
None
|
method
|
str
|
HTTP method. |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
return_metadata
|
bool
|
Also return metadata if True. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | list[dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]] | tuple[dict[str, Any], dict[str, Any]]
|
Dictionary or list, optionally with separate metadata. |
Source code in pybdl/api/client.py
fetch_single_result_with_metadata ¶
fetch_single_result_with_metadata(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
)
Source code in pybdl/api/client.py
afetch_all_results
async
¶
afetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[False] = False,
show_progress: bool = True,
) -> list[dict[str, Any]]
afetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[True],
show_progress: bool = True,
) -> tuple[list[dict[str, Any]], dict[str, Any]]
afetch_all_results(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
return_metadata=False,
show_progress=True,
)
Asynchronously fetch paginated results and combine them into a single list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
method
|
str
|
HTTP method (default: GET). |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
results_key
|
str
|
Key for extracting data from each page. |
'results'
|
page_size
|
int
|
Items per page. |
100
|
max_pages
|
int | None
|
Optional limit of pages. |
None
|
return_metadata
|
bool
|
If True, return (results, metadata). |
False
|
show_progress
|
bool
|
Display progress via tqdm. |
True
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]]
|
Combined list of results, optionally with metadata. |
Source code in pybdl/api/client.py
afetch_all_results_with_metadata
async
¶
afetch_all_results_with_metadata(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
show_progress=True,
)
Source code in pybdl/api/client.py
afetch_single_result
async
¶
afetch_single_result(
endpoint: str,
*,
method: str = "GET",
results_key: Literal[None] = None,
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> dict[str, Any]
afetch_single_result(
endpoint: str,
*,
results_key: str,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> list[dict[str, Any]]
afetch_single_result(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
return_metadata=False,
)
Asynchronously fetch a single result, non-paginated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
results_key
|
str | None
|
If not None, extract this key from the JSON. |
None
|
method
|
str
|
HTTP method. |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
return_metadata
|
bool
|
Also return metadata if True. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | list[dict[str, Any]] | tuple[dict[str, Any], dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]]
|
Dictionary or list, optionally with separate metadata. |
Source code in pybdl/api/client.py
afetch_single_result_with_metadata
async
¶
afetch_single_result_with_metadata(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
)
Source code in pybdl/api/client.py
Levels¶
levels ¶
LevelsAPI ¶
Bases: BaseAPIClient
Client for the BDL /levels endpoints.
Initialize base API client for BDL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
BDLConfig
|
BDL configuration object. |
required |
extra_headers
|
dict[str, str] | None
|
Optional extra headers (e.g., Accept-Language) to include in requests. |
None
|
Source code in pybdl/api/client.py
session
instance-attribute
¶
session = build_sync_http_client(
cache_backend=cache_backend,
http_cache_db_path=_http_cache_path,
default_headers=default_headers,
proxy=_proxy_url,
)
list_levels ¶
list_levels(
sort=None,
page_size=100,
max_pages=None,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/levels.py
get_level ¶
get_level(
level_id,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/levels.py
get_levels_metadata ¶
get_levels_metadata(
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/levels.py
alist_levels
async
¶
alist_levels(
sort=None,
page_size=100,
max_pages=None,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/levels.py
aget_level
async
¶
aget_level(
level_id,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/levels.py
aget_levels_metadata
async
¶
aget_levels_metadata(
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/levels.py
close ¶
aclose
async
¶
__enter__ ¶
__exit__ ¶
__aenter__
async
¶
__aexit__
async
¶
fetch_all_results ¶
fetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[False] = False,
show_progress: bool = True,
) -> list[dict[str, Any]]
fetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[True],
show_progress: bool = True,
) -> tuple[list[dict[str, Any]], dict[str, Any]]
fetch_all_results(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
return_metadata=False,
show_progress=True,
)
Fetch paginated results synchronously and combine them into a single list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
method
|
str
|
HTTP method (default: GET). |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
results_key
|
str
|
Key for extracting data from each page. |
'results'
|
page_size
|
int
|
Items per page. |
100
|
max_pages
|
int | None
|
Optional limit of pages. |
None
|
return_metadata
|
bool
|
If True, return (results, metadata). |
False
|
show_progress
|
bool
|
Display progress via tqdm. |
True
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]]
|
Combined list of results, optionally with metadata. |
Source code in pybdl/api/client.py
fetch_all_results_with_metadata ¶
fetch_all_results_with_metadata(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
show_progress=True,
)
Source code in pybdl/api/client.py
fetch_single_result ¶
fetch_single_result(
endpoint: str,
*,
results_key: None = None,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> dict[str, Any]
fetch_single_result(
endpoint: str,
*,
results_key: str,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> list[dict[str, Any]]
fetch_single_result(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
return_metadata=False,
)
Fetch a single result, non-paginated (sync).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
results_key
|
str | None
|
If not None, extract this key from the JSON. |
None
|
method
|
str
|
HTTP method. |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
return_metadata
|
bool
|
Also return metadata if True. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | list[dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]] | tuple[dict[str, Any], dict[str, Any]]
|
Dictionary or list, optionally with separate metadata. |
Source code in pybdl/api/client.py
fetch_single_result_with_metadata ¶
fetch_single_result_with_metadata(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
)
Source code in pybdl/api/client.py
afetch_all_results
async
¶
afetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[False] = False,
show_progress: bool = True,
) -> list[dict[str, Any]]
afetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[True],
show_progress: bool = True,
) -> tuple[list[dict[str, Any]], dict[str, Any]]
afetch_all_results(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
return_metadata=False,
show_progress=True,
)
Asynchronously fetch paginated results and combine them into a single list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
method
|
str
|
HTTP method (default: GET). |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
results_key
|
str
|
Key for extracting data from each page. |
'results'
|
page_size
|
int
|
Items per page. |
100
|
max_pages
|
int | None
|
Optional limit of pages. |
None
|
return_metadata
|
bool
|
If True, return (results, metadata). |
False
|
show_progress
|
bool
|
Display progress via tqdm. |
True
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]]
|
Combined list of results, optionally with metadata. |
Source code in pybdl/api/client.py
afetch_all_results_with_metadata
async
¶
afetch_all_results_with_metadata(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
show_progress=True,
)
Source code in pybdl/api/client.py
afetch_single_result
async
¶
afetch_single_result(
endpoint: str,
*,
method: str = "GET",
results_key: Literal[None] = None,
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> dict[str, Any]
afetch_single_result(
endpoint: str,
*,
results_key: str,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> list[dict[str, Any]]
afetch_single_result(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
return_metadata=False,
)
Asynchronously fetch a single result, non-paginated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
results_key
|
str | None
|
If not None, extract this key from the JSON. |
None
|
method
|
str
|
HTTP method. |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
return_metadata
|
bool
|
Also return metadata if True. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | list[dict[str, Any]] | tuple[dict[str, Any], dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]]
|
Dictionary or list, optionally with separate metadata. |
Source code in pybdl/api/client.py
afetch_single_result_with_metadata
async
¶
afetch_single_result_with_metadata(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
)
Source code in pybdl/api/client.py
Measures¶
measures ¶
MeasuresAPI ¶
Bases: BaseAPIClient
Client for the BDL /measures endpoints.
Initialize base API client for BDL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
BDLConfig
|
BDL configuration object. |
required |
extra_headers
|
dict[str, str] | None
|
Optional extra headers (e.g., Accept-Language) to include in requests. |
None
|
Source code in pybdl/api/client.py
session
instance-attribute
¶
session = build_sync_http_client(
cache_backend=cache_backend,
http_cache_db_path=_http_cache_path,
default_headers=default_headers,
proxy=_proxy_url,
)
list_measures ¶
list_measures(
sort=None,
page_size=100,
max_pages=None,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/measures.py
get_measure ¶
get_measure(
measure_id,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/measures.py
get_measures_metadata ¶
get_measures_metadata(
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/measures.py
alist_measures
async
¶
alist_measures(
sort=None,
page_size=100,
max_pages=None,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/measures.py
aget_measure
async
¶
aget_measure(
measure_id,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/measures.py
aget_measures_metadata
async
¶
aget_measures_metadata(
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/measures.py
close ¶
aclose
async
¶
__enter__ ¶
__exit__ ¶
__aenter__
async
¶
__aexit__
async
¶
fetch_all_results ¶
fetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[False] = False,
show_progress: bool = True,
) -> list[dict[str, Any]]
fetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[True],
show_progress: bool = True,
) -> tuple[list[dict[str, Any]], dict[str, Any]]
fetch_all_results(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
return_metadata=False,
show_progress=True,
)
Fetch paginated results synchronously and combine them into a single list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
method
|
str
|
HTTP method (default: GET). |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
results_key
|
str
|
Key for extracting data from each page. |
'results'
|
page_size
|
int
|
Items per page. |
100
|
max_pages
|
int | None
|
Optional limit of pages. |
None
|
return_metadata
|
bool
|
If True, return (results, metadata). |
False
|
show_progress
|
bool
|
Display progress via tqdm. |
True
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]]
|
Combined list of results, optionally with metadata. |
Source code in pybdl/api/client.py
fetch_all_results_with_metadata ¶
fetch_all_results_with_metadata(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
show_progress=True,
)
Source code in pybdl/api/client.py
fetch_single_result ¶
fetch_single_result(
endpoint: str,
*,
results_key: None = None,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> dict[str, Any]
fetch_single_result(
endpoint: str,
*,
results_key: str,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> list[dict[str, Any]]
fetch_single_result(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
return_metadata=False,
)
Fetch a single result, non-paginated (sync).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
results_key
|
str | None
|
If not None, extract this key from the JSON. |
None
|
method
|
str
|
HTTP method. |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
return_metadata
|
bool
|
Also return metadata if True. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | list[dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]] | tuple[dict[str, Any], dict[str, Any]]
|
Dictionary or list, optionally with separate metadata. |
Source code in pybdl/api/client.py
fetch_single_result_with_metadata ¶
fetch_single_result_with_metadata(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
)
Source code in pybdl/api/client.py
afetch_all_results
async
¶
afetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[False] = False,
show_progress: bool = True,
) -> list[dict[str, Any]]
afetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[True],
show_progress: bool = True,
) -> tuple[list[dict[str, Any]], dict[str, Any]]
afetch_all_results(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
return_metadata=False,
show_progress=True,
)
Asynchronously fetch paginated results and combine them into a single list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
method
|
str
|
HTTP method (default: GET). |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
results_key
|
str
|
Key for extracting data from each page. |
'results'
|
page_size
|
int
|
Items per page. |
100
|
max_pages
|
int | None
|
Optional limit of pages. |
None
|
return_metadata
|
bool
|
If True, return (results, metadata). |
False
|
show_progress
|
bool
|
Display progress via tqdm. |
True
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]]
|
Combined list of results, optionally with metadata. |
Source code in pybdl/api/client.py
afetch_all_results_with_metadata
async
¶
afetch_all_results_with_metadata(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
show_progress=True,
)
Source code in pybdl/api/client.py
afetch_single_result
async
¶
afetch_single_result(
endpoint: str,
*,
method: str = "GET",
results_key: Literal[None] = None,
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> dict[str, Any]
afetch_single_result(
endpoint: str,
*,
results_key: str,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> list[dict[str, Any]]
afetch_single_result(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
return_metadata=False,
)
Asynchronously fetch a single result, non-paginated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
results_key
|
str | None
|
If not None, extract this key from the JSON. |
None
|
method
|
str
|
HTTP method. |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
return_metadata
|
bool
|
Also return metadata if True. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | list[dict[str, Any]] | tuple[dict[str, Any], dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]]
|
Dictionary or list, optionally with separate metadata. |
Source code in pybdl/api/client.py
afetch_single_result_with_metadata
async
¶
afetch_single_result_with_metadata(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
)
Source code in pybdl/api/client.py
Subjects¶
subjects ¶
SubjectsAPI ¶
Bases: BaseAPIClient
Client for the BDL /subjects endpoints.
Initialize base API client for BDL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
BDLConfig
|
BDL configuration object. |
required |
extra_headers
|
dict[str, str] | None
|
Optional extra headers (e.g., Accept-Language) to include in requests. |
None
|
Source code in pybdl/api/client.py
session
instance-attribute
¶
session = build_sync_http_client(
cache_backend=cache_backend,
http_cache_db_path=_http_cache_path,
default_headers=default_headers,
proxy=_proxy_url,
)
list_subjects ¶
list_subjects(
parent_id=None,
sort=None,
page=None,
page_size=100,
max_pages=None,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/subjects.py
get_subject ¶
get_subject(
subject_id,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/subjects.py
search_subjects ¶
search_subjects(
name,
page=None,
page_size=100,
max_pages=None,
sort=None,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/subjects.py
get_subjects_metadata ¶
get_subjects_metadata(
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/subjects.py
alist_subjects
async
¶
alist_subjects(
parent_id=None,
sort=None,
page=None,
page_size=100,
max_pages=None,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/subjects.py
aget_subject
async
¶
aget_subject(
subject_id,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/subjects.py
asearch_subjects
async
¶
asearch_subjects(
name,
page=None,
page_size=100,
max_pages=None,
sort=None,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/subjects.py
aget_subjects_metadata
async
¶
aget_subjects_metadata(
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/subjects.py
close ¶
aclose
async
¶
__enter__ ¶
__exit__ ¶
__aenter__
async
¶
__aexit__
async
¶
fetch_all_results ¶
fetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[False] = False,
show_progress: bool = True,
) -> list[dict[str, Any]]
fetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[True],
show_progress: bool = True,
) -> tuple[list[dict[str, Any]], dict[str, Any]]
fetch_all_results(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
return_metadata=False,
show_progress=True,
)
Fetch paginated results synchronously and combine them into a single list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
method
|
str
|
HTTP method (default: GET). |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
results_key
|
str
|
Key for extracting data from each page. |
'results'
|
page_size
|
int
|
Items per page. |
100
|
max_pages
|
int | None
|
Optional limit of pages. |
None
|
return_metadata
|
bool
|
If True, return (results, metadata). |
False
|
show_progress
|
bool
|
Display progress via tqdm. |
True
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]]
|
Combined list of results, optionally with metadata. |
Source code in pybdl/api/client.py
fetch_all_results_with_metadata ¶
fetch_all_results_with_metadata(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
show_progress=True,
)
Source code in pybdl/api/client.py
fetch_single_result ¶
fetch_single_result(
endpoint: str,
*,
results_key: None = None,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> dict[str, Any]
fetch_single_result(
endpoint: str,
*,
results_key: str,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> list[dict[str, Any]]
fetch_single_result(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
return_metadata=False,
)
Fetch a single result, non-paginated (sync).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
results_key
|
str | None
|
If not None, extract this key from the JSON. |
None
|
method
|
str
|
HTTP method. |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
return_metadata
|
bool
|
Also return metadata if True. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | list[dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]] | tuple[dict[str, Any], dict[str, Any]]
|
Dictionary or list, optionally with separate metadata. |
Source code in pybdl/api/client.py
fetch_single_result_with_metadata ¶
fetch_single_result_with_metadata(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
)
Source code in pybdl/api/client.py
afetch_all_results
async
¶
afetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[False] = False,
show_progress: bool = True,
) -> list[dict[str, Any]]
afetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[True],
show_progress: bool = True,
) -> tuple[list[dict[str, Any]], dict[str, Any]]
afetch_all_results(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
return_metadata=False,
show_progress=True,
)
Asynchronously fetch paginated results and combine them into a single list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
method
|
str
|
HTTP method (default: GET). |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
results_key
|
str
|
Key for extracting data from each page. |
'results'
|
page_size
|
int
|
Items per page. |
100
|
max_pages
|
int | None
|
Optional limit of pages. |
None
|
return_metadata
|
bool
|
If True, return (results, metadata). |
False
|
show_progress
|
bool
|
Display progress via tqdm. |
True
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]]
|
Combined list of results, optionally with metadata. |
Source code in pybdl/api/client.py
afetch_all_results_with_metadata
async
¶
afetch_all_results_with_metadata(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
show_progress=True,
)
Source code in pybdl/api/client.py
afetch_single_result
async
¶
afetch_single_result(
endpoint: str,
*,
method: str = "GET",
results_key: Literal[None] = None,
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> dict[str, Any]
afetch_single_result(
endpoint: str,
*,
results_key: str,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> list[dict[str, Any]]
afetch_single_result(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
return_metadata=False,
)
Asynchronously fetch a single result, non-paginated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
results_key
|
str | None
|
If not None, extract this key from the JSON. |
None
|
method
|
str
|
HTTP method. |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
return_metadata
|
bool
|
Also return metadata if True. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | list[dict[str, Any]] | tuple[dict[str, Any], dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]]
|
Dictionary or list, optionally with separate metadata. |
Source code in pybdl/api/client.py
afetch_single_result_with_metadata
async
¶
afetch_single_result_with_metadata(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
)
Source code in pybdl/api/client.py
Units¶
units ¶
UnitsAPI ¶
Bases: BaseAPIClient
Client for the BDL /units endpoints.
Initialize base API client for BDL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
BDLConfig
|
BDL configuration object. |
required |
extra_headers
|
dict[str, str] | None
|
Optional extra headers (e.g., Accept-Language) to include in requests. |
None
|
Source code in pybdl/api/client.py
session
instance-attribute
¶
session = build_sync_http_client(
cache_backend=cache_backend,
http_cache_db_path=_http_cache_path,
default_headers=default_headers,
proxy=_proxy_url,
)
list_units ¶
list_units(
parent_id=None,
level=None,
page=None,
page_size=100,
max_pages=None,
sort=None,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/units.py
get_unit ¶
get_unit(
unit_id,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/units.py
search_units ¶
search_units(
name=None,
level=None,
years=None,
kind=None,
page=None,
page_size=100,
max_pages=None,
sort=None,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/units.py
list_localities ¶
list_localities(
parent_id,
page=None,
page_size=100,
max_pages=None,
sort=None,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/units.py
get_locality ¶
get_locality(
locality_id,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/units.py
search_localities ¶
search_localities(
name=None,
years=None,
page=None,
page_size=100,
max_pages=None,
sort=None,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/units.py
get_units_metadata ¶
get_units_metadata(
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/units.py
alist_units
async
¶
alist_units(
parent_id=None,
level=None,
page=None,
page_size=100,
max_pages=None,
sort=None,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/units.py
aget_unit
async
¶
aget_unit(
unit_id,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/units.py
asearch_units
async
¶
asearch_units(
name=None,
level=None,
years=None,
kind=None,
page=None,
page_size=100,
max_pages=None,
sort=None,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/units.py
alist_localities
async
¶
alist_localities(
parent_id,
page=None,
page_size=100,
max_pages=None,
sort=None,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/units.py
aget_locality
async
¶
aget_locality(
locality_id,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/units.py
asearch_localities
async
¶
asearch_localities(
name=None,
years=None,
page=None,
page_size=100,
max_pages=None,
sort=None,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/units.py
aget_units_metadata
async
¶
aget_units_metadata(
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/units.py
close ¶
aclose
async
¶
__enter__ ¶
__exit__ ¶
__aenter__
async
¶
__aexit__
async
¶
fetch_all_results ¶
fetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[False] = False,
show_progress: bool = True,
) -> list[dict[str, Any]]
fetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[True],
show_progress: bool = True,
) -> tuple[list[dict[str, Any]], dict[str, Any]]
fetch_all_results(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
return_metadata=False,
show_progress=True,
)
Fetch paginated results synchronously and combine them into a single list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
method
|
str
|
HTTP method (default: GET). |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
results_key
|
str
|
Key for extracting data from each page. |
'results'
|
page_size
|
int
|
Items per page. |
100
|
max_pages
|
int | None
|
Optional limit of pages. |
None
|
return_metadata
|
bool
|
If True, return (results, metadata). |
False
|
show_progress
|
bool
|
Display progress via tqdm. |
True
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]]
|
Combined list of results, optionally with metadata. |
Source code in pybdl/api/client.py
fetch_all_results_with_metadata ¶
fetch_all_results_with_metadata(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
show_progress=True,
)
Source code in pybdl/api/client.py
fetch_single_result ¶
fetch_single_result(
endpoint: str,
*,
results_key: None = None,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> dict[str, Any]
fetch_single_result(
endpoint: str,
*,
results_key: str,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> list[dict[str, Any]]
fetch_single_result(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
return_metadata=False,
)
Fetch a single result, non-paginated (sync).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
results_key
|
str | None
|
If not None, extract this key from the JSON. |
None
|
method
|
str
|
HTTP method. |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
return_metadata
|
bool
|
Also return metadata if True. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | list[dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]] | tuple[dict[str, Any], dict[str, Any]]
|
Dictionary or list, optionally with separate metadata. |
Source code in pybdl/api/client.py
fetch_single_result_with_metadata ¶
fetch_single_result_with_metadata(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
)
Source code in pybdl/api/client.py
afetch_all_results
async
¶
afetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[False] = False,
show_progress: bool = True,
) -> list[dict[str, Any]]
afetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[True],
show_progress: bool = True,
) -> tuple[list[dict[str, Any]], dict[str, Any]]
afetch_all_results(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
return_metadata=False,
show_progress=True,
)
Asynchronously fetch paginated results and combine them into a single list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
method
|
str
|
HTTP method (default: GET). |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
results_key
|
str
|
Key for extracting data from each page. |
'results'
|
page_size
|
int
|
Items per page. |
100
|
max_pages
|
int | None
|
Optional limit of pages. |
None
|
return_metadata
|
bool
|
If True, return (results, metadata). |
False
|
show_progress
|
bool
|
Display progress via tqdm. |
True
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]]
|
Combined list of results, optionally with metadata. |
Source code in pybdl/api/client.py
afetch_all_results_with_metadata
async
¶
afetch_all_results_with_metadata(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
show_progress=True,
)
Source code in pybdl/api/client.py
afetch_single_result
async
¶
afetch_single_result(
endpoint: str,
*,
method: str = "GET",
results_key: Literal[None] = None,
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> dict[str, Any]
afetch_single_result(
endpoint: str,
*,
results_key: str,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> list[dict[str, Any]]
afetch_single_result(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
return_metadata=False,
)
Asynchronously fetch a single result, non-paginated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
results_key
|
str | None
|
If not None, extract this key from the JSON. |
None
|
method
|
str
|
HTTP method. |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
return_metadata
|
bool
|
Also return metadata if True. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | list[dict[str, Any]] | tuple[dict[str, Any], dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]]
|
Dictionary or list, optionally with separate metadata. |
Source code in pybdl/api/client.py
afetch_single_result_with_metadata
async
¶
afetch_single_result_with_metadata(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
)
Source code in pybdl/api/client.py
Variables¶
variables ¶
VariablesAPI ¶
Bases: BaseAPIClient
Client for the BDL /variables endpoints.
Initialize base API client for BDL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
BDLConfig
|
BDL configuration object. |
required |
extra_headers
|
dict[str, str] | None
|
Optional extra headers (e.g., Accept-Language) to include in requests. |
None
|
Source code in pybdl/api/client.py
session
instance-attribute
¶
session = build_sync_http_client(
cache_backend=cache_backend,
http_cache_db_path=_http_cache_path,
default_headers=default_headers,
proxy=_proxy_url,
)
list_variables ¶
list_variables(
subject_id=None,
level=None,
years=None,
page=None,
page_size=100,
max_pages=None,
sort=None,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/variables.py
get_variable ¶
get_variable(
variable_id,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/variables.py
search_variables ¶
search_variables(
name=None,
subject_id=None,
level=None,
years=None,
page=None,
page_size=100,
max_pages=None,
sort=None,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/variables.py
get_variables_metadata ¶
get_variables_metadata(
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/variables.py
alist_variables
async
¶
alist_variables(
subject_id=None,
level=None,
years=None,
page=None,
page_size=100,
max_pages=None,
sort=None,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/variables.py
aget_variable
async
¶
aget_variable(
variable_id,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/variables.py
asearch_variables
async
¶
asearch_variables(
name=None,
subject_id=None,
level=None,
years=None,
page=None,
page_size=100,
max_pages=None,
sort=None,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/variables.py
aget_variables_metadata
async
¶
aget_variables_metadata(
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/variables.py
close ¶
aclose
async
¶
__enter__ ¶
__exit__ ¶
__aenter__
async
¶
__aexit__
async
¶
fetch_all_results ¶
fetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[False] = False,
show_progress: bool = True,
) -> list[dict[str, Any]]
fetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[True],
show_progress: bool = True,
) -> tuple[list[dict[str, Any]], dict[str, Any]]
fetch_all_results(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
return_metadata=False,
show_progress=True,
)
Fetch paginated results synchronously and combine them into a single list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
method
|
str
|
HTTP method (default: GET). |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
results_key
|
str
|
Key for extracting data from each page. |
'results'
|
page_size
|
int
|
Items per page. |
100
|
max_pages
|
int | None
|
Optional limit of pages. |
None
|
return_metadata
|
bool
|
If True, return (results, metadata). |
False
|
show_progress
|
bool
|
Display progress via tqdm. |
True
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]]
|
Combined list of results, optionally with metadata. |
Source code in pybdl/api/client.py
fetch_all_results_with_metadata ¶
fetch_all_results_with_metadata(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
show_progress=True,
)
Source code in pybdl/api/client.py
fetch_single_result ¶
fetch_single_result(
endpoint: str,
*,
results_key: None = None,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> dict[str, Any]
fetch_single_result(
endpoint: str,
*,
results_key: str,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> list[dict[str, Any]]
fetch_single_result(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
return_metadata=False,
)
Fetch a single result, non-paginated (sync).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
results_key
|
str | None
|
If not None, extract this key from the JSON. |
None
|
method
|
str
|
HTTP method. |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
return_metadata
|
bool
|
Also return metadata if True. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | list[dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]] | tuple[dict[str, Any], dict[str, Any]]
|
Dictionary or list, optionally with separate metadata. |
Source code in pybdl/api/client.py
fetch_single_result_with_metadata ¶
fetch_single_result_with_metadata(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
)
Source code in pybdl/api/client.py
afetch_all_results
async
¶
afetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[False] = False,
show_progress: bool = True,
) -> list[dict[str, Any]]
afetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[True],
show_progress: bool = True,
) -> tuple[list[dict[str, Any]], dict[str, Any]]
afetch_all_results(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
return_metadata=False,
show_progress=True,
)
Asynchronously fetch paginated results and combine them into a single list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
method
|
str
|
HTTP method (default: GET). |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
results_key
|
str
|
Key for extracting data from each page. |
'results'
|
page_size
|
int
|
Items per page. |
100
|
max_pages
|
int | None
|
Optional limit of pages. |
None
|
return_metadata
|
bool
|
If True, return (results, metadata). |
False
|
show_progress
|
bool
|
Display progress via tqdm. |
True
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]]
|
Combined list of results, optionally with metadata. |
Source code in pybdl/api/client.py
afetch_all_results_with_metadata
async
¶
afetch_all_results_with_metadata(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
show_progress=True,
)
Source code in pybdl/api/client.py
afetch_single_result
async
¶
afetch_single_result(
endpoint: str,
*,
method: str = "GET",
results_key: Literal[None] = None,
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> dict[str, Any]
afetch_single_result(
endpoint: str,
*,
results_key: str,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> list[dict[str, Any]]
afetch_single_result(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
return_metadata=False,
)
Asynchronously fetch a single result, non-paginated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
results_key
|
str | None
|
If not None, extract this key from the JSON. |
None
|
method
|
str
|
HTTP method. |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
return_metadata
|
bool
|
Also return metadata if True. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | list[dict[str, Any]] | tuple[dict[str, Any], dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]]
|
Dictionary or list, optionally with separate metadata. |
Source code in pybdl/api/client.py
afetch_single_result_with_metadata
async
¶
afetch_single_result_with_metadata(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
)
Source code in pybdl/api/client.py
Version¶
version ¶
VersionAPI ¶
Bases: BaseAPIClient
Client for the BDL /version endpoint.
Initialize base API client for BDL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
BDLConfig
|
BDL configuration object. |
required |
extra_headers
|
dict[str, str] | None
|
Optional extra headers (e.g., Accept-Language) to include in requests. |
None
|
Source code in pybdl/api/client.py
session
instance-attribute
¶
session = build_sync_http_client(
cache_backend=cache_backend,
http_cache_db_path=_http_cache_path,
default_headers=default_headers,
proxy=_proxy_url,
)
get_version ¶
get_version(
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/version.py
aget_version
async
¶
aget_version(
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/version.py
close ¶
aclose
async
¶
__enter__ ¶
__exit__ ¶
__aenter__
async
¶
__aexit__
async
¶
fetch_all_results ¶
fetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[False] = False,
show_progress: bool = True,
) -> list[dict[str, Any]]
fetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[True],
show_progress: bool = True,
) -> tuple[list[dict[str, Any]], dict[str, Any]]
fetch_all_results(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
return_metadata=False,
show_progress=True,
)
Fetch paginated results synchronously and combine them into a single list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
method
|
str
|
HTTP method (default: GET). |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
results_key
|
str
|
Key for extracting data from each page. |
'results'
|
page_size
|
int
|
Items per page. |
100
|
max_pages
|
int | None
|
Optional limit of pages. |
None
|
return_metadata
|
bool
|
If True, return (results, metadata). |
False
|
show_progress
|
bool
|
Display progress via tqdm. |
True
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]]
|
Combined list of results, optionally with metadata. |
Source code in pybdl/api/client.py
fetch_all_results_with_metadata ¶
fetch_all_results_with_metadata(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
show_progress=True,
)
Source code in pybdl/api/client.py
fetch_single_result ¶
fetch_single_result(
endpoint: str,
*,
results_key: None = None,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> dict[str, Any]
fetch_single_result(
endpoint: str,
*,
results_key: str,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> list[dict[str, Any]]
fetch_single_result(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
return_metadata=False,
)
Fetch a single result, non-paginated (sync).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
results_key
|
str | None
|
If not None, extract this key from the JSON. |
None
|
method
|
str
|
HTTP method. |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
return_metadata
|
bool
|
Also return metadata if True. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | list[dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]] | tuple[dict[str, Any], dict[str, Any]]
|
Dictionary or list, optionally with separate metadata. |
Source code in pybdl/api/client.py
fetch_single_result_with_metadata ¶
fetch_single_result_with_metadata(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
)
Source code in pybdl/api/client.py
afetch_all_results
async
¶
afetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[False] = False,
show_progress: bool = True,
) -> list[dict[str, Any]]
afetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[True],
show_progress: bool = True,
) -> tuple[list[dict[str, Any]], dict[str, Any]]
afetch_all_results(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
return_metadata=False,
show_progress=True,
)
Asynchronously fetch paginated results and combine them into a single list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
method
|
str
|
HTTP method (default: GET). |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
results_key
|
str
|
Key for extracting data from each page. |
'results'
|
page_size
|
int
|
Items per page. |
100
|
max_pages
|
int | None
|
Optional limit of pages. |
None
|
return_metadata
|
bool
|
If True, return (results, metadata). |
False
|
show_progress
|
bool
|
Display progress via tqdm. |
True
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]]
|
Combined list of results, optionally with metadata. |
Source code in pybdl/api/client.py
afetch_all_results_with_metadata
async
¶
afetch_all_results_with_metadata(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
show_progress=True,
)
Source code in pybdl/api/client.py
afetch_single_result
async
¶
afetch_single_result(
endpoint: str,
*,
method: str = "GET",
results_key: Literal[None] = None,
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> dict[str, Any]
afetch_single_result(
endpoint: str,
*,
results_key: str,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> list[dict[str, Any]]
afetch_single_result(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
return_metadata=False,
)
Asynchronously fetch a single result, non-paginated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
results_key
|
str | None
|
If not None, extract this key from the JSON. |
None
|
method
|
str
|
HTTP method. |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
return_metadata
|
bool
|
Also return metadata if True. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | list[dict[str, Any]] | tuple[dict[str, Any], dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]]
|
Dictionary or list, optionally with separate metadata. |
Source code in pybdl/api/client.py
afetch_single_result_with_metadata
async
¶
afetch_single_result_with_metadata(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
)
Source code in pybdl/api/client.py
Years¶
years ¶
YearsAPI ¶
Bases: BaseAPIClient
Client for the BDL /years endpoints.
Initialize base API client for BDL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
BDLConfig
|
BDL configuration object. |
required |
extra_headers
|
dict[str, str] | None
|
Optional extra headers (e.g., Accept-Language) to include in requests. |
None
|
Source code in pybdl/api/client.py
session
instance-attribute
¶
session = build_sync_http_client(
cache_backend=cache_backend,
http_cache_db_path=_http_cache_path,
default_headers=default_headers,
proxy=_proxy_url,
)
list_years ¶
list_years(
sort=None,
page_size=100,
max_pages=None,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/years.py
get_year ¶
get_year(
year_id,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/years.py
get_years_metadata ¶
get_years_metadata(
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/years.py
alist_years
async
¶
alist_years(
sort=None,
page_size=100,
max_pages=None,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/years.py
aget_year
async
¶
aget_year(
year_id,
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/years.py
aget_years_metadata
async
¶
aget_years_metadata(
lang=None,
format=None,
if_none_match=None,
if_modified_since=None,
extra_query=None,
)
Source code in pybdl/api/years.py
close ¶
aclose
async
¶
__enter__ ¶
__exit__ ¶
__aenter__
async
¶
__aexit__
async
¶
fetch_all_results ¶
fetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[False] = False,
show_progress: bool = True,
) -> list[dict[str, Any]]
fetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[True],
show_progress: bool = True,
) -> tuple[list[dict[str, Any]], dict[str, Any]]
fetch_all_results(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
return_metadata=False,
show_progress=True,
)
Fetch paginated results synchronously and combine them into a single list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
method
|
str
|
HTTP method (default: GET). |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
results_key
|
str
|
Key for extracting data from each page. |
'results'
|
page_size
|
int
|
Items per page. |
100
|
max_pages
|
int | None
|
Optional limit of pages. |
None
|
return_metadata
|
bool
|
If True, return (results, metadata). |
False
|
show_progress
|
bool
|
Display progress via tqdm. |
True
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]]
|
Combined list of results, optionally with metadata. |
Source code in pybdl/api/client.py
fetch_all_results_with_metadata ¶
fetch_all_results_with_metadata(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
show_progress=True,
)
Source code in pybdl/api/client.py
fetch_single_result ¶
fetch_single_result(
endpoint: str,
*,
results_key: None = None,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> dict[str, Any]
fetch_single_result(
endpoint: str,
*,
results_key: str,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> list[dict[str, Any]]
fetch_single_result(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
return_metadata=False,
)
Fetch a single result, non-paginated (sync).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
results_key
|
str | None
|
If not None, extract this key from the JSON. |
None
|
method
|
str
|
HTTP method. |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
return_metadata
|
bool
|
Also return metadata if True. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | list[dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]] | tuple[dict[str, Any], dict[str, Any]]
|
Dictionary or list, optionally with separate metadata. |
Source code in pybdl/api/client.py
fetch_single_result_with_metadata ¶
fetch_single_result_with_metadata(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
)
Source code in pybdl/api/client.py
afetch_all_results
async
¶
afetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[False] = False,
show_progress: bool = True,
) -> list[dict[str, Any]]
afetch_all_results(
endpoint: str,
*,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
results_key: str = "results",
page_size: int = 100,
max_pages: int | None = None,
return_metadata: Literal[True],
show_progress: bool = True,
) -> tuple[list[dict[str, Any]], dict[str, Any]]
afetch_all_results(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
return_metadata=False,
show_progress=True,
)
Asynchronously fetch paginated results and combine them into a single list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
method
|
str
|
HTTP method (default: GET). |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
results_key
|
str
|
Key for extracting data from each page. |
'results'
|
page_size
|
int
|
Items per page. |
100
|
max_pages
|
int | None
|
Optional limit of pages. |
None
|
return_metadata
|
bool
|
If True, return (results, metadata). |
False
|
show_progress
|
bool
|
Display progress via tqdm. |
True
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]]
|
Combined list of results, optionally with metadata. |
Source code in pybdl/api/client.py
afetch_all_results_with_metadata
async
¶
afetch_all_results_with_metadata(
endpoint,
*,
method="GET",
params=None,
headers=None,
results_key="results",
page_size=100,
max_pages=None,
show_progress=True,
)
Source code in pybdl/api/client.py
afetch_single_result
async
¶
afetch_single_result(
endpoint: str,
*,
method: str = "GET",
results_key: Literal[None] = None,
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> dict[str, Any]
afetch_single_result(
endpoint: str,
*,
results_key: str,
method: str = "GET",
params: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
return_metadata: Literal[False] = False,
) -> list[dict[str, Any]]
afetch_single_result(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
return_metadata=False,
)
Asynchronously fetch a single result, non-paginated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint. |
required |
results_key
|
str | None
|
If not None, extract this key from the JSON. |
None
|
method
|
str
|
HTTP method. |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
headers
|
dict[str, str] | None
|
Optional request headers. |
None
|
return_metadata
|
bool
|
Also return metadata if True. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | list[dict[str, Any]] | tuple[dict[str, Any], dict[str, Any]] | tuple[list[dict[str, Any]], dict[str, Any]]
|
Dictionary or list, optionally with separate metadata. |
Source code in pybdl/api/client.py
afetch_single_result_with_metadata
async
¶
afetch_single_result_with_metadata(
endpoint,
*,
results_key=None,
method="GET",
params=None,
headers=None,
)