Skip to main content

resilient-httpx

python coverage

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.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for resilient-httpx 1.2.0
File Size Uploaded Provenance Actions
resilient_httpx-1.2.0.tar.gz 16.8 kB With provenance Details for resilient_httpx-1.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for resilient-httpx 1.2.0
File Interpreter ABI Platform Actions
resilient_httpx-1.2.0-py3-none-any.whl Python 3 none any Details for resilient_httpx-1.2.0-py3-none-any.whl

Total release size: 32.6 kB

Release files / resilient_httpx-1.2.0.tar.gz

Download URL resilient_httpx-1.2.0.tar.gz
Size 16.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b01e84af61955db1eea1e3976ac3aa64767318a534bb3062c15b4b05bdc6b44b
BLAKE2b-256 checksum
How to use checksums
aaf2f7cc356460742c650bd2e0b02a1fbfad79f36cf17501c0404173e97ba765
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 log

Release files / resilient_httpx-1.2.0-py3-none-any.whl

Download URL resilient_httpx-1.2.0-py3-none-any.whl
Size 15.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
00d1d50ff4f21aff162830de5c67f21b601e0da377177d983fff66ce0e75df1c
BLAKE2b-256 checksum
How to use checksums
ea8f4f846fb3fafa1616db4102d8b35dfb492d3e3fb2f550c0ca403607614068
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 log

Security for resilient-httpx 1.2.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.

Select from 2 files

Attestation for resilient_httpx-1.2.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 log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page