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 \| null
__v integer \| null
country string \| null
electedCandidates array[string] \| null
isActive boolean \| null
type string \| null
candidates array[ElectionCandidate] \| null
votesStartAt string \| null
votesEndAt string \| null
votesCount integer \| null
electedCount integer \| null
createdAt string \| null
status string \| null
votes object \| null

ElectionCandidate

A candidate in an election.

Field Type Required Description
user string \| null
voteCount integer \| null
article string \| null
party string \| null
isElected boolean \| null

.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 \| null
__v integer \| null
country string \| null
electedCandidates array[string] \| null
isActive boolean \| null
type string \| null
candidates array[ElectionCandidate] \| null
votesStartAt string \| null
votesEndAt string \| null
votesCount integer \| null
electedCount integer \| null
createdAt string \| null
status string \| null
votes object \| null

ElectionCandidate

A candidate in an election.

Field Type Required Description
user string \| null
voteCount integer \| null
article string \| null
party string \| null
isElected boolean \| null

.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 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

Return Models

CursorPage[Election]

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

Election

An election event in a country.

Field Type Required Description
_id string \| null
__v integer \| null
country string \| null
electedCandidates array[string] \| null
isActive boolean \| null
type string \| null
candidates array[ElectionCandidate] \| null
votesStartAt string \| null
votesEndAt string \| null
votesCount integer \| null
electedCount integer \| null
createdAt string \| null
status string \| null
votes object \| null

ElectionCandidate

A candidate in an election.

Field Type Required Description
user string \| null
voteCount integer \| null
article string \| null
party string \| null
isElected boolean \| null

.invalidate_cache()

Clear the SWR cache for all resources.

Signature

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

Clone this wiki locally