API reference
Package
Python client for the SAP BusinessObjects Web Intelligence API (EFS).
Standalone functions (boapi.api)
Functions to query a BusinessObjects document and export it to a file.
Credentials are read from .env. The output format is taken from the file
extension (.parquet, .csv, .json).
- boapi.api.describe_document_parameters(doc_id: str, env: str | None = None) Dict[str, List[Dict]][source]
Describe the filter parameters of a document.
Connects using
.envcredentials. Returns the parameters per dataprovider.
- boapi.api.generate_export_config(doc_id: str, env: str | None = None, output: str | None = None, chunk_size: int = 10000, date_format: str = '%d/%m/%Y', with_columns: bool = False) str[source]
Build a YAML export config skeleton for a document.
Reads the document parameters and returns YAML text ready to be saved. Filters are keyed by parameter id, with the parameter name kept as a comment and a placeholder value. DateTime parameters get a placeholder ISO value. When
with_columnsis set, the column names declared by the document dataproviders are appended as commented entries so that unlisted columns stay under pandas inference.- Parameters:
doc_id (str) – Document identifier
env (Optional[str]) – Optional environment suffix for
.envoutput (Optional[str]) – Output path written under the
outputkey, optionalchunk_size (int) – Value written under the
chunk_sizekeydate_format (str) – Value written under the
date_formatkeywith_columns (bool) – List the document column names from the dataprovider dictionary (no data fetch)
- Returns:
YAML configuration text
- Return type:
- boapi.api.export_document(doc_id: str, output: str, params: Dict[str, Any] | None = None, env: str | None = None, refresh: bool | None = None, **kwargs) str[source]
Query a document and export it to a file.
Connects using
.envcredentials. Refreshes the document whenparamsis given. The output format is taken from theoutputextension (.parquet,.csv,.json).- Parameters:
doc_id (str) – Document identifier
output (str) – Output file path; its extension selects the format
params (Optional[Dict[str, Any]]) – Filter parameters as
{name: value}; triggers a refreshenv (Optional[str]) – Optional environment suffix for
.envrefresh (Optional[bool]) – Force (True) or disable (False) the refresh; when None, refresh only if
paramsis providedkwargs – Options forwarded to the export (e.g.
chunk_size,date_format)
- Returns:
Path of the created file
- Return type:
- boapi.api.export_from_config(config_path, env: str | None = None, output: str | None = None, **kwargs) str[source]
Export a document from a YAML configuration file.
Reads the doc_id, filters and column typing from the YAML, refreshes the document when filters are present, then exports it. Column typing applies to
.parquetand.jsonoutputs.- Parameters:
- Returns:
Path of the created file
- Return type:
- Raises:
ValueError – If no output path is provided
YAML configuration (boapi.config)
YAML export configuration for a BusinessObjects document.
A single YAML file describes the document id, the BO filters and the output
column typing for one export. The file is loaded into a plain dictionary used
by boapi.api.export_from_config().
Schema:
doc_id: # scalar, or a mapping by environment
dev: 123456
prod: 123456
output: out.parquet # optional, output file path
chunk_size: 10000 # optional, rows per chunk for Parquet
dataprovider: s_lieuprel # optional, dataprovider targeted by the filters
date_format: "%d/%m/%Y" # optional, default format for datetime columns
filters: # optional, BO parameters by parameter id
'0': ['2026-04-24']
'1': ['2026-05-01']
'2': [AURA, IDFR]
columns: # optional, typing and renaming
id_lieu_prel: str # shorthand: type only
lat: {type: float}
date_prel: {rename: date_prelevement, type: datetime, format: "%d/%m/%Y"}
- boapi.config.load_export_config(config_path, env: str | None = None) Dict[str, Any][source]
Load a YAML export configuration.
- Parameters:
config_path – Path to the YAML file
env (Optional[str]) – Environment name used to resolve doc_id when defined per env
- Returns:
Configuration with keys doc_id, output, chunk_size, dataprovider, date_format, filters, column_mapping
- Return type:
Dict[str, Any]
- Raises:
FileNotFoundError – If the file does not exist
.env credentials (boapi.credentials)
BusinessObjects connection settings loaded from .env files.
- boapi.credentials.load_bo_config(env: str | None = None) Dict[str, str | None][source]
Load BusinessObjects connection settings from
.envfiles.Values are read from
~/.envthen the local.env, the latter taking precedence. Expected variables:BO_BASE_URL,BO_USER,BO_PASSWORDand optionallyBO_AUTH_TYPE(defaultsecEnterprise). Whenenvis given, the suffixed variant (e.g.BO_BASE_URL_PROD) is used if present, otherwise the unsuffixed variable.
Low-level client (boapi.client)
Main client for the BusinessObjects Web Intelligence API.
Defines the BOAPIClient class, the entry point for API operations with session handling.
- class boapi.client.BOAPIClient(base_url: str, user: str, auth_type: str = 'secEnterprise')[source]
Bases:
objectClient for the BusinessObjects Web Intelligence API.
Handles connection and authentication, and delegates operations to the managers. Implements the context manager protocol to close the session on exit.
- Variables:
cache – Cache manager
reports – Reports manager
dataproviders – Dataproviders manager
refresh – Refresh manager
export – Export manager
Example:
with BOAPIClient(base_url, "user") as client: if client.connect(): df = client.get_dataframe("123456")
- get_headers(accept: str = 'application/json', use_quotes: bool = True) dict[source]
Build the HTTP headers with authentication.
The token may be wrapped in quotes depending on the endpoint. The raylight API requires use_quotes=False.
- Parameters:
- Returns:
HTTP headers dictionary
- Return type:
- Raises:
ConnectionError – If not connected
- get_dataframe(doc_id: str, separator: str = None, use_cache: bool = True, debug: bool = False, **kwargs)[source]
Retrieve the data of a document as a DataFrame.
Delegates to the export manager.
- save_to_parquet(doc_id: str, output_path: str, use_cache: bool = True, **kwargs)[source]
Save the data to Parquet format.
- save_to_csv(doc_id: str, output_path: str, use_cache: bool = True)[source]
Save the data to CSV format.
- save_to_json(doc_id: str, output_path: str, use_cache: bool = True, orient: str = 'records', **kwargs)[source]
Save the data to JSON format.
- list_dataproviders(doc_id: str, show_details: bool = True)[source]
List the dataproviders of a document.
- describe_parameters(doc_id: str)[source]
Describe the filter parameters of a document, grouped by dataprovider.
Delegates to the dataproviders manager.
Managers
BusinessObjects dataprovider management.
A dataprovider is the data source feeding a Web Intelligence document. It holds a query with its dimensions, measures and parameters.
- class boapi.dataproviders.DataProvidersManager(client: BOAPIClient)[source]
Bases:
objectManager for the dataproviders of a document.
Dataproviders represent the data sources with their queries, dimensions, measures and filter parameters.
- get_dataprovider_detail(doc_id: str, dp_id: str) Dict[source]
Return the full details of a dataprovider.
- list_dataproviders(doc_id: str, show_details: bool = True, show_parameters: bool = False) List[Dict][source]
Print the list of dataproviders of a document.
- get_dataprovider_parameters(doc_id: str, dp_id: str) List[Dict][source]
Return the parameters of a dataprovider.
- build_lov_map(doc_id: str, dp_id: str) Dict[str, Dict[str, str]][source]
Build a mapping from LOV values to their identifiers.
LOV (List of Values) parameters require a mapping between text values and their internal identifiers.
- Parameters:
- Returns:
Mapping {param_id: {value: lov_id}}
- Return type:
Example:
{"2": {"IDFR": "67", "AURA": "59"}}
- describe_parameters(doc_id: str) Dict[str, List[Dict]][source]
Describe the filter parameters of a document, grouped by dataprovider.
For each dataprovider, returns its parameters with their metadata: name, internal identifier, type, cardinality, mandatory flag and, for LOV (List of Values) parameters, the list of allowed values.
Export of BusinessObjects data to Parquet, CSV or JSON, with chunked processing for large volumes.
- class boapi.export.ExportManager(client: BOAPIClient)[source]
Bases:
objectManager for data exports.
Exports data to a pandas DataFrame, CSV, Parquet or JSON with column mapping and automatic typing.
- get_csv_from_zip(zip_content: bytes) str[source]
Extract the CSV content from an in-memory ZIP archive.
- get_raw_data(doc_id: str, use_cache: bool = True) str[source]
Retrieve the raw data as CSV.
Downloads the data from the API and keeps it in memory. Automatically extracts from a ZIP archive when needed.
- get_dataframe(doc_id: str, separator: str = None, use_cache: bool = True, debug: bool = False, apply_mapping: bool = True, mapping_file: str | None = None, date_format: str | None = None) pandas.DataFrame[source]
Retrieve the data and convert it to a DataFrame.
Downloads the data, auto-detects the CSV separator and applies the column mapping with typing.
- Parameters:
doc_id (str) – Document identifier
separator (str) – CSV separator, auto-detected if None
use_cache (bool) – Enable cache usage
debug (bool) – Enable debug output
apply_mapping (bool) – Enable column mapping and typing
mapping_file (Optional[str]) – Path to the mapping file, optional
date_format (Optional[str]) – Date format used for datetime columns, optional
- Returns:
DataFrame with the data
- Return type:
pd.DataFrame
- Raises:
Exception – If CSV parsing fails
- save_to_parquet(doc_id: str, output_path: str, use_cache: bool = True, apply_mapping: bool = True, mapping_file: str | None = None, chunk_size: int | None = None, date_format: str | None = None, **kwargs) str[source]
Save the data to Parquet format.
Converts and saves the data with compression. If chunk_size is given, processes the data in batches to optimize memory usage.
- Parameters:
doc_id (str) – Document identifier
output_path (str) – Output file path
use_cache (bool) – Enable cache usage
apply_mapping (bool) – Enable column mapping
mapping_file (Optional[str]) – Path to the mapping file, optional
chunk_size (Optional[int]) – Chunk size for batch processing
date_format (Optional[str]) – Date format used for datetime columns, optional
kwargs – Extra arguments for to_parquet
- Returns:
Path of the created file
- Return type:
- save_to_csv(doc_id: str, output_path: str, use_cache: bool = True) str[source]
Save the data to CSV format.
- save_to_json(doc_id: str, output_path: str, use_cache: bool = True, apply_mapping: bool = True, mapping_file: str | None = None, date_format: str | None = None, orient: str = 'records') str[source]
Save the data to JSON format.
- Parameters:
doc_id (str) – Document identifier
output_path (str) – Output file path
use_cache (bool) – Enable cache usage
apply_mapping (bool) – Enable column mapping
mapping_file (Optional[str]) – Path to the mapping file, optional
date_format (Optional[str]) – Date format used for datetime columns, optional
orient (str) – JSON format (records, split, index, columns, values, table)
- Returns:
Path of the created file
- Return type:
Refresh of BusinessObjects dataproviders by re-running their queries with the applied parameters and filters.
- class boapi.refresh.RefreshManager(client: BOAPIClient)[source]
Bases:
objectManager for dataprovider refresh.
Re-runs dataprovider queries with applied filter parameters.
- refresh_dataprovider(doc_id: str, dp_id: str, parameters: Dict | None = None)[source]
Refresh a dataprovider with optional parameters.
Re-runs the dataprovider query applying the given filter parameters. LOV parameters are handled automatically.
- refresh_document(doc_id: str, dataprovider_names: List[str] | None = None, refresh_all: bool = False, verbose: bool = True, parameters: Dict[str, Dict] | None = None) Dict[source]
Refresh the dataproviders of a document.
Refreshes all dataproviders or a selection, applying per-dataprovider parameters.
- Parameters:
doc_id (str) – Document identifier
dataprovider_names (Optional[List[str]]) – Names of the dataproviders to refresh
refresh_all (bool) – Refresh all dataproviders if True
verbose (bool) – Enable detail output
parameters (Optional[Dict[str, Dict]]) – Per-dataprovider parameters as {“DP_NAME”: {“param_id”: [“value”]}}
- Returns:
Dictionary with success, failed and skipped lists
- Return type:
Dict
Report enumeration and metadata for Web Intelligence documents.
- class boapi.reports.ReportsManager(client: BOAPIClient)[source]
Bases:
objectManager for the reports of a BusinessObjects document.
Reports correspond to the views and tables configured in Web Intelligence documents.
In-memory cache for raw CSV data, to avoid repeated downloads.
- class boapi.cache.CacheManager[source]
Bases:
objectIn-memory cache for CSV data.
The cache stores raw data to avoid querying the API several times for the same document.
Utilities (boapi.utils)
Formatting, validation and type-conversion helpers for the export pipeline.
- boapi.utils.format_size(size_bytes: int) str[source]
Format a size in bytes for human-readable display.
- Parameters:
size_bytes (int) – Size in bytes
- Returns:
Formatted size (e.g. “1.5 MB”, “234 KB”)
- Return type:
Example:
>>> format_size(1536) "1.50 KB" >>> format_size(1048576) "1.00 MB"
- boapi.utils.validate_doc_id(doc_id: str) bool[source]
Validate a BusinessObjects document identifier.
- Parameters:
doc_id (str) – Identifier to validate
- Returns:
True if the identifier is valid
- Return type:
Example:
>>> validate_doc_id("123456") True >>> validate_doc_id("") False
- boapi.utils.parse_bo_error(response_data: dict) str[source]
Extract and format an error message from the API.
- Parameters:
response_data (dict) – JSON data of the error response
- Returns:
Formatted error message
- Return type:
Example:
>>> error = {"error_code": "ERR_WIS_30270", "message": "Invalid session"} >>> parse_bo_error(error) "BO error ERR_WIS_30270: Invalid session"
- boapi.utils.truncate_string(text: str, max_length: int = 100, suffix: str = '...') str[source]
Truncate a string if it exceeds the maximum length.
- Parameters:
- Returns:
Truncated text if needed
- Return type:
Example:
>>> truncate_string("A very long text", max_length=10) "A very ..."
- boapi.utils.load_column_mapping(mapping_file=None) dict[source]
Load the column mapping configuration.
Accepts a path to a JSON file or an already-built mapping dictionary.
- Parameters:
mapping_file – Path to the JSON file, a mapping dict, or None to use column_mapping.json
- Returns:
Mapping configuration dictionary
- Return type:
Example:
>>> mapping = load_column_mapping() >>> mapping['Code INSEE']['normalized_name'] 'insee_code'
- boapi.utils.get_dtype_dict(mapping_file: str | None = None) dict[source]
Build a dtype dictionary for pd.read_csv().
Forces columns that must preserve their format (codes with leading zeros, categories, booleans, dates, integers) to load as str. Floats are left to pandas to handle decimal=’,’ and thousands=’ ‘.
The final conversion to the target type is done by apply_column_mapping().
- Parameters:
mapping_file (Optional[str]) – Path to the mapping file, optional
- Returns:
Mapping {original_column_name: pandas_dtype}
- Return type:
Example:
>>> dtype_dict = get_dtype_dict() >>> dtype_dict['Code Postal'] str >>> dtype_dict['Code INSEE'] str
- boapi.utils.apply_column_mapping(df: pandas.DataFrame, mapping_file=None, date_format: str | None = None) pandas.DataFrame[source]
Apply the column mapping and type conversions.
Renames columns according to normalized_name and converts types according to python_type. A per-column date_format overrides the global one. Columns absent from the mapping are left unchanged.
- Parameters:
df (pd.DataFrame) – DataFrame to transform
mapping_file – Path to the mapping file, a mapping dict, or None
date_format (Optional[str]) – Default date format for datetime columns, optional
- Returns:
DataFrame with renamed and typed columns
- Return type:
pd.DataFrame
Example:
>>> df = pd.DataFrame({'Code INSEE': ['01234', '56789']}) >>> df_mapped = apply_column_mapping(df) >>> 'insee_code' in df_mapped.columns True