freshcrate
Skin:/
Home > Frameworks > httpx

httpx

The next generation HTTP client.

Why this rank:Strong adoptionRelease freshnessHealthy release cadence

Description

<p align="center"> <a href="https://www.python-httpx.org/"><img width="350" height="208" src="https://raw.githubusercontent.com/encode/httpx/master/docs/img/butterfly.png" alt='HTTPX'></a> </p> <p align="center"><strong>HTTPX</strong> <em>- A next-generation HTTP client for Python.</em></p> <p align="center"> <a href="https://github.com/encode/httpx/actions"> <img src="https://github.com/encode/httpx/workflows/Test%20Suite/badge.svg" alt="Test Suite"> </a> <a href="https://pypi.org/project/httpx/"> <img src="https://badge.fury.io/py/httpx.svg" alt="Package version"> </a> </p> HTTPX 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 HTTPX using pip: ```shell $ pip install httpx ``` Now, let's get started: ```pycon >>> import httpx >>> r = httpx.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. ```shell $ pip install 'httpx[cli]' # The command line client is an optional dependency. ``` Which now allows us to use HTTPX directly from the command-line... <p align="center"> <img width="700" src="https://raw.githubusercontent.com/encode/httpx/master/docs/img/httpx-help.png" alt='httpx --help'> </p> Sending a request... <p align="center"> <img width="700" src="https://raw.githubusercontent.com/encode/httpx/master/docs/img/httpx-request.png" alt='httpx http://httpbin.org/json'> </p> ## Features HTTPX builds on the well-established usability of `requests`, and gives you: * A broadly [requests-compatible API](https://www.python-httpx.org/compatibility/). * An integrated command-line client. * HTTP/1.1 [and HTTP/2 support](https://www.python-httpx.org/http2/). * Standard synchronous interface, but with [async support if you need it](https://www.python-httpx.org/async/). * Ability to make requests directly to [WSGI applications](https://www.python-httpx.org/advanced/transports/#wsgi-transport) or [ASGI applications](https://www.python-httpx.org/advanced/transports/#asgi-transport). * 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 ## Installation Install with pip: ```shell $ pip install httpx ``` Or, to include the optional HTTP/2 support, use: ```shell $ pip install httpx[http2] ``` HTTPX requires Python 3.8+. ## Documentation Project documentation is available at [https://www.python-httpx.org/](https://www.python-httpx.org/). For a run-through of all the basics, head over to the [QuickStart](https://www.python-httpx.org/quickstart/). For more advanced topics, see the [Advanced Usage](https://www.python-httpx.org/advanced/) section, the [async support](https://www.python-httpx.org/async/) section, or the [HTTP/2](https://www.python-httpx.org/http2/) section. The [Developer Interface](https://www.python-httpx.org/api/) provides a comprehensive API reference. To find out about tools that integrate with HTTPX, see [Third Party Packages](https://www.python-httpx.org/third_party_packages/). ## Contribute If you want to contribute with HTTPX check out the [Contributing Guide](https://www.python-httpx.org/contributing/) to learn how to start. ## Dependencies The HTTPX project relies on these excellent libraries: * `httpcore` - The underlying transport implementation for `httpx`. * `h11` - HTTP/1.1 support. * `certifi` - SSL certificates. * `idna` - Internationalized domain name support. * `sniffio` - Async library autodetection. As well as these optional installs: * `h2` - HTTP/2 support. *(Optional, with `httpx[http2]`)* * `socksio` - SOCKS proxy support. *(Optional, with `httpx[socks]`)* * `rich` - Rich terminal support. *(Optional, with `httpx[cli]`)* * `click` - Command line client support. *(Optional, with `httpx[cli]`)* * `brotli` or `brotlicffi` - Decoding for "brotli" compressed responses. *(Optional, with `httpx[brotli]`)* * `zstandard` - Decoding for "zstd" compressed responses. *(Optional, with `httpx[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. --- <p align="center"><i>HTTPX is <a href="https://github.com/encode/httpx/blob/master/LICENSE.md">BSD licensed</a> code.<br/>Designed &

