httpx README

The project's README from github.com/encode/httpx. As one markdown file: README.md.

HTTPX

HTTPX - A next-generation HTTP client for Python.

Test Suite Package version

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:

$ pip install httpx

Now, let's get started:

>>> 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.

$ pip install 'httpx[cli]'  # The command line client is an optional dependency.

Which now allows us to use HTTPX directly from the command-line...

httpx --help

Sending a request...

httpx http://httpbin.org/json

Features

HTTPX builds on the well-established usability of requests, and gives you:

Plus all the standard features of requests...

Installation

Install with pip:

$ pip install httpx

Or, to include the optional HTTP/2 support, use:

$ pip install httpx[http2]

HTTPX requires Python 3.9+.

Documentation

Project documentation is available at https://www.python-httpx.org/.

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.

To find out about tools that integrate with HTTPX, see Third Party Packages.

Contribute

If you want to contribute with HTTPX check out the Contributing Guide to learn how to start.

Dependencies

The HTTPX project relies on these excellent libraries:

As well as these optional installs:

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.


HTTPX is BSD licensed code.
Designed & crafted with care.

— 🦋 —

httpx (encode/httpx)

Searching Database…

15.6K ·GitHub
What is this?HTTPX is a fully featured HTTP client library for Python 3, with a broadly requests-compatible API, HTTP/1.1 and HTTP/2 support, and both sync and async interfaces. It also ships with an integrated command-line client.
Is this a library or a command-line tool?Primarily a Python library you import in code, but the same project also ships an integrated command-line client, so you can send requests straight from the terminal without writing a script.
What do I need installed before I can use it?Python 3.9 or newer. pip installs the core dependencies (httpcore, h11, certifi, idna, sniffio) automatically, so there is nothing to set up beyond Python itself.
Is HTTP/2 supported out of the box?No. HTTP/2 comes via an optional extra: pip install httpx[http2]. Without it you are on HTTP/1.1, which still covers most APIs and everyday requests.
Why pick httpx over requests?It follows the familiar requests API but adds HTTP/1.1 and HTTP/2 support, async, direct calls to WSGI/ASGI apps, and strict timeouts everywhere — the README even credits requests for the API layout it follows.
Can I test my web app with it without running a server?Yes. httpx can send requests directly to WSGI and ASGI applications, so you can exercise an app in-process, which is handy for tests.
What can the command-line client do?After installing the httpx[cli] extra you can fire HTTP requests straight from the terminal, with rich terminal output provided by the rich library.
Is it mature enough for production?The codebase is fully type annotated with 100% test coverage, and it delegates low-level networking to battle-tested libraries like httpcore and h11.
Creator
encode
Size
8.4 MB
Stars
15.6K
Age
7y
Commits · 90 Days