README.md
This file
Path
README.md
149 lines · 4.8 KiB · Markdown
Last changed by
Update docs to reflect supported python versions (#2338)Fred Thomsenbefore adoption5af6123
History of this fileTake it
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150<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 integratedcommand line client**, has support for both **HTTP/1.1 and HTTP/2**, and provides both **syncand 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_code200>>> 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="docs/img/httpx-help.png" alt='httpx --help'></p>
Sending a request...
<p align="center"> <img width="700" src="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/#calling-into-python-web-apps) or [ASGI applications](https://www.python-httpx.org/async/#calling-into-python-web-apps).* 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.7+.
## 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.* `rfc3986` - URL parsing & normalization. * `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]`)*
A huge amount of credit is due to `requests` for the API layout thatmuch of this work follows, as well as to `urllib3` for plenty of designinspiration 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 & crafted with care.</i><br/>— 🦋 —</p>