Skip to content

client

Heurist API client

Classes:

HeuristAPIClient

HeuristAPIClient(database_name: str, session: Session)

Client for Heurist API.

Methods:

  • get_records

    Request all records of a certain type and in a certain data format.

  • get_response_content

    Request resources from the Heurist server.

  • get_structure

    Request the Heurist database's overall structure in XML format.

get_records

get_records(
    record_type_id: int,
    form: Literal["xml", "json"] = "json",
    users: tuple[int] = (),
) -> bytes | list | None

Request all records of a certain type and in a certain data format.

Parameters:

  • record_type_id

    (int) –

    Heurist ID of targeted record type.

  • form

    (Literal['xml', 'json'], default: 'json' ) –

    Data format for requested records. Defaults to "json".

  • users

    (tuple, default: () ) –

    Array of IDs of users who added the target records.

Returns:

  • bytes | list | None

    bytes | list | None: If XML, binary response returned from Heurist server, else JSON array.

get_response_content

get_response_content(url: str) -> ByteString | None

Request resources from the Heurist server.

Parameters:

  • url

    (str) –

    Heurist API entry point.

Returns:

  • ByteString | None

    ByteString | None: Binary response returned from Heurist server.

get_structure

get_structure() -> bytes | None

Request the Heurist database's overall structure in XML format.

Returns:

  • bytes | None

    bytes | list | None: If XML, binary response returned from Heurist server,

  • bytes | None

    else JSON array.