Serialization

Request and response models.

APIRequest

class civicrm_py.APIRequest[source]

Bases: Struct

Base structure for CiviCRM API v4 requests.

select

Fields to return (default: all).

Type:

list[str] | None

where

Filter conditions as list of [field, operator, value].

Type:

list[list[Any]] | None

orderBy

Sort order as dict of field: direction.

Type:

dict[str, str] | None

limit

Maximum number of records to return.

Type:

int | None

offset

Number of records to skip.

Type:

int | None

join

Related entities to join.

Type:

list[list[Any]] | None

groupBy

Fields to group by.

Type:

list[str] | None

having

Having clause for aggregations.

Type:

list[list[Any]] | None

select: list[str] | None
where: list[list[Any]] | None
orderBy: dict[str, str] | None
limit: int | None
offset: int | None
join: list[list[Any]] | None
groupBy: list[str] | None
having: list[list[Any]] | None
values: dict[str, Any] | None
chain: dict[str, Any] | None

APIResponse

class civicrm_py.APIResponse[source]

Bases: Struct, Generic[T]

CiviCRM API v4 response structure.

values

List of returned entities.

Type:

list[civicrm_py.core.serialization.T] | None

count

Total count of matching records.

Type:

int | None

countFetched

Number of records actually returned.

Type:

int | None

error_code

Error code if request failed.

Type:

int | str | None

error_message

Error message if request failed.

Type:

str | None

values: list[T] | None
count: int | None
countFetched: int | None
error_code: int | str | None
error_message: str | None
property is_error: bool

Check if response indicates an error.

property first: T | None

Get first value from response or None.