HTTPXP - A next-generation HTTP client for Python.
HTTPXP is a fully featured HTTP client library for Python 3. It includes an integrated command line client, has support for both HTTP/1.1 and HTTP/2, and provides both sync and async APIs.
Install HTTPXP using pip:
$ pip install httpxpNow, let's get started:
>>> import httpxp
>>> r = httpxp.get('https://www.example.org/')
>>> r
<Response [200 OK]>
>>> r.status_code
200
>>> r.headers['content-type']
'text/html; charset=UTF-8'
>>> r.text
'<!doctype html>\n<html>\n<head>\n<title>Example Domain</title>...'Or, using the command-line client.
$ pip install 'httpxp[cli]' # The command line client is an optional dependency.Which now allows us to use HTTPXP directly from the command-line...
$ httpxp --helpSending a request...
$ httpxp http://httpbin.org/jsonHTTPXP builds on the well-established usability of requests, and gives you:
- A broadly requests-compatible API.
- An integrated command-line client.
- HTTP/1.1 and HTTP/2 support.
- Standard synchronous interface, but with async support if you need it.
- Ability to make requests directly to WSGI applications or ASGI applications.
- Strict timeouts everywhere.
- Fully type annotated.
- 100% test coverage.
Plus all the standard features of requests...
- International Domains and URLs
- Keep-Alive & Connection Pooling
- Sessions with Cookie Persistence
- Browser-style SSL Verification
- Basic/Digest Authentication
- Elegant Key/Value Cookies
- Automatic Decompression
- Automatic Content Decoding
- Unicode Response Bodies
- Multipart File Uploads
- HTTP(S) Proxy Support
- Connection Timeouts
- Streaming Downloads
- .netrc Support
- Chunked Requests
Install with pip:
$ pip install httpxpThe native transport includes HTTP/2 and SOCKS. The following HTTP/2 compatibility extra remains available, but is not required for native HTTP/2:
$ pip install httpxp[http2]HTTPXP requires Python 3.9+.
Project documentation is available at https://github.com/jerlendds/httpxp/blob/master/docs/index.md.
For a run-through of all the basics, head over to the QuickStart.
For more advanced topics, see the Advanced Usage section, the async support section, or the HTTP/2 section.
The Developer Interface provides a comprehensive API reference.
For the upstream ecosystem and compatibility notes, see Third Party Packages.
If you want to contribute with HTTPXP check out the Contributing Guide to learn how to start.
The HTTPXP project relies on these excellent libraries:
- Rust
wreqand PyO3 - Native HTTP/1, HTTP/2, TLS, SOCKS, and WebSocket transport. certifi- SSL certificates.idna- Internationalized domain name support.anyio- Async integration for asyncio and Trio.
As well as these optional installs:
h2- Retained in thehttpxp[http2]compatibility extra; native HTTP/2 does not require it.socksio- Retained in thehttpxp[socks]compatibility extra; native SOCKS does not require it.rich- Rich terminal support. (Optional, withhttpxp[cli])click- Command line client support. (Optional, withhttpxp[cli])brotliorbrotlicffi- Decoding for "brotli" compressed responses. (Optional, withhttpxp[brotli])zstandard- Decoding for "zstd" compressed responses. (Optional, withhttpxp[zstd])
A huge amount of credit is due to requests for the API layout that
much of this work follows, as well as to urllib3 for plenty of design
inspiration around the lower-level networking details.
with httpxp.Client(privacy_options={"emulation": "Chrome149"}) as client:
response = client.get(
"https://example.com",
extensions={"private": {"group": "account-one"}},
)See the privacy guide, complete implemented option reference, and API coverage audit. The migration is still in progress; the audit explicitly lists unsupported callbacks/runtime features, WebSocket limitations, and compatibility gaps.
Source installs build a PyO3 extension with Maturin and require Rust 1.98 or newer plus the native BoringSSL build tools (C/C++ compiler, CMake, Perl, and Clang/libclang). Prebuilt compatible wheels do not require a local Rust build. For development with a suitable installed nightly toolchain:
python -m venv .venv
.venv/bin/pip install maturin
RUSTUP_TOOLCHAIN=nightly .venv/bin/maturin developRun the supplied examples from the source checkout after installation with
python -m examples.private_proxy --help or
python -m examples.private_websocket --help.
HTTPXP is BSD licensed code.
Designed & crafted with care.
— ♥ —