From 422bac5e910b40c216610f159ca98bc75c18449e Mon Sep 17 00:00:00 2001 From: dheerajitbhu Date: Fri, 6 Nov 2026 11:10:17 -0800 Subject: [PATCH 1/3] docs: document gzip default and brotli extra for request compression Closes #1179 --- src/apify_client/_apify_client.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/apify_client/_apify_client.py b/src/apify_client/_apify_client.py index aac0da66..ad36076b 100644 --- a/src/apify_client/_apify_client.py +++ b/src/apify_client/_apify_client.py @@ -154,8 +154,10 @@ def __init__( user_agent_suffix: Extra part or parts appended to the default `User-Agent` header, separated by `; `, for example to identify the tool built on top of the client. With `with_custom_http_client`, pass it to the HTTP client's constructor. - compression: Compression algorithm for request bodies. Pass a string literal to select an algorithm, - or an `HttpCompressor` instance for finer-grained control. + compression: Compression algorithm for request bodies. Defaults to `'gzip'`. Pass a string + literal to select an algorithm, or an `HttpCompressor` instance for finer-grained control. + `'brotli'` needs the optional extra (`pip install "apify-client[brotli]"`); it is not the + default because brotli is a native package and would add a required compiled dependency. Raises: ValueError: If `max_retries` is negative. @@ -534,8 +536,10 @@ def __init__( user_agent_suffix: Extra part or parts appended to the default `User-Agent` header, separated by `; `, for example to identify the tool built on top of the client. With `with_custom_http_client`, pass it to the HTTP client's constructor. - compression: Compression algorithm for request bodies. Pass a string literal to select an algorithm, - or an `HttpCompressor` instance for finer-grained control. + compression: Compression algorithm for request bodies. Defaults to `'gzip'`. Pass a string + literal to select an algorithm, or an `HttpCompressor` instance for finer-grained control. + `'brotli'` needs the optional extra (`pip install "apify-client[brotli]"`); it is not the + default because brotli is a native package and would add a required compiled dependency. Raises: ValueError: If `max_retries` is negative. From a473c1a7cba028195399af623f82fe13bf37194e Mon Sep 17 00:00:00 2001 From: Vlada Dusek Date: Mon, 9 Nov 2026 12:09:02 +0100 Subject: [PATCH 2/3] docs: document ImportError for missing brotli extra --- src/apify_client/_apify_client.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/apify_client/_apify_client.py b/src/apify_client/_apify_client.py index ad36076b..6c51d2ed 100644 --- a/src/apify_client/_apify_client.py +++ b/src/apify_client/_apify_client.py @@ -154,13 +154,13 @@ def __init__( user_agent_suffix: Extra part or parts appended to the default `User-Agent` header, separated by `; `, for example to identify the tool built on top of the client. With `with_custom_http_client`, pass it to the HTTP client's constructor. - compression: Compression algorithm for request bodies. Defaults to `'gzip'`. Pass a string - literal to select an algorithm, or an `HttpCompressor` instance for finer-grained control. - `'brotli'` needs the optional extra (`pip install "apify-client[brotli]"`); it is not the - default because brotli is a native package and would add a required compiled dependency. + compression: Compression algorithm for request bodies. Defaults to `'gzip'`. Pass a string literal to select + an algorithm, or an `HttpCompressor` instance for finer-grained control. `'brotli'` needs the `brotli` + extra (`pip install "apify-client[brotli]"`). It is not the default because it is a compiled package. Raises: ValueError: If `max_retries` is negative. + ImportError: If `compression` is `'brotli'` and the `brotli` extra is not installed. """ if max_retries < 0: raise ValueError(f'max_retries must be a non-negative integer, got {max_retries}') @@ -536,13 +536,13 @@ def __init__( user_agent_suffix: Extra part or parts appended to the default `User-Agent` header, separated by `; `, for example to identify the tool built on top of the client. With `with_custom_http_client`, pass it to the HTTP client's constructor. - compression: Compression algorithm for request bodies. Defaults to `'gzip'`. Pass a string - literal to select an algorithm, or an `HttpCompressor` instance for finer-grained control. - `'brotli'` needs the optional extra (`pip install "apify-client[brotli]"`); it is not the - default because brotli is a native package and would add a required compiled dependency. + compression: Compression algorithm for request bodies. Defaults to `'gzip'`. Pass a string literal to select + an algorithm, or an `HttpCompressor` instance for finer-grained control. `'brotli'` needs the `brotli` + extra (`pip install "apify-client[brotli]"`). It is not the default because it is a compiled package. Raises: ValueError: If `max_retries` is negative. + ImportError: If `compression` is `'brotli'` and the `brotli` extra is not installed. """ if max_retries < 0: raise ValueError(f'max_retries must be a non-negative integer, got {max_retries}') From 9bdabe4f22976b8d6f86e8fd73f6542aecd18377 Mon Sep 17 00:00:00 2001 From: Vlada Dusek Date: Mon, 9 Nov 2026 12:19:45 +0100 Subject: [PATCH 3/3] docs: explain why brotli is not the default compression --- src/apify_client/_apify_client.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/apify_client/_apify_client.py b/src/apify_client/_apify_client.py index 6c51d2ed..255c87ea 100644 --- a/src/apify_client/_apify_client.py +++ b/src/apify_client/_apify_client.py @@ -156,7 +156,8 @@ def __init__( the HTTP client's constructor. compression: Compression algorithm for request bodies. Defaults to `'gzip'`. Pass a string literal to select an algorithm, or an `HttpCompressor` instance for finer-grained control. `'brotli'` needs the `brotli` - extra (`pip install "apify-client[brotli]"`). It is not the default because it is a compiled package. + extra (`pip install "apify-client[brotli]"`). It is not the default because the `brotli` package is a C + extension, while gzip support is part of the Python standard library. Raises: ValueError: If `max_retries` is negative. @@ -538,7 +539,8 @@ def __init__( the HTTP client's constructor. compression: Compression algorithm for request bodies. Defaults to `'gzip'`. Pass a string literal to select an algorithm, or an `HttpCompressor` instance for finer-grained control. `'brotli'` needs the `brotli` - extra (`pip install "apify-client[brotli]"`). It is not the default because it is a compiled package. + extra (`pip install "apify-client[brotli]"`). It is not the default because the `brotli` package is a C + extension, while gzip support is part of the Python standard library. Raises: ValueError: If `max_retries` is negative.