ResultContainer API Reference#

Complete API reference for the ResultContainer class.

class bfabric.results.result_container.ResultContainer(results: list[ApiResponseObjectType], total_pages_api: int | None, errors: list[BfabricRequestError])#

Bases: object

Container structure for query results.

assert_success() None#

Asserts that the query was successful. Raises a RuntimeError if it was not.

property errors: list[BfabricRequestError]#

List of errors that occurred during the query. An empty list indicates success.

extend(other: ResultContainer, reset_total_pages_api: bool = False) None#

Merges the results of other into this container. :param other: The container whose elements to append to the end of this container :param reset_total_pages_api: If True, the total_pages_api attribute will be reset to None

get_first_n_results(n_results: int | None) ResultContainer#

Returns a shallow copy of self, containing at most n_results results.

property is_success: bool#

Whether the query was successful.

to_list_dict(drop_empty: bool = False) list[ApiResponseObjectType]#

Converts the results to a list of dictionaries. :param drop_empty: If True, empty attributes will be removed from the results

to_polars(drop_empty: bool = False, flatten: bool = False) polars.DataFrame#

Returns the results as a polars DataFrame. :param drop_empty: If True, empty attributes will be removed from the results :param flatten: If True, flatten struct columns into individual columns

property total_pages_api: int | None#

Number of pages available from the API.

Overview#

ResultContainer is returned by Bfabric read operations and provides:

  • List-like interface: Iterate over results with indexing

  • Error tracking: Check if operations succeeded

  • Pagination information: Total pages available

  • Conversion methods: Export to various formats (list, Polars DataFrame)

See Also#