Skip to content

Resource ElectionResource

CrucifiedPain edited this page Jun 26, 2026 · 10 revisions

ElectionResource (client.election)

Endpoints: • election.getElections (cursor-paginated)

.collect_all()

Fetch all items across all pages concurrently using parallel time-slicing.

Signature

await client.election.collect_all(**kwargs: 'typing.Any') -> 'list[Election]'

Parameters

Name Type Default
kwargs Any *Required*

Return Models

Election

An election event in a country.

Field Type Required Description
_id string Optional
__v integer Optional
country string Optional The UUID of the country this user holds citizenship in.
electedCandidates array[string] Optional
isActive boolean Optional
type string Optional The type.
candidates array[ElectionCandidate] Optional The candidates.
votesStartAt string Optional
votesEndAt string Optional
votesCount integer Optional
electedCount integer Optional
createdAt string Optional The timestamp when this record was created.
status string Optional The status.
votes object Optional The votes.

ElectionCandidate

A candidate in an election.

Field Type Required Description
user string Optional
voteCount integer Optional
article string Optional
party string Optional
isElected boolean Optional

.get_by_country()

Convenience: fetch all elections in a given country.

Signature

await client.election.get_by_country(country_id: 'str') -> 'list[Election]'

Parameters

Name Type Default
country_id str *Required*

Return Models

Election

An election event in a country.

Field Type Required Description
_id string Optional
__v integer Optional
country string Optional The UUID of the country this user holds citizenship in.
electedCandidates array[string] Optional
isActive boolean Optional
type string Optional The type.
candidates array[ElectionCandidate] Optional The candidates.
votesStartAt string Optional
votesEndAt string Optional
votesCount integer Optional
electedCount integer Optional
createdAt string Optional The timestamp when this record was created.
status string Optional The status.
votes object Optional The votes.

ElectionCandidate

A candidate in an election.

Field Type Required Description
user string Optional
voteCount integer Optional
article string Optional
party string Optional
isElected boolean Optional

.get_paginated()

Get elections (cursor-paginated), optionally filtered by country.

Args: country_id: Filter to elections in this country. direction: "forward" (default) or "backward" pagination.

Signature

await client.election.get_paginated(*, country_id: 'str | None' = None, limit: 'int' = 20, cursor: 'str | None' = None, direction: 'str | None' = None, auto_items: 'bool' = False, max_pages: 'int | float' = inf, cursor_end: 'str | None' = None) -> 'CursorPage[Election] | AsyncIterator[Election]'

Parameters

Name Type Default
country_id str None
limit int 20
cursor str None
direction str None
auto_items bool False
max_pages int | float inf
cursor_end str None

Return Models

CursorPage[Election]

Field Type Required Description
_id string Optional
__v integer Optional
items array[Election] Required
nextCursor string Optional
hasMore boolean Optional

Election

An election event in a country.

Field Type Required Description
_id string Optional
__v integer Optional
country string Optional The UUID of the country this user holds citizenship in.
electedCandidates array[string] Optional
isActive boolean Optional
type string Optional The type.
candidates array[ElectionCandidate] Optional The candidates.
votesStartAt string Optional
votesEndAt string Optional
votesCount integer Optional
electedCount integer Optional
createdAt string Optional The timestamp when this record was created.
status string Optional The status.
votes object Optional The votes.

ElectionCandidate

A candidate in an election.

Field Type Required Description
user string Optional
voteCount integer Optional
article string Optional
party string Optional
isElected boolean Optional

.invalidate_cache()

Clear the SWR cache for all resources.

Signature

await client.election.invalidate_cache() -> 'None'

Clone this wiki locally