Skip to content

Exports

exports

Service class for handling data exports from Kaleidoscope.

This class provides methods to export and download data from the Kaleidoscope API, specifically for pulling record search data and saving it as CSV files.

Classes:

Name Description
ExportsService

Service class for exporting and downloading record search data as CSV.

Example
    # Pull data and download as CSV
    file_path = client.exports_service.pull_data(
        filename="my_export.csv",
        entity_slice_id="some-uuid",
        download_path="/path/to/downloads",
        search_text="example"
    )

ExportsService

ExportsService(client: KaleidoscopeClient)

Service class for handling data exports from Kaleidoscope.

This class provides methods to export and download data from the Kaleidoscope API, specifically for pulling record search data and saving it as CSV files.

Example
# Pull data and download as CSV
file_path = client.exports_service.pull_data(
    filename="my_export.csv",
    entity_slice_id="some-uuid",
    download_path="/path/to/downloads",
    search_text="example"
)

Methods:

Name Description
pull_data

Pull record search data and download it as a CSV file.

Source code in kalpy/exports.py
44
45
def __init__(self, client: "KaleidoscopeClient"):
    self._client = client

pull_data

pull_data(filename: str, entity_slice_id: str, download_path: str | None = None, record_view_id: str | None = None, view_field_ids: str | None = None, identifier_ids: str | None = None, record_set_id: str | None = None, program_id: str | None = None, operation_id: str | None = None, record_set_filters: str | None = None, view_field_filters: str | None = None, view_field_sorts: str | None = None, entity_field_filters: str | None = None, entity_field_sorts: str | None = None, search_text: str | None = None) -> str | None

Pull record search data and download it as a CSV file.

This method interacts with the Kaleidoscope API to export records as a CSV file based on the provided parameters. It supports filtering, sorting, and searching records, and allows specifying various identifiers and filters to customize the export.

Parameters:

Name Type Description Default
filename str

The name of the CSV file to be downloaded.

required
entity_slice_id str

The ID of the entity slice to export records from.

required
download_path str

The directory path where the CSV file will be saved. Defaults to None (uses '/tmp').

None
record_view_id str

The ID of the record view to filter records. Defaults to None.

None
view_field_ids str

Comma-separated IDs of view fields to include in the export. Defaults to None.

None
identifier_ids str

Comma-separated IDs of identifiers to filter records. Defaults to None.

None
record_set_id str

The ID of the record set to filter records. Defaults to None.

None
program_id str

The ID of the program to filter records. Defaults to None.

None
operation_id str

The ID of the operation to filter records. Defaults to None.

None
record_set_filters str

Filters to apply to the record set. Defaults to None.

None
view_field_filters str

Filters to apply to view fields. Defaults to None.

None
view_field_sorts str

Sorting options for view fields. Defaults to None.

None
entity_field_filters str

Filters to apply to entity fields. Defaults to None.

None
entity_field_sorts str

Sorting options for entity fields. Defaults to None.

None
search_text str

Text to search within records. Defaults to None.

None

Returns:

Type Description
str | None

The file path of the downloaded CSV file, or None if not successful.

API Reference

https://kaleidoscope.readme.io/reference/get_records-export-csv

Source code in kalpy/exports.py
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
def pull_data(
    self,
    filename: str,
    entity_slice_id: str,
    download_path: Optional[str] = None,
    record_view_id: Optional[str] = None,
    view_field_ids: Optional[str] = None,
    identifier_ids: Optional[str] = None,
    record_set_id: Optional[str] = None,
    program_id: Optional[str] = None,
    operation_id: Optional[str] = None,
    record_set_filters: Optional[str] = None,
    view_field_filters: Optional[str] = None,
    view_field_sorts: Optional[str] = None,
    entity_field_filters: Optional[str] = None,
    entity_field_sorts: Optional[str] = None,
    search_text: Optional[str] = None,
) -> str | None:
    """Pull record search data and download it as a CSV file.

    This method interacts with the Kaleidoscope API to export records as a CSV file based on the provided parameters.
    It supports filtering, sorting, and searching records, and allows specifying various identifiers and filters
    to customize the export.

    Args:
        filename (str): The name of the CSV file to be downloaded.
        entity_slice_id (str): The ID of the entity slice to export records from.
        download_path (str, optional): The directory path where the CSV file will be saved. Defaults to None (uses '/tmp').
        record_view_id (str, optional): The ID of the record view to filter records. Defaults to None.
        view_field_ids (str, optional): Comma-separated IDs of view fields to include in the export. Defaults to None.
        identifier_ids (str, optional): Comma-separated IDs of identifiers to filter records. Defaults to None.
        record_set_id (str, optional): The ID of the record set to filter records. Defaults to None.
        program_id (str, optional): The ID of the program to filter records. Defaults to None.
        operation_id (str, optional): The ID of the operation to filter records. Defaults to None.
        record_set_filters (str, optional): Filters to apply to the record set. Defaults to None.
        view_field_filters (str, optional): Filters to apply to view fields. Defaults to None.
        view_field_sorts (str, optional): Sorting options for view fields. Defaults to None.
        entity_field_filters (str, optional): Filters to apply to entity fields. Defaults to None.
        entity_field_sorts (str, optional): Sorting options for entity fields. Defaults to None.
        search_text (str, optional): Text to search within records. Defaults to None.

    Returns:
        (str | None): The file path of the downloaded CSV file, or None if not successful.

    API Reference:
        https://kaleidoscope.readme.io/reference/get_records-export-csv
    """

    params = {
        "filename": filename,
        "entity_slice_id": entity_slice_id,
    }

    optional_params = {
        "record_view_id": record_view_id,
        "view_field_ids": view_field_ids,
        "identifier_ids": identifier_ids,
        "record_set_id": record_set_id,
        "program_id": program_id,
        "operation_id": operation_id,
        "record_set_filters": record_set_filters,
        "view_field_filters": view_field_filters,
        "view_field_sorts": view_field_sorts,
        "entity_field_filters": entity_field_filters,
        "entity_field_sorts": entity_field_sorts,
        "search_text": search_text,
    }

    params.update(
        {key: value for key, value in optional_params.items() if value is not None}
    )

    url = "/records/export/csv"
    file = self._client._get_file(
        url,
        f"{download_path if download_path else "/tmp"}/{filename}",
        params,
    )

    return file