# encode/httpx

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/encode-httpx).**

15,090 stars · 1,041 forks · Python · bsd-3-clause

## Links

- GitHub: https://github.com/encode/httpx
- Homepage: https://www.python-httpx.org/
- awesome-repositories: https://awesome-repositories.com/repository/encode-httpx.md

## Topics

`asyncio` `http` `python` `trio`

## Description

This project is a comprehensive Python network request framework designed for both synchronous and asynchronous HTTP communication. It provides a high-performance client capable of executing non-blocking requests within event-driven applications, while also supporting standard blocking calls for simpler scripts. The library is built to operate natively across diverse asynchronous runtimes, automatically detecting and utilizing the underlying event loop for concurrency.

What distinguishes this library is its modular architecture, which decouples request construction from network execution through swappable transport layers. It features a middleware-based hook system that allows for the injection of custom logic into the request-response lifecycle, enabling advanced capabilities like custom authentication, detailed activity logging, and internal network event tracing. The framework also supports protocol-multiplexing via HTTP/2 and maintains long-lived connection pools to minimize handshake overhead across sequential requests.

The library covers a broad range of networking requirements, including real-time communication through WebSocket and server-sent event interfaces, secure proxy routing, and granular control over SSL and TLS configurations. It provides robust tools for data handling, such as stream-oriented processing for large payloads, automatic content decoding, and multipart file uploads. Additionally, it includes built-in utilities for testing and debugging, such as response mocking, traffic recording, and direct invocation of local applications.

The project is distributed as a feature-rich library that integrates into Python environments to manage complex API interactions and low-level transport configurations.

## Tags

### Networking & Communication

