explaingit

encode/httpx

Analysis updated 2026-06-24

15,264PythonAudience · developerComplexity · 2/5LicenseSetup · easy

TLDR

Python HTTP client that supports both sync and async usage, HTTP/2, strict timeouts, and direct calls into WSGI and ASGI apps. Familiar requests-style API.

Mindmap

mindmap
  root((httpx))
    Inputs
      URL and method
      Headers and body
      WSGI or ASGI app
    Outputs
      Response object
      Streamed bytes
      JSON data
    Use Cases
      Call REST APIs from async code
      Test a FastAPI app in process
      Run HTTP/2 requests
      Use as a CLI client
    Tech Stack
      Python
      asyncio
      trio
      HTTP/2
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Make async HTTP calls from a FastAPI or Starlette service

USE CASE 2

Test a FastAPI app in process by passing the ASGI app to httpx

USE CASE 3

Replace requests with httpx to add HTTP/2 and async support

USE CASE 4

Stream a large file download in chunks without holding it all in memory

What is it built with?

PythonasynciotrioHTTP/2

How does it compare?

encode/httpxfacebookresearch/detrpre-commit/pre-commit
Stars15,26415,26615,267
LanguagePythonPythonPython
Setup difficultyeasyhardeasy
Complexity2/54/52/5
Audiencedeveloperresearcherdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

HTTP/2 needs the optional h2 extra installed via pip install httpx[http2].

BSD license, free to use commercially with attribution.

In plain English

HTTPX is a Python library for making HTTP requests, meaning it lets your code talk to websites and web services by sending requests and receiving responses. It is written in Python and designed to work with Python 3.9 and later versions. What sets HTTPX apart from older tools is that it supports both synchronous and asynchronous usage. Synchronous means your code waits for each request to finish before moving on, which is the traditional approach. Asynchronous (using asyncio or trio) means your code can send many requests at the same time without waiting, which is useful when building faster apps. HTTPX also supports HTTP/2, a newer version of the web protocol that can handle multiple requests over a single connection more efficiently than HTTP/1.1. HTTPX includes a built-in command-line client, so you can send web requests directly from your terminal without writing any code, useful for quick testing. The library handles many common tasks automatically: it verifies SSL certificates for secure connections, manages cookies, supports authentication, handles automatic decompression of responses, and can send large files in chunks via streaming downloads. It can also make requests directly to WSGI and ASGI applications, which are Python web application formats, handy for testing your own web app without needing a live server. HTTPX enforces strict timeouts on all requests to prevent your program from hanging indefinitely. The project is BSD licensed.

Copy-paste prompts

Prompt 1
Show me an httpx.AsyncClient example that fans out 100 GET requests in parallel and gathers the responses
Prompt 2
Migrate this requests code to httpx and add a 5 second connect and read timeout
Prompt 3
Use httpx to test my FastAPI app in process by passing the ASGI app to the client
Prompt 4
Stream a multi gigabyte download with httpx without loading it all into memory

Frequently asked questions

What is httpx?

Python HTTP client that supports both sync and async usage, HTTP/2, strict timeouts, and direct calls into WSGI and ASGI apps. Familiar requests-style API.

What language is httpx written in?

Mainly Python. The stack also includes Python, asyncio, trio.

What license does httpx use?

BSD license, free to use commercially with attribution.

How hard is httpx to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is httpx for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Scan in gitsafehub Deploy in gitdeployhub encode on gitmyhub

Verify against the repo before relying on details.