Pagination¶
Async utilities for handling paginated API responses.
- class clash_royale.aio.PaginatedList[source]¶
Bases:
Generic[ResourceType]Async lazy-loading paginated list that fetches pages on demand.
Supports async iteration and explicit async methods for indexed access.
Example usage:
# Async iteration (lazy loading) async for clan in client.clans.search("royal"): print(clan.name) # Explicit index access clan = await results.get(5) # Explicit slice access clans = await results.slice(0, 10) # Fetch all results all_clans = await results.all()
- __init__(client: Client, endpoint: str, model: type[ResourceType], params: PaginationParams | ClanSearchParams | None = None)[source]¶
- async get(index: int) ResourceType[source]¶
Get item at index, fetching pages as needed.
- Parameters:
index – The index of the item to retrieve.
- Returns:
The item at the specified index.
- Raises:
IndexError – If index is out of range.
ValueError – If index is negative.
- async slice(start: int, stop: int) list[ResourceType][source]¶
Get a slice of items, fetching pages as needed.
- Parameters:
start – Start index (inclusive).
stop – Stop index (exclusive).
- Returns:
List of items in the specified range.