- [HTTP Client Libraries](https://awesome-repositories.com/f/networking-communication/api-integration-frameworks/http-client-libraries.md) — Provides a comprehensive library for making synchronous and asynchronous HTTP requests with support for connection pooling and HTTP/2.
- [HTTP Client Libraries](https://awesome-repositories.com/f/networking-communication/http-client-libraries.md) — A comprehensive toolkit for interacting with web services, handling complex authentication, and managing low-level transport configurations in Python.
- [HTTP Clients](https://awesome-repositories.com/f/networking-communication/http-clients.md) — Acts as a high-performance HTTP client library for both synchronous and asynchronous network communication.
- [Request Timeout Configurations](https://awesome-repositories.com/f/networking-communication/api-integration-frameworks/http-client-libraries/http-client-configurations/request-timeout-configurations.md) — Enforces strict time limits on network operations to prevent requests from hanging indefinitely. ([source](https://www.python-httpx.org/compatibility/))
- [Asynchronous Networking](https://awesome-repositories.com/f/networking-communication/asynchronous-networking.md) — Executes high-concurrency network operations within event-driven applications without blocking the main thread.
- [Middleware-Based Request Pipelines](https://awesome-repositories.com/f/networking-communication/communication-protocols-architectures/request-processing-architectures/request-processing/middleware-based-request-pipelines.md) — Features a middleware-based hook system for injecting custom logic into the request-response lifecycle.
- [Connection Pooling](https://awesome-repositories.com/f/networking-communication/connection-pooling.md) — Reuses underlying TCP connections across multiple requests to the same host to reduce latency. ([source](https://www.python-httpx.org/advanced/clients/))
- [WebSocket Clients](https://awesome-repositories.com/f/networking-communication/websocket-clients.md) — Supports persistent connections for real-time data streaming and bidirectional messaging over standard web protocols.
- [Response Streaming](https://awesome-repositories.com/f/networking-communication/api-integration-frameworks/http-client-libraries/http-client-utilities/response-streaming.md) — Downloads large payloads incrementally using iterators to minimize memory usage. ([source](https://www.python-httpx.org/quickstart/))
- [Connection Management](https://awesome-repositories.com/f/networking-communication/connection-management.md) — Maintains long-lived connections and supports HTTP/2 to improve performance for sequential requests. ([source](https://www.python-httpx.org/api/))
- [HTTP/2 Protocol Implementations](https://awesome-repositories.com/f/networking-communication/http-2-protocol-implementations.md) — Implements binary-formatted transport with request multiplexing and header compression to improve network efficiency. ([source](https://www.python-httpx.org/http2/))
- [HTTP Request Builders](https://awesome-repositories.com/f/networking-communication/http-request-builders.md) — Provides tools to define methods, URLs, headers, and payloads to build precise HTTP requests for any web service. ([source](https://www.python-httpx.org/api/))
- [HTTP Request Customizations](https://awesome-repositories.com/f/networking-communication/network-infrastructure-routing/network-infrastructure-configuration/network-management/http-interaction-utilities/http-request-customizations.md) — Performs common HTTP methods like GET, POST, PUT, and DELETE with support for custom headers and request body formats. ([source](https://www.python-httpx.org/quickstart/))
- [Cookie Management](https://awesome-repositories.com/f/networking-communication/api-integration-frameworks/request-configurations/cookie-management.md) — Persists cookies across multiple requests at the client level for consistent state tracking. ([source](https://www.python-httpx.org/compatibility/))
- [Binary Protocols](https://awesome-repositories.com/f/networking-communication/binary-protocols.md) — Supports binary-formatted communication and request multiplexing via HTTP/2 for improved efficiency.
- [Real-Time Data Streams](https://awesome-repositories.com/f/networking-communication/real-time-data-streams.md) — Maintains persistent connections to consume server-sent events or bidirectional WebSocket traffic.
- [Traffic Proxying](https://awesome-repositories.com/f/networking-communication/traffic-proxying.md) — Directs network requests through specified proxy servers, supporting both HTTP and SOCKS protocols with optional authentication. ([source](https://www.python-httpx.org/advanced/proxies/))
- [HTTP Client Configurations](https://awesome-repositories.com/f/networking-communication/api-integration-frameworks/http-client-libraries/http-client-configurations.md) — Enables setting default headers, proxies, and authentication parameters on a client instance for consistent request behavior. ([source](https://www.python-httpx.org/advanced/clients/))
- [Synchronous Request Handlers](https://awesome-repositories.com/f/networking-communication/communication-protocols-architectures/request-processing-architectures/request-execution/synchronous-request-handlers.md) — Supports standard blocking calls for simple scripts where high concurrency is not required. ([source](https://www.python-httpx.org/api/))
- [Custom Transport Protocols](https://awesome-repositories.com/f/networking-communication/custom-transport-protocols.md) — Allows extending base transport classes to implement custom request handling and protocol logic. ([source](https://www.python-httpx.org/advanced/transports/))
- [Network Proxies](https://awesome-repositories.com/f/networking-communication/network-infrastructure-routing/network-proxying-tools/network-proxies.md) — Routes traffic through intermediate servers and manages custom certificate validation for secure communication.
- [Network Traffic Analyzers](https://awesome-repositories.com/f/networking-communication/network-traffic-analyzers.md) — Inspects and logs the details of outgoing requests and incoming responses to troubleshoot connectivity or data issues. ([source](https://www.python-httpx.org/third_party_packages/))
- [Server-Sent Events](https://awesome-repositories.com/f/networking-communication/server-sent-events.md) — Maintains persistent connections to receive real-time data streams pushed from a server over a single channel. ([source](https://www.python-httpx.org/third_party_packages/))

### Web Development

- [RESTful API Clients](https://awesome-repositories.com/f/web-development/restful-api-clients.md) — Provides a comprehensive framework for interacting with RESTful web services and managing complex API communication.
- [Request Dispatchers](https://awesome-repositories.com/f/web-development/backend-development/request-response-handling/http-request-handling/request-dispatchers.md) — Sends HTTP/1.1 and HTTP/2 requests using synchronous or asynchronous interfaces across different network environments. ([source](https://www.python-httpx.org/))
- [HTTP Response Handling](https://awesome-repositories.com/f/web-development/backend-development/request-response-handling/http-response-handling.md) — Automatically decodes compressed responses and manages character encoding to simplify data exchange. ([source](https://www.python-httpx.org/))
- [Request Body Handling](https://awesome-repositories.com/f/web-development/request-body-handling.md) — Uploads large payloads using asynchronous generators to avoid loading entire content into memory. ([source](https://www.python-httpx.org/async/))
- [Network Transport Customizers](https://awesome-repositories.com/f/web-development/network-transport-customizers.md) — Provides interfaces for customizing low-level network behavior, including local addresses and connection retry logic. ([source](https://www.python-httpx.org/advanced/transports/))
- [Transport Injection](https://awesome-repositories.com/f/web-development/network-transport-customizers/transport-injection.md) — Supports injecting custom transport instances to manage low-level connection settings and protocol handling. ([source](https://www.python-httpx.org/async/))
- [Request Lifecycle Managers](https://awesome-repositories.com/f/web-development/request-lifecycle-managers.md) — Configures automatic redirection, network timeouts, and structured exception handling for the request-response pipeline. ([source](https://www.python-httpx.org/quickstart/))
- [Response Character Encoding](https://awesome-repositories.com/f/web-development/backend-development/request-response-handling/http-response-handling/response-character-encoding.md) — Converts raw response bytes into readable text using header information or character set overrides. ([source](https://www.python-httpx.org/advanced/text-encodings/))
- [Multipart Upload Utilities](https://awesome-repositories.com/f/web-development/multipart-upload-utilities.md) — Supports multipart-encoded requests with streaming for large files to maintain low memory usage. ([source](https://www.python-httpx.org/advanced/clients/))
- [Request Routing](https://awesome-repositories.com/f/web-development/network-transport-customizers/transport-customizers/request-routing.md) — Directs outgoing requests to specific transport handlers based on target URL schemes or domains. ([source](https://www.python-httpx.org/advanced/transports/))

### Programming Languages & Runtimes

- [Asynchronous Request Execution](https://awesome-repositories.com/f/programming-languages-runtimes/language-features-paradigms/concurrency-models/asynchronous-processing/asynchronous-request-execution.md) — Sends HTTP requests using an asynchronous interface for concurrent operations within a single event loop. ([source](https://www.python-httpx.org/api/))
- [Asynchronous Runtime Adapters](https://awesome-repositories.com/f/programming-languages-runtimes/asynchronous-runtime-adapters.md) — Provides native support for multiple asynchronous runtimes by automatically detecting and utilizing the underlying event loop.
- [Asynchronous Runtime Compatibility](https://awesome-repositories.com/f/programming-languages-runtimes/runtime-execution-environments/runtime-environments/runtimes/deployment-specific-runtimes/backend-runtimes/asynchronous-runtime-compatibility.md) — Operates natively across different asynchronous runtimes by automatically detecting the underlying event loop. ([source](https://www.python-httpx.org/async/))

### Security & Cryptography

- [Certificate Verification](https://awesome-repositories.com/f/security-cryptography/certificate-verification.md) — Enables or disables server certificate verification to ensure secure communication. ([source](https://www.python-httpx.org/advanced/ssl/))
- [Client Certificate Authentication](https://awesome-repositories.com/f/security-cryptography/client-certificate-authentication.md) — Provides local certificate files to verify client identity during the handshake process. ([source](https://www.python-httpx.org/advanced/ssl/))
- [API Request Authentication](https://awesome-repositories.com/f/security-cryptography/identity-access-management/authentication-strategies/machine-and-protocol-identity/api-machine-authentication/api-request-authentication.md) — Applies standard security schemes like Basic or Digest to outgoing requests for identity verification. ([source](https://www.python-httpx.org/advanced/authentication/))
- [Client Session Persistence](https://awesome-repositories.com/f/security-cryptography/session-persistence-strategies/client-session-persistence.md) — Groups multiple requests under a single client instance to reuse connections and configuration settings. ([source](https://www.python-httpx.org/compatibility/))
- [Certificate Authority Configurations](https://awesome-repositories.com/f/security-cryptography/certificate-authority-configurations.md) — Configures the client to validate server identities against specific trusted certificate authorities. ([source](https://www.python-httpx.org/advanced/ssl/))
- [TLS/SSL Configurations](https://awesome-repositories.com/f/security-cryptography/security/cryptography-and-secrets/cryptographic-primitives-management/tls-ssl-configurations.md) — Defines encryption and certificate verification parameters at the client level for consistent security. ([source](https://www.python-httpx.org/compatibility/))
- [SSRF Protections](https://awesome-repositories.com/f/security-cryptography/ssrf-protections.md) — Validates destination addresses to prevent unauthorized requests to internal or sensitive infrastructure. ([source](https://www.python-httpx.org/third_party_packages/))
- [Custom Authentication Providers](https://awesome-repositories.com/f/security-cryptography/custom-authentication-providers.md) — Enables bespoke authentication flows by intercepting requests and responses for complex token management. ([source](https://www.python-httpx.org/advanced/authentication/))

### DevOps & Infrastructure

- [Request Retries](https://awesome-repositories.com/f/devops-infrastructure/api-service-management/api-resilience/request-retries.md) — Automatically re-executes network requests that fail due to transient errors to improve reliability. ([source](https://www.python-httpx.org/third_party_packages/))
- [SNI Overrides](https://awesome-repositories.com/f/devops-infrastructure/hostname-configurations/sni-overrides.md) — Specifies a custom hostname for certificate verification when connecting to a server via an IP address. ([source](https://www.python-httpx.org/advanced/extensions/))

### Development Tools & Productivity

- [Hook Registration](https://awesome-repositories.com/f/development-tools-productivity/lifecycle-hooks/hook-registration.md) — Allows the injection of custom logic into the request-response lifecycle via a middleware-based hook system. ([source](https://www.python-httpx.org/advanced/event-hooks/))

### Testing & Quality Assurance

- [API Request Mocking](https://awesome-repositories.com/f/testing-quality-assurance/general-testing-utilities/test-utilities-assertions/network-api-mocking/api-request-mocking.md) — Intercepts outgoing network requests to return pre-defined responses for testing without performing actual network operations. ([source](https://www.python-httpx.org/advanced/transports/))
- [HTTP Interaction Recording](https://awesome-repositories.com/f/testing-quality-assurance/api-network-testing/network-testing/http-interaction-recording.md) — Captures network interactions into persistent files to enable deterministic replay during test runs. ([source](https://www.python-httpx.org/third_party_packages/))

### Data & Databases

- [Incremental Data Streaming](https://awesome-repositories.com/f/data-databases/incremental-data-streaming.md) — Handles large request and response bodies as incremental byte chunks to maintain low memory usage.

### Software Engineering & Architecture

- [Exception Hierarchies](https://awesome-repositories.com/f/software-engineering-architecture/error-handling/exception-logic-structures/exception-hierarchies.md) — Categorizes network, protocol, and status-related failures into a structured hierarchy for precise error handling. ([source](https://www.python-httpx.org/exceptions/))

### System Administration & Monitoring

- [Local Network Event Loggers](https://awesome-repositories.com/f/system-administration-monitoring/network-log-streaming/local-network-event-loggers.md) — Outputs internal network events and request-response lifecycle details to standard logging streams to assist with debugging. ([source](https://www.python-httpx.org/logging/))
- [Transfer Monitoring Tools](https://awesome-repositories.com/f/system-administration-monitoring/transfer-monitoring-tools.md) — Tracks byte-by-byte progress of large uploads and downloads in real time. ([source](https://www.python-httpx.org/advanced/clients/))
