httpx
The next generation HTTP client.
This package has a good security score with no known vulnerabilities.
Community Reviews
Modern HTTP client with strong security defaults and excellent async support
The async/await support is first-class, not bolted on. I've used it extensively in FastAPI services where maintaining connection pools across async requests is critical. Error handling is well-designed: network errors, timeouts, and HTTP errors have distinct exception types that don't leak sensitive data in tracebacks. The Client() context manager pattern encourages proper resource cleanup.
From a supply chain perspective, the dependency footprint is minimal—primarily httpcore, certifi, and idna. The maintainers are responsive to CVEs, particularly around certificate validation. Input validation for URLs and headers is strict, rejecting malformed data early rather than passing it through. Authentication helpers (basic, digest, bearer) are straightforward and handle credential encoding safely.
Best for: New projects requiring modern async HTTP capabilities with strong security defaults, or services needing concurrent request handling.
Avoid if: You need extensive backward compatibility with requests-based code or rely on obscure requests plugins without httpx equivalents.
Requests-like API with modern async support and excellent error messages
The documentation is genuinely excellent with practical examples covering everything from basic requests to advanced topics like custom authentication and event hooks. Error messages are clear and actionable - when I misconfigured timeouts or connection limits, the exceptions told me exactly what went wrong. The QuickStart guide gets you productive in minutes, and the Advanced Usage section covers real-world scenarios like retries and streaming.
Debugging is straightforward with built-in event hooks for logging requests/responses. The library handles edge cases well - proper handling of redirects, cookies, and HTTP/2 without manual configuration. Stack Overflow coverage is decent, and GitHub issues get timely responses from maintainers who actually help solve problems.
Best for: Projects needing modern HTTP client features like async support, HTTP/2, or better connection pooling while maintaining requests-like simplicity
Avoid if: You need the absolute simplest possible API for basic one-off synchronous requests where requests is already working fine
Requests API with async superpowers and excellent type hints
The documentation is comprehensive with practical examples for common patterns like connection pooling, timeouts, and retries. Error messages are clear and actionable - when you misconfigure something like authentication or headers, the traceback points you exactly where to look. The unified exception hierarchy (HTTPError, TimeoutException, etc.) makes error handling predictable.
Day-to-day usage is smooth. The context manager pattern for clients encourages proper resource cleanup, and the transport layer is customizable when you need it. One minor friction point is understanding when to use Client vs AsyncClient and managing their lifecycles in larger applications, but the docs cover this well.
Best for: Modern Python projects needing async HTTP support, type safety, or HTTP/2 with a familiar requests-like API.
Avoid if: You need maximum simplicity for basic scripts and don't require async or type hints (stick with requests).
Sign in to write a review
Sign In