1. License
“Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met”
Allowed in paid and closed-source apps; keep the copyright notice and license text with any copy of its code.
github.com/encode/httpx/blob/master/LICENSE.md3. Used by agents' projects
Dependency in 280 public GitHub projects set up for AI coding agents that we scanned (4.5%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
From the package registry and GitHub, checked daily; card checked Nov 11, 2026. Tap a verdict to see its source.How we checkedReport an error
What httpx does
HTTPX is a free Python library your app uses to talk to other web services, such as a payment provider, a weather service or an AI model. It works in plain scripts and in async web apps, and it gives up on slow servers after 5 seconds by default. It is the usual pick when code that used Requests has to run inside an async app.
What people build with it
Call an outside service safely
Your backend asks a shipping or payment service for data, waits at most 10 seconds and stops with a clear error when the answer is an error page.
Many calls at once in async apps
A FastAPI page needs prices from five places; your app asks all five at the same time instead of one after another.
Test code without real network calls
In tests, your assistant swaps the network for a fake that returns ready answers, so tests run offline and never hit a paid service.
Download big files without filling memory
Your app saves a large export or video to disk piece by piece instead of holding the whole file in memory.
Test your own FastAPI app directly
Tests call your FastAPI or other async web app straight in Python, with no server started.
Faster calls to AI model services Idea
An app that sends many requests to one AI service turns on HTTP/2, so they share one connection.
httpx popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How httpx is used
- httpx is a dependency in 280 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (17.3% of the 1,623 Python ones), #3 of 126 in http clients and networking.
- Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 685; those are left out of every share on this page.
- The most used alternative in our scan is Requests (425 projects).
- Projects that use it most often also use Pydantic (56.8%), Uvicorn (52.5%), python-dotenv (50.4%).
- It is more common in projects set up for OpenClaw (7.8%) than for Devin Desktop (2.2%).
By coding agent
Often used with
httpx in practice
Strengths
The site lists "a broadly requests-compatible API" among its features. Calls are synchronous by default, and async support is there "if you need it".
httpx can send requests directly to a WSGI or ASGI application rather than to a network address. The docs list this among the features.
<code>raise_for_status()</code> raises <code>HTTPStatusError</code> on non-2xx responses. On success it returns the response itself, so <code>httpx.get('...').raise_for_status().json()</code> works in one line.
<code>httpx.stream(...)</code> is used as a context manager. You iterate with <code>iter_bytes()</code>, <code>iter_text()</code> or <code>iter_lines()</code>. <code>iter_raw()</code> skips content decoding entirely.
Watch out for
Miguel Mendez reports random crashes ending in <code>httpx.ReadError</code> from his async client as traffic grew. The error appeared only under heavy traffic, and not every time. He calls it a generic error that "doesn’t give much detail". He then found a GitHub issue that, in his words, "provided insight into the performance limitations of httpx when compared to aiohttp", and switched to aiohttp. He does not pin down a root cause.
The dependency list marks HTTP/2 support (<code>h2</code>) and SOCKS proxy support (<code>socksio</code>) as optional, installed with <code>httpx[http2]</code> and <code>httpx[socks]</code>. A plain <code>pip install httpx</code> does not include them.
HTTPX requires Python 3.9+. Brotli and zstd decoding come from the <code>httpx[brotli,zstd]</code> extras. The site's dependency list names <code>brotli</code> or <code>brotlicffi</code> for brotli decoding. The quickstart page instead says "If brotlipy is installed".
A first GET request
>>> 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>...'More about httpx
Funding
- GitHub Sponsors: https://github.com/encode
- 29 GitHub sponsors
Head to head
- Requests vs httpx used together in 56 projects
- httpx vs aiohttp used together in 32 projects
- httpx vs urllib3 used together in 14 projects
Packages around it
- pydantic: Data validation
- uvicorn: ASGI server
- python-dotenv: .env file loader
- fastapi: Web API framework
- mcp: Model Context Protocol SDK
- pydantic-settings: Settings from env vars
More in HTTP clients and networking
Alternatives
httpx This page
Pick Requests for plain sync scripts where async is never needed; it follows redirects by default and has no default timeout.
Pick aiohttp for an asyncio-only app that also needs a web server or WebSocket client in the same library.
Pick urllib3 for a lower-level sync client with built-in retries on error answers and connection pooling.
Get started
Tell your AI assistant
“Use the Python library httpx (pin httpx==0.28.1, Python 3.9+) with one shared httpx.Client or httpx.AsyncClient, set timeout and follow_redirects explicitly, call raise_for_status() on every response, and use httpx.MockTransport in tests.”
Install HTTPX into your project's Python environment.
pip install httpxMake a request and read the answer.
>>> import httpx >>> r = httpx.get('https://www.example.org/') >>> r.status_code 200In async code, use AsyncClient inside an async with block.
>>> async with httpx.AsyncClient() as client: ... r = await client.get('https://www.example.com/')
Rules for your agent
## httpx
- Add extras only when the feature is used: `httpx[http2]` for HTTP/2, `httpx[socks]` for SOCKS proxies, `httpx[cli]` for the command-line client, `httpx[brotli]` / `httpx[zstd]` for those decoders.
- Pass query parameters with `params=`. Send form data with `data=`, files with `files=`, JSON with `json=`, and raw bytes or a bytes generator with `content=`.
- Call `raise_for_status()` when non-2xx responses should fail. It returns the response, so `httpx.get(...).raise_for_status().json()` works inline.
- For large downloads, use `httpx.stream(...)` as a context manager with `iter_bytes()`, `iter_text()` or `iter_lines()` instead of reading `r.content`.
- Use `iter_raw()` only when you need the body without gzip, deflate, brotli or zstd decoding.
- Header lookups are case-insensitive, and repeated headers are merged into one comma-separated value. If you need to override the standard encoding behaviour, set `r.encoding`.
- Target Python 3.9+.
Mistakes to avoid
proxies= was removed in 0.28; in our run on 0.28.1 it raised TypeError: unexpected keyword argument 'proxies'.
app= was removed in 0.28; in our run it raised TypeError: unexpected keyword argument 'app'.
HTTPX returns the 301/302 answer itself; our demo got 301 until follow_redirects=True.
The default raises a timeout after 5 seconds of inactivity; our demo got ReadTimeout with timeout=1.0.
Pre-release 1.0 builds are a redesigned client-and-server toolkit, not a drop-in upgrade of 0.28.
Questions
Can I switch from Requests by changing the import?
Mostly. The interface is close to Requests, but redirects are off by default, timeouts are on, and requests.Session becomes httpx.Client.
Why does my request fail with a timeout when Requests worked?
HTTPX stops after 5 seconds without network activity. Set timeout=30.0 or more, or timeout=None to wait forever.
Does it support HTTP/2?
Yes, after pip install httpx[http2] and http2=True on the client.
Can I use it in a paid app?
Yes. BSD-3-Clause allows commercial and closed-source use; keep the copyright notice if you ship its code.
How do I send requests through a proxy?
Pass proxy="http://..." to the client. The old proxies= argument was removed in 0.28.