| id | retries |
|---|---|
| title | Retries |
| description | Configure automatic retries with exponential backoff for failed requests. |
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import CodeBlock from '@theme/CodeBlock';
import ApiLink from '@theme/ApiLink';
import RetriesAsyncExample from '!!raw-loader!./code/05_retries_async.py'; import RetriesSyncExample from '!!raw-loader!./code/05_retries_sync.py';
The Apify client automatically retries requests that fail due to:
- Network errors
- Internal errors in the Apify API (HTTP status codes 500 and above)
- Rate limit errors (HTTP status code 429)
By default, the client retries a failed request up to 4 times. The retry intervals use an exponential backoff strategy:
- The first retry occurs after approximately 500 milliseconds.
- The second retry occurs after approximately 1,000 milliseconds, and so on.
You can customize this behavior using the following options in the ApifyClient constructor:
max_retries: Defines the maximum number of retry attempts.min_delay_between_retries: Sets the minimum delay between retries as atimedelta.
Retries with exponential backoff help reduce the load on the server and increase the chances of a successful request.
{RetriesAsyncExample} {RetriesSyncExample}