# HttpClientBase<!-- -->

Shared configuration and utilities for HTTP clients.

Provides common functionality for both sync and async HTTP clients including: header construction, parameter parsing, request body preparation, URL building, timeout calculation, and error classification.

Subclasses should call `super().__init__()` to initialize shared configuration. The helpers are then used by the inherited `call`, and stay available to a client that replaces it.

### Hierarchy

* *HttpClientBase*

  * [HttpClient](https://docs.apify.com/api/client/python/reference/class/HttpClient.md)
  * [HttpClientAsync](https://docs.apify.com/api/client/python/reference/class/HttpClientAsync.md)

## Index[**](#Index)

### Methods

* [**\_\_init\_\_](https://docs.apify.com/api/client/python/reference/class/HttpClientBase.md#__init__)
* [**is_retryable_transport_error](https://docs.apify.com/api/client/python/reference/class/HttpClientBase.md#is_retryable_transport_error)
* [**is_timeout_error](https://docs.apify.com/api/client/python/reference/class/HttpClientBase.md#is_timeout_error)
* [**set_default_authorization](https://docs.apify.com/api/client/python/reference/class/HttpClientBase.md#set_default_authorization)

## Methods<!-- -->[**](#Methods)

### [**](#__init__)\_\_init\_\_

* ****\_\_init\_\_**(\*, token, timeout_short, timeout_medium, timeout_long, timeout_max, max_retries, min_delay_between_retries, statistics, headers, user_agent_suffix, http_compressor): None

- Initialize the HTTP client base.

  ***

  #### Parameters

  * ##### optionalkeyword-onlytoken: str | None = <!-- -->None

    Apify API token for authentication.

  * ##### optionalkeyword-onlytimeout_short: timedelta = <!-- -->DEFAULT_TIMEOUT_SHORT

    Default timeout for short-duration API operations (simple CRUD operations, ...).

  * ##### optionalkeyword-onlytimeout_medium: timedelta = <!-- -->DEFAULT_TIMEOUT_MEDIUM

    Default timeout for medium-duration API operations (batch operations, listing, ...).

  * ##### optionalkeyword-onlytimeout_long: timedelta = <!-- -->DEFAULT_TIMEOUT_LONG

    Default timeout for long-duration API operations (long-polling, streaming, ...).

  * ##### optionalkeyword-onlytimeout_max: timedelta = <!-- -->DEFAULT_TIMEOUT_MAX

    Maximum timeout cap for any single request attempt, including tier and per-call timeouts.

  * ##### optionalkeyword-onlymax_retries: int = <!-- -->DEFAULT_MAX_RETRIES

    Maximum number of retries for failed requests. Set to 0 to disable retries.

  * ##### optionalkeyword-onlymin_delay_between_retries: timedelta = <!-- -->DEFAULT_MIN_DELAY_BETWEEN_RETRIES

    Minimum delay between retries.

  * ##### optionalkeyword-onlystatistics: [ClientStatistics](https://docs.apify.com/api/client/python/reference/class/ClientStatistics.md) | 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.

  * ##### optionalkeyword-onlyuser_agent_suffix: (str | [list](https://docs.apify.com/api/client/python/reference/class/ActorCollectionClient.md#list)\[str]) | None = <!-- -->None

    Extra part or parts appended to the default `User-Agent` header, separated by `; `.

  * ##### optionalkeyword-onlyhttp_compressor: [HttpCompressor](https://docs.apify.com/api/client/python/reference/class/HttpCompressor.md) | None = <!-- -->None

    Compressor used to compress request bodies. Defaults to `GzipHttpCompressor`.

  #### Returns None

### [**](#is_retryable_transport_error)is_retryable_transport_error

* ****is_retryable_transport_error**(exc): bool

- Return whether an underlying HTTP-library exception is retryable.

  The default classifies nothing as retryable, so a transport that doesn't override it gives up on the first connection failure. Every transport adapter should map its own transient error types here.

  ***

  #### Parameters

  * ##### exc: Exception

  #### Returns bool

### [**](#is_timeout_error)is_timeout_error

* ****is_timeout_error**(exc): bool

- Return whether an exception represents a transport timeout.

  Recognizes Python's own `TimeoutError`. Transport adapters extend it with the timeout types their HTTP library defines.

  ***

  #### Parameters

  * ##### exc: Exception

  #### Returns bool

### [**](#set_default_authorization)set_default_authorization

* ****set_default_authorization**(token): None

- Set the `Authorization` header from the token, unless an authorization header is already configured.

  ***

  #### Parameters

  * ##### token: str

    The Apify API token to set as the `Bearer` authorization.

  #### Returns None
