Skip to main content

ImpitHttpClientAsync

Asynchronous HTTP client for the Apify API built on top of Impit.

Impit is a high-performance HTTP client written in Rust that provides browser-like TLS fingerprints, automatic header ordering, and HTTP/2 support. This client wraps impit.AsyncClient and adds automatic retries with exponential backoff for rate-limited (HTTP 429) and server error (HTTP 5xx) responses.

Hierarchy

Index

Methods

__init__

  • __init__(*, token, timeout, max_retries, min_delay_between_retries, statistics, headers): None
  • Initialize the Impit-based asynchronous HTTP client.


    Parameters

    • optionalkeyword-onlytoken: str | None = None

      Apify API token for authentication.

    • optionalkeyword-onlytimeout: timedelta = DEFAULT_TIMEOUT

      Default timeout for HTTP requests.

    • optionalkeyword-onlymax_retries: int = DEFAULT_MAX_RETRIES

      Maximum number of retry attempts for failed requests.

    • optionalkeyword-onlymin_delay_between_retries: timedelta = DEFAULT_MIN_DELAY_BETWEEN_RETRIES

      Minimum delay between retries (increases exponentially with each attempt).

    • optionalkeyword-onlystatistics: ClientStatistics | None = None

      Statistics tracker for API calls. Created automatically if not provided.

    • optionalkeyword-onlyheaders: dict[str, str] | None = None

      Additional HTTP headers to include in all requests.

    Returns None

call

  • async call(*, method, url, headers, params, data, json, stream, timeout): HttpResponse
  • Make an HTTP request with automatic retry and exponential backoff.


    Parameters

    • keyword-onlymethod: str

      HTTP method (GET, POST, PUT, DELETE, etc.).

    • keyword-onlyurl: str

      Full URL to make the request to.

    • optionalkeyword-onlyheaders: dict[str, str] | None = None

      Additional headers to include.

    • optionalkeyword-onlyparams: dict[str, Any] | None = None

      Query parameters to append to the URL.

    • optionalkeyword-onlydata: ((str | bytes) | bytearray) | None = None

      Raw request body data. Cannot be used together with json.

    • optionalkeyword-onlyjson: JsonSerializable | None = None

      JSON-serializable data for the request body. Cannot be used together with data.

    • optionalkeyword-onlystream: bool | None = None

      Whether to stream the response body.

    • optionalkeyword-onlytimeout: timedelta | None = None

      Timeout override for this request.

    Returns HttpResponse

    The HTTP response object.

Page Options