Skip to main content

HTTPX Tenacity

Package Latest PyPI Version Supported Python Versions
Meta Apache-2.0 Code of Conduct Checked with mypy Code Style Black Linting: Ruff
Automation CI codecov

A lightweight package that provides tenacious (retrying) httpx and httpx2 transports.

Installation

The package is published on PyPI. Plain pip install httpx-tenacity installs only the shared core with the retry policies, which contains no HTTP client. Select the HTTP client you use with an extra, httpx or httpx2.

pip install 'httpx-tenacity[httpx]'
pip install 'httpx-tenacity[httpx2]'

To use both HTTP clients in the same process, install both extras.

pip install 'httpx-tenacity[httpx,httpx2]'

There is no automatic fallback: you choose the integration explicitly by importing from httpx_tenacity.httpx or from httpx_tenacity.httpx2.

Migrating from <0.3

Two breaking changes land in 0.3.0.

First, the transports moved out of the package root and httpx is no longer a required dependency. Install httpx-tenacity[httpx] instead of httpx-tenacity and change your imports. RetryPolicy, SmartRetryPolicy, and RetryingT keep their import paths.

-from httpx_tenacity import AsyncTenaciousTransport, TenaciousTransport
+from httpx_tenacity.httpx import AsyncTenaciousTransport, TenaciousTransport

The same applies to HTTPXHTTPTransportKeywordArguments. For HTTPX2, import the transports from httpx_tenacity.httpx2 instead. The transports' loggers follow their modules and are now named httpx_tenacity.httpx.tenacious_transport and httpx_tenacity.httpx.async_tenacious_transport.

Second, TenaciousTransport.create() and AsyncTenaciousTransport.create() take a policy instead of the max_attempts, multiplier, max_wait_seconds, min_wait_seconds, and exponent_base arguments. Pass them to SmartRetryPolicy.

-transport = TenaciousTransport.create(max_attempts=3)
+transport = TenaciousTransport.create(policy=SmartRetryPolicy(max_attempts=3))

Usage

Wrap the requests of an HTTPX client with a transport that retries server-side issues (HTTP 5xx errors and 429 Too Many Requests responses) and request errors:

import httpx
from httpx_tenacity import SmartRetryPolicy
from httpx_tenacity.httpx import TenaciousTransport

transport = TenaciousTransport.create(policy=SmartRetryPolicy(max_attempts=3))

with httpx.Client(transport=transport) as client:
    response = client.get("https://api.example.com/data")

For HTTPX2, import httpx2 instead of httpx and import the transports from httpx_tenacity.httpx2 instead of httpx_tenacity.httpx; everything else stays the same. The documentation shows every example for both clients, including the asynchronous AsyncTenaciousTransport. Transports, clients, and responses must all come from the same client: httpx_tenacity.httpx works with httpx and httpx_tenacity.httpx2 works with httpx2.

Using Both Clients Together

You can install both extras, httpx-tenacity[httpx,httpx2], and use both integrations in the same process. The retry policies are independent of the HTTP client, so you may even share one policy between them. The HTTP objects, however, are not interchangeable: an httpx_tenacity.httpx transport cannot be used with an httpx2.Client, and an httpx_tenacity.httpx2 transport cannot be used with an httpx.Client.

Metadata

Release files for httpx-tenacity 0.3.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 httpx-tenacity 0.3.0
File Size Uploaded Provenance Actions
httpx_tenacity-0.3.0.tar.gz 15.9 kB With provenance Details for httpx_tenacity-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for httpx-tenacity 0.3.0
File Interpreter ABI Platform Actions
httpx_tenacity-0.3.0-py3-none-any.whl Python 3 none any Details for httpx_tenacity-0.3.0-py3-none-any.whl

Total release size: 40.7 kB

Release files / httpx_tenacity-0.3.0.tar.gz

Download URL httpx_tenacity-0.3.0.tar.gz
Size 15.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a2186825219c28f2d56a424941a1c3e97e8ef4905a988724e268d5f85f00e116
BLAKE2b-256 checksum
How to use checksums
8b0e7144283f69d65656fc00d04d0ee03b1c7eb3d60d1898ba1f2bffc3ff137a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 13, 2026.

Transparency log

Release files / httpx_tenacity-0.3.0-py3-none-any.whl

Download URL httpx_tenacity-0.3.0-py3-none-any.whl
Size 24.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
60566eb72460def579f71da99ee7e1b198584c4e309ecf422f8ae50685aa4c03
BLAKE2b-256 checksum
How to use checksums
430b61f4bae4c54475af04c6f7ab95eec8ed614614e5295e7125691452521c77
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 13, 2026.

Transparency log

Security for httpx-tenacity 0.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.

Select from 2 files

Attestation for httpx_tenacity-0.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 Nov 13, 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