Release History

VersionChangesUrgencyDate
0.28.1Imported from PyPI (0.28.1)Low4/21/2026
0.28.0## 0.28.0 (28th November, 2024) The 0.28 release includes a limited set of deprecations. **Deprecations**: We are working towards a simplified SSL configuration API. *For users of the standard `verify=True` or `verify=False` cases, or `verify=<ssl_context>` case this should require no changes. The following cases have been deprecated...* * The `verify` argument as a string argument is now deprecated and will raise warnings. * The `cert` argument is now deprecated and will raise wLow11/28/2024
0.27.2## 0.27.2 (27th August, 2024) ### Fixed * Reintroduced supposedly-private `URLTypes` shortcut. (#2673)Low8/27/2024
0.27.1## 0.27.1 (27th August, 2024) ## Added * Support for `zstd` content decoding using the python `zstandard` package is added. Installable using `httpx[zstd]`. (#3139) ### Fixed * Improved error messaging for `InvalidURL` exceptions. (#3250) * Fix `app` type signature in `ASGITransport`. (#3109)Low8/27/2024
0.27.0## 0.27.0 (21st February, 2024) ### Deprecated * The `app=...` shortcut has been deprecated. Use the explicit style of `transport=httpx.WSGITransport()` or `transport=httpx.ASGITransport()` instead. ### Fixed * Respect the `http1` argument while configuring proxy transports. (#3023) * Fix RFC 2069 mode digest authentication. (#3045)Low2/21/2024
0.26.0## 0.26.0 (20th December, 2023) ### Added * The `proxy` argument was added. You should use the `proxy` argument instead of the deprecated `proxies`, or use `mounts=` for more complex configurations. (#2879) ### Deprecated * The `proxies` argument is now deprecated. It will still continue to work, but it will be removed in the future. (#2879) ### Fixed * Fix cases of double escaping of URL path components. Allow / as a safe character in the query portion. (#2990) * Handle `NO_PLow12/20/2023
0.25.2## 0.25.2 (24th November, 2023) ### Added * Add missing type hints to few `__init__()` methods. (#2938) Low11/24/2023
0.25.1## 0.25.1 (3rd November, 2023) * Add support for Python 3.12. (#2854) * Add support for httpcore 1.0 (#2885) ### Fixed * Raise `ValueError` on `Response.encoding` being set after `Response.text` has been accessed. (#2852)Low11/3/2023
0.25.0## 0.25.0 (11th Sep, 2023) ### Removed * Drop support for Python 3.7. (#2813) ### Added * Support HTTPS proxies. (#2845) * Change the type of `Extensions` from `Mapping[Str, Any]` to `MutableMapping[Str, Any]`. (#2803) * Add `socket_options` argument to `httpx.HTTPTransport` and `httpx.AsyncHTTPTransport` classes. (#2716) * The `Response.raise_for_status()` method now returns the response instance. For example: `data = httpx.get('...').raise_for_status().json()`. (#2776) ### FiLow9/11/2023
0.24.1## 0.24.1 (17th May, 2023) ### Added * Provide additional context in some `InvalidURL` exceptions. (#2675) ### Fixed * Fix optional percent-encoding behaviour. (#2671) * More robust checking for opening upload files in binary mode. (#2630) * Properly support IP addresses in `NO_PROXY` environment variable. (#2659) * Set default file for `NetRCAuth()` to `None` to use the stdlib default. (#2667) * Set logging request lines to INFO level for async requests, in line with sync requesLow5/18/2023
0.24.0## 0.24.0 (6th April, 2023) ### Changed * The logging behaviour has been change to be more in-line with other standard Python logging usages. We no longer have a custom `TRACE` log level, and we no longer use the `HTTPX_LOG_LEVEL` environment variable to auto-configure logging. We now have a significant amount of `DEBUG` logging available at the network level. Full documentation is available at https://www.python-httpx.org/logging/ (#2547, encode/httpcore#648) * The `Response.iter_lines()Low4/11/2023
0.23.3## 0.23.3 (4th Jan, 2023) ### Fixed * Version 0.23.2 accidentally included stricter type checking on query parameters. This shouldn've have been included in a minor version bump, and is now reverted. (#2523, #2539)Low1/4/2023
0.23.2## 0.23.2 (2nd Jan, 2023) ### Added * Support digest auth nonce counting to avoid multiple auth requests. (#2463) ### Fixed * Multipart file uploads where the file length cannot be determine now use chunked transfer encoding, rather than loading the entire file into memory in order to determine the `Content-Length`. (#2382) * Raise `TypeError` if content is passed a dict-instance. (#2495) * Partially revert the API breaking change in 0.23.1, which removed `RawURL`. We continuLow1/2/2023
0.23.1## 0.23.1 ### Added * Support for Python 3.11. (#2420) * Allow setting an explicit multipart boundary in `Content-Type` header. (#2278) * Allow `tuple` or `list` for multipart values, not just `list`. (#2355) * Allow `str` content for multipart upload files. (#2400) * Support connection upgrades. See https://www.encode.io/httpcore/extensions/#upgrade-requests ### Fixed * Don't drop empty query parameters. (#2354) ### Removed * Drop `.read`/`.aread` from SyncByteStream/AsyncLow11/18/2022
0.23.0## 0.23.0 (23rd May, 2022) ### Changed * Drop support for Python 3.6. (#2097) * Use `utf-8` as the default character set, instead of falling back to `charset-normalizer` for auto-detection. To enable automatic character set detection, see [the documentation](https://www.python-httpx.org/advanced/#character-set-encodings-and-auto-detection). (#2165) ### Fixed * Fix `URL.copy_with` for some oddly formed URL cases. (#2185) * Digest authentication should use case-insensitive compLow5/23/2022
0.22.0## 0.22.0 (26th January, 2022) ### Added * Support for [the SOCKS5 proxy protocol](https://www.python-httpx.org/advanced/#socks) via [the `socksio` package](https://github.com/sethmlarson/socksio). (#2034) * Support for custom headers in multipart/form-data requests (#1936) ### Fixed * Don't perform unreliable close/warning on `__del__` with unclosed clients. (#2026) * Fix `Headers.update(...)` to correctly handle repeated headers (#2038)Low1/26/2022
0.21.3## 0.21.3 (6th January, 2022) ### Fixed * Fix streaming uploads using `SyncByteStream` or `AsyncByteStream`. Regression in 0.21.2. (#2016)Low1/6/2022
0.21.2## 0.21.2 (5th January, 2022) ### Fixed * HTTP/2 support for tunnelled proxy cases. (#2009) * Improved the speed of large file uploads. (#1948)Low1/5/2022
0.21.1## 0.21.1 (16th November, 2021) ### Fixed * The `response.url` property is now correctly annotated as `URL`, instead of `Optional[URL]`. (#1940)Low11/16/2021
0.21.0## 0.21.0 (15th November, 2021) The 0.21.0 release integrates against a newly redesigned `httpcore` backend. Both packages ought to automatically update to the required versions, but if you are seeing any issues, you should ensure that you have `httpx==0.21.*` and `httpcore==0.14.*` installed. ### Added * The command-line client will now display connection information when `-v/--verbose` is used. * The command-line client will now display server certificate information when `-v/--vLow11/15/2021
0.20.0## 0.20.0 (13th October, 2021) The 0.20.0 release adds an integrated command-line client, and also includes some design changes. The most notable of these is that redirect responses are no longer automatically followed, unless specifically requested. This design decision prioritises a more explicit approach to redirects, in order to avoid code that unintentionally issues multiple requests as a result of misconfigured URLs. For example, previously a client configured to send requests to Low10/13/2021
1.0.0.beta0## 1.0.0.beta0 (14th September 2021) The 1.0 pre-release adds an integrated command-line client, and also includes some design changes. The most notable of these is that redirect responses are no longer automatically followed, unless specifically requested. This design decision prioritises a more explicit approach to redirects, in order to avoid code that unintentionally issues multiple requests as a result of misconfigured URLs. For example, previously a client configured to send requeLow9/14/2021
0.19.0## 0.19.0 (19th August, 2021) ### Added * Add support for `Client(allow_redirects=<bool>)`. (Pull #1790) * Add automatic character set detection, when no `charset` is included in the response `Content-Type` header. (Pull #1791) ### Changed * Event hooks are now also called for any additional redirect or auth requests/responses. (Pull #1806) * Strictly enforce that upload files must be opened in binary mode. (Pull #1736) * Strictly enforce that client instances can only be oLow8/19/2021
0.18.2## 0.18.2 (17th June, 2021) ### Added * Support for Python 3.10. (Pull #1687) * Expose `httpx.USE_CLIENT_DEFAULT`, used as the default to `auth` and `timeout` parameters in request methods. (Pull #1634) * Support [HTTP/2 "prior knowledge"](https://python-hyper.org/projects/hyper-h2/en/v2.3.1/negotiating-http2.html#prior-knowledge), using `httpx.Client(http1=False, http2=True)`. (Pull #1624) ### Fixed * Clean up some cases where warnings were being issued. (Pull #1687) * Prefer ConLow6/17/2021
0.18.1## 0.18.1 (29th April, 2021) ### Changed * Update brotli support to use the `brotlicffi` package (Pull #1605) * Ensure that `Request(..., stream=...)` does not auto-generate any headers on the request instance. (Pull #1607) ### Fixed * Pass through `timeout=...` in top-level httpx.stream() function. (Pull #1613) * Map httpcore transport close exceptions to httpx exceptions. (Pull #1606)Low4/29/2021
0.18.0## 0.18.0 (27th April, 2021) The 0.18.x release series formalises our low-level Transport API, introducing the base classes `httpx.BaseTransport` and `httpx.AsyncBaseTransport`. See the "[Writing custom transports](https://www.python-httpx.org/advanced/#writing-custom-transports)" documentation and the [`httpx.BaseTransport.handle_request()`](https://github.com/encode/httpx/blob/397aad98fdc8b7580a5fc3e88f1578b4302c6382/httpx/_transports/base.py#L77-L147) docstring for more complete detailsLow4/27/2021
0.17.1## 0.17.1 ### Fixed * Type annotation on `CertTypes` allows `keyfile` and `password` to be optional. (Pull #1503) * Fix httpcore pinned version. (Pull #1495)Low3/15/2021
0.17.0## 0.17.0 ### Added * Add `httpx.MockTransport()`, allowing to mock out a transport using pre-determined responses. (Pull #1401, Pull #1449) * Add `httpx.HTTPTransport()` and `httpx.AsyncHTTPTransport()` default transports. (Pull #1399) * Add mount API support, using `httpx.Client(mounts=...)`. (Pull #1362) * Add `chunk_size` parameter to `iter_raw()`, `iter_bytes()`, `iter_text()`. (Pull #1277) * Add `keepalive_expiry` parameter to `httpx.Limits()` configuration. (Pull #1398) * Add rLow2/28/2021
0.16.1## 0.16.1 (October 8th, 2020) ### Fixed * Support literal IPv6 addresses in URLs. (Pull #1349) * Force lowercase headers in ASGI scope dictionaries. (Pull #1351)Low10/8/2020
0.16.0## 0.16.0 (October 6th, 2020) ### Changed * Preserve HTTP header casing. (Pull #1338, encode/httpcore#216, python-hyper/h11#104) * Drop `response.next()` and `response.anext()` methods in favour of `response.next_request` attribute. (Pull #1339) * Closed clients now raise a runtime error if attempting to send a request. (Pull #1346) ### Added * Add Python 3.9 to officially supported versions. * Type annotate `__enter__`/`__exit__`/`__aenter__`/`__aexit__` in a way that supports suLow10/6/2020
0.15.5## 0.15.5 (October 1st, 2020) ### Added * Add `response.next_request` (Pull ##1334) Low10/1/2020
0.15.4## 0.15.4 (September 25th, 2020) ### Added * Support direct comparisons between `Headers` and dicts or lists of two-tuples. Eg. `assert response.headers == {"Content-Length": 24}` (Pull #1326) ### Fixed * Fix automatic `.read()` when `Response` instances are created with `content=<str>` (Pull #1324)Low9/25/2020
0.15.3## 0.15.3 (September 24th, 2020) ### Fixed * Fixed connection leak in async client due to improper closing of response streams. (Pull #1316) Low9/24/2020
0.15.2## 0.15.2 (September 23nd, 2020) ### Fixed * Fixed `response.elapsed` property. (Pull #1313) * Fixed client authentication interaction with `.stream()`. (Pull #1312)Low9/23/2020
0.15.1## 0.15.1 (September 23nd, 2020) ### Fixed * ASGITransport now properly applies URL decoding to the `path` component, as-per the ASGI spec. (Pull #1307)Low9/23/2020
0.15.0## 0.15.0 (22nd September 2020) ### Added * Added support for curio. (Pull https://github.com/encode/httpcore/pull/168) * Added support for event hooks. (Pull #1246) * Added support for authentication flows which require either sync or async I/O. (Pull #1217) * Added support for monitoring download progress with `response.num_bytes_downloaded`. (Pull #1268) * Added `Request(content=...)` for byte content, instead of overloading `Request(data=...)` (Pull #1266) * Added support for all Low9/22/2020
0.14.3## 0.14.3 (September 2nd, 2020) ### Added * `http.Response()` may now be instantiated without a `request=...` parameter. Useful for some unit testing cases. (Pull #1238) * Add `103 Early Hints` and `425 Too Early` status codes. (Pull #1244) ### Fixed * `DigestAuth` now handles responses that include multiple 'WWW-Authenticate' headers. (Pull #1240) * Call into transport `__enter__`/`__exit__` or `__aenter__`/`__aexit__` when client is used in a context manager style. (Pull #1218)Low9/2/2020
0.14.2## 0.14.2 (August 24th, 2020) ### Added * Support `client.get(..., auth=None)` to bypass the default authentication on a clients. (Pull #1115) * Support `client.auth = ...` property setter. (Pull #1185) * Support `httpx.get(..., proxies=...)` on top-level request functions. (Pull #1198) * Display instances with nicer import styles. (Eg. <httpx.ReadTimeout ...>) (Pull #1155) * Support `cookies=[(key, value)]` list-of-two-tuples style usage. (Pull #1211) ### Fixed * Ensure that autLow8/24/2020
0.14.1## 0.14.1 (August 11th, 2020) ### Added * The `httpx.URL(...)` class now raises `httpx.InvalidURL` on invalid URLs, rather than exposing the underlying `rfc3986` exception. If a redirect response includes an invalid 'Location' header, then a `RemoteProtocolError` exception is raised, which will be associated with the request that caused it. (Pull #1163) ### Fixed * Handling multiple `Set-Cookie` headers became broken in the 0.14.0 release, and is now resolved. (Pull #1156)Low8/11/2020
0.14.0## 0.14.0 (August 7th, 2020) The 0.14 release includes a range of improvements to the public API, intended on preparing for our upcoming 1.0 release. * Our HTTP/2 support is now fully optional. **You now need to use `pip install httpx[http2]` if you want to include the HTTP/2 dependancies.** * Our HSTS support has now been removed. Rewriting URLs from `http` to `https` if the host is on the HSTS list can be beneficial in avoiding roundtrips to incorrectly formed URLs, but on balance we'veLow8/7/2020
0.13.3## 0.13.3 (May 29th, 2020) ### Fixed * Include missing keepalive expiry configuration. (Pull #1005) * Improved error message when URL redirect has a custom scheme. (Pull #1002)Low5/29/2020
0.13.2## 0.13.2 (May 27th, 2020) ### Fixed * Include explicit "Content-Length: 0" on POST, PUT, PATCH if no request body is used. (Pull #995) * Add `http2` option to `httpx.Client`. (Pull #982) * Tighten up API typing in places. (Pull #992, #999)Low5/27/2020
0.13.1## 0.13.1 (May 22nd, 2020) ### Fixed * Fix pool options deprecation warning. (Pull #980) * Include `httpx.URLLib3ProxyTransport` in top-level API. (Pull #979)Low5/22/2020
0.13.0## 0.13.0 (May 22nd, 2020) This release switches to `httpcore` for all the internal networking, which means: * We're using the same codebase for both our sync and async clients. * HTTP/2 support is now available with the sync client. * We no longer have a `urllib3` dependency for our sync client, although there is still an *optional* `URLLib3Transport` class. It also means we've had to remove our UDS support, since maintaining that would have meant having to push back our work towardsLow5/22/2020
0.13.0.dev2## 0.13.0.dev2 (May 12th, 2020) The 0.13.0.dev2 is a *pre-release* version. To install it, use `pip install httpx --pre`. ### Added - Logging via HTTPCORE_LOG_LEVEL and HTTPX_LOG_LEVEL environment variables and TRACE level logging. (HTTPCore Pull #79) ### Fixed - Reuse of connections on HTTP/2 in close concurrency situations. (HTTPCore Pull #81) - When using an `app=<ASGI app>` observe neater disconnect behaviour instead of sending empty body messages. (Pull #919)Low5/12/2020
0.13.0.dev1## 0.13.0.dev1 (May 6th, 2020) The 0.13.0.dev1 is a *pre-release* version. To install it, use `pip install httpx --pre`. ### Fixed - Passing `http2` flag to proxy dispatchers. (Pull #934) - Use [`httpcore` v0.8.3](https://github.com/encode/httpcore/releases/tag/0.8.3) which addresses problems in handling of headers when using proxies.Low5/6/2020
0.13.0.dev0## 0.13.0.dev0 (April 30th, 2020) The 0.13.0.dev0 is a *pre-release* version. To install it, use `pip install httpx --pre`. This release switches to `httpcore` for all the internal networking, which means: * We're using the same codebase for both our sync and async clients. * HTTP/2 support is now available with the sync client. * We no longer have a `urllib3` dependency for our sync client, although there is still an *optional* `URLLib3Dispatcher` class. It also means we've had toLow4/30/2020
0.7.5version 0.7.5Low10/10/2019
0.7.4Release 0.7.4Low10/4/2019
0.7.3Release 0.7.3Low10/4/2019

Dependencies & License Audit

Loading dependencies...

Similar Packages

tqdmFast, Extensible Progress Meterv4.68.1
inspect-aiFramework for large language model evaluationsmain@2026-06-05
hypothesisThe property-based testing library for Pythonv6.155.2
bleachAn easy safelist-based HTML-sanitizing tool.main@2026-06-05
jupyter-clientJupyter protocol implementation and client librariesv8.9.0

More from pypi

markitdownUtility tool for converting various files to Markdown
fastapiFastAPI framework, high performance, easy to learn, fast to code, ready for production
djangoA high-level Python web framework that encourages rapid development and clean, pragmatic design.
flaskA simple framework for building complex web applications.

More in Frameworks

langchainThe agent engineering platform
deer-flowAn open-source long-horizon SuperAgent harness that researches, codes, and creates. With the help of sandboxes, memories, tools, skill, subagents and message gateway, it handles different levels of ta
tqdmFast, Extensible Progress Meter
simBuild, deploy, and orchestrate AI agents. Sim is the central intelligence layer for your AI workforce.