resilient-httpx
HTTP client with retry, backoff, and proxy rotation. Sync and async. Built on top of httpx, tenacity, and structlog.
Installation
pip install resilient-httpx
Usage
Sync client
from resilient_httpx import ProxyHttpClient, RetryPolicy
with ProxyHttpClient(retry=RetryPolicy(max_attempts=5), timeout=15.0) as client:
response = client.get("https://api.example.com/data")
Async client
from resilient_httpx import AsyncProxyHttpClient, RetryPolicy
async with AsyncProxyHttpClient(retry=RetryPolicy(max_attempts=5), timeout=15.0) as client:
response = await client.get("https://api.example.com/data")
With proxy rotation
from resilient_httpx import ProxyHttpClient, RetryPolicy
client = ProxyHttpClient(
proxies=[
"http://proxy1:8080",
"http://user:pass@proxy2:8080",
"socks5://proxy3:1080",
],
proxy_strategy="round-robin", # or "random"
retry=RetryPolicy(max_attempts=5, backoff="exponential"),
timeout=15.0,
blacklist_threshold=3,
blacklist_ttl=300.0,
)
with client:
response = client.get("https://api.example.com/data")
data = response.json()
AsyncProxyHttpClient accepts the same parameters:
from resilient_httpx import AsyncProxyHttpClient, RetryPolicy
async with AsyncProxyHttpClient(
proxies=["http://proxy1:8080", "http://proxy2:8080"],
retry=RetryPolicy(max_attempts=5, backoff="exponential"),
) as client:
response = await client.get("https://api.example.com/data")
Custom retry policy
import httpx
from resilient_httpx import RetryPolicy
policy = RetryPolicy(
max_attempts=5,
backoff="exponential", # "exponential" | "fixed" | "random_jitter"
min_wait=1.0,
max_wait=30.0,
retry_on=[429, 500, 502, 503, 504],
retry_on_exception=[httpx.TimeoutException, httpx.ConnectError],
)
Error handling
from resilient_httpx import ProxyHttpClient, AllProxiesExhausted, MaxRetriesExceeded
with ProxyHttpClient(proxies=proxy_list) as client:
try:
response = client.get("https://api.example.com/data")
except AllProxiesExhausted:
... # all proxies blacklisted
except MaxRetriesExceeded as exc:
... # retries exhausted, exc.__cause__ has the last error
Configuration Reference
Both ProxyHttpClient and AsyncProxyHttpClient accept the same parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
proxies |
list[str] | None |
None |
Proxy URLs |
proxy_strategy |
str |
"round-robin" |
"round-robin" or "random" |
retry |
RetryPolicy |
RetryPolicy() |
Retry configuration |
timeout |
float |
30.0 |
Request timeout in seconds |
headers |
dict[str, str] | None |
None |
Default headers |
blacklist_threshold |
int |
3 |
Consecutive failures before blacklisting |
blacklist_ttl |
float |
300.0 |
Blacklist duration in seconds |
fallback_to_direct |
bool |
False |
Request without proxy when all are blacklisted |
Development
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
pytest
Run with coverage:
pytest --cov=resilient_httpx --cov-report=term-missing
Metadata
Release files for resilient-httpx 1.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| resilient_httpx-1.3.0.tar.gz | 57.3 kB | With provenance | Details for resilient_httpx-1.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| resilient_httpx-1.3.0-py3-none-any.whl | Python 3 | none | any | Details for resilient_httpx-1.3.0-py3-none-any.whl |
Total release size: 74.8 kB
Release files / resilient_httpx-1.3.0.tar.gz
| Download URL | resilient_httpx-1.3.0.tar.gz |
|---|---|
| Size | 57.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b5d45f306c2e68c87442749ed924716fce756208db459e220d37f507742a4360
|
|
BLAKE2b-256 checksum How to use checksums |
6d69018b7db9dc705b2907f484171f36981a37d8157d4951df645f52a3cf76be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 18, 2026.
Transparency logRelease files / resilient_httpx-1.3.0-py3-none-any.whl
| Download URL | resilient_httpx-1.3.0-py3-none-any.whl |
|---|---|
| Size | 17.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9f551b559faaed4e15cb0770d8c4e9380fefca7e6bb4b4da0767db21cddce005
|
|
BLAKE2b-256 checksum How to use checksums |
f81477a147a35e07b8b12eafcb4831a7b37d11453fd15d8d48ce082ff426126b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 18, 2026.
Transparency logSecurity for resilient-httpx 1.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for resilient_httpx-1.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 18, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.