# 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, and timeout calculation.

Subclasses should call `super().__init__()` to initialize shared configuration. The helper methods are then available for use in the `call()` implementation.

### Hierarchy

* *HttpClientBase*

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

## Index[**](#Index)

### Methods

* [**\_\_init\_\_](https://docs.apify.com/api/client/python/api/client/python/reference/class/HttpClientBase.md#__init__)
* [**set\_default\_authorization](https://docs.apify.com/api/client/python/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, 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 exponential timeout growth across retries.

  * ##### optionalkeyword-onlymax\_retries: int = <!-- -->DEFAULT\_MAX\_RETRIES

    Maximum number of retries for failed requests.

  * ##### 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/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-onlyhttp\_compressor: [HttpCompressor](https://docs.apify.com/api/client/python/api/client/python/reference/class/HttpCompressor.md) | None = <!-- -->None

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

  #### Returns None

### [**](#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
