Skip to content

Configure retries

Control how the public API fetcher retries transient failures before raising an error.

Default behaviour

Retries are enabled out of the box. Every public API request (attractions, product groups, locations, content) is automatically retried up to 5 times on:

  • HTTP 429 (rate limited) and any HTTP 5xx (server error)
  • Network-level failures — connection resets, timeouts

Delays follow exponential backoff starting at 1 second, doubling on each attempt, with full jitter applied so concurrent clients do not pile up at the same moment.

Attempt Base delay With jitter (approx.)
1st retry 1 s 0 – 1 s
2nd retry 2 s 0 – 2 s
3rd retry 4 s 0 – 4 s
4th retry 8 s 0 – 8 s
5th retry 16 s 0 – 16 s

No code change is needed to get this behaviour.

Increase retries for unreliable networks

Pass max_retries when creating the client.

from pyventim import EventimClient, EventimMarket, EventimCategory

client = EventimClient(
    market=EventimMarket.GERMANY,
    max_retries=10,
)

for pg in client.product_groups(categories=[EventimCategory.CONCERTS], page_limit=1):
    print(pg.name)

Adjust the backoff delay

Use retry_base_delay to change the starting delay. The value is the sleep time in seconds before the first retry; each subsequent retry doubles it.

# Aggressive: start retrying after 0.25 s.
client = EventimClient(
    market=EventimMarket.GERMANY,
    retry_base_delay=0.25,
)

# Conservative: start retrying after 5 s.
client = EventimClient(
    market=EventimMarket.GERMANY,
    retry_base_delay=5.0,
)

Disable retries

Set max_retries=0 to make every request a single attempt with no retry.

client = EventimClient(
    market=EventimMarket.GERMANY,
    max_retries=0,
)

Notes

  • Retries apply only to the public (JSON / httpx) fetcher. The private (HTML scraping / Scrapling) fetcher does not retry automatically.
  • After all retries are exhausted, the client either raises PyventimPublicPaginationError (when raise_for_status=True) or silently stops pagination for the failed page (the default).
  • The Retry-After response header is respected automatically: if the server sends a Retry-After value longer than the computed backoff, that value is used instead.