Quick start

Use a context manager so the internal httpx.Client is closed when you are done.

Terminal methods return a basef1.domain.parse.ParsedApiResponse with .pagination, .kind, and typed .data.

from basef1 import BaseF1Client
from basef1.domain.tables import SeasonTable

with BaseF1Client() as client:
    envelope = client.get_seasons(limit=100)
    assert isinstance(envelope.data, SeasonTable)
    print(envelope.pagination.total_int, len(envelope.data.seasons))
    print(envelope.data.seasons[0].season)

    client.get_seasons(limit=100)
    client.stats()

Chaining queries

Use basef1.query.F1Query via client.query() to build path-shaped filters (season, round, circuit, driver, etc.) before calling a terminal resource. See Examples for fuller patterns.

Caching and statistics

Responses are cached in memory by default (TTL cache). Use cache_backend="sqlite" for a persistent cache, or cache=False when every request must hit the network.

Use basef1.client.BaseF1Client.usage_snapshot() or basef1.client.BaseF1Client.stats() to inspect logical vs HTTP traffic and cache hits; details in Caching and usage statistics.