{
 "kind": "tool",
 "slug": "httpx",
 "path": "tools/httpx/",
 "name": "httpx",
 "maker": null,
 "density": "full",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "HTTP clients and networking",
   "tools/http-clients/"
  ]
 ],
 "lead": "Call web services from Python, sync or async.",
 "chips": [
  {
   "label": "HTTP clients and networking",
   "path": "tools/http-clients/"
  },
  {
   "label": "PYPI"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "pip install httpx"
 },
 "links": [
  {
   "label": "GitHub",
   "href": "https://github.com/encode/httpx"
  },
  {
   "label": "Website",
   "href": "https://github.com/encode/httpx"
  }
 ],
 "track": "New versions, deprecation and license changes on your dashboard",
 "verdicts": [
  {
   "key": "license",
   "label": "License",
   "value": "BSD",
   "status": "yes",
   "sub": "Use it in paid apps",
   "quote": "Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met",
   "note": "Allowed in paid and closed-source apps; keep the copyright notice and license text with any copy of its code.",
   "src": "https://github.com/encode/httpx/blob/master/LICENSE.md"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Maintained",
   "status": "yes",
   "sub": "Last change Nov 16, 2026",
   "note": "Latest GitHub release Dec 6, 2024. ",
   "src": "https://github.com/encode/httpx"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "280 projects",
   "status": "info",
   "sub": "#3 of 126 in its category",
   "note": "Dependency in 280 public GitHub projects set up for AI coding agents that we scanned (4.5%).",
   "src": null
  },
  {
   "key": "agent",
   "label": "Agent access",
   "value": "Install only",
   "status": "info",
   "sub": null,
   "note": "Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.",
   "src": null
  }
 ],
 "vfoot": "From the package registry and GitHub, checked daily; card checked Nov 11, 2026.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What httpx does",
   "parts": [
    {
     "t": "prose",
     "text": "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."
    },
    {
     "t": "h3",
     "text": "What people build with it"
    },
    {
     "t": "uses",
     "items": [
      {
       "title": "Call an outside service safely",
       "text": "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.",
       "idea": false
      },
      {
       "title": "Many calls at once in async apps",
       "text": "A FastAPI page needs prices from five places; your app asks all five at the same time instead of one after another.",
       "idea": false
      },
      {
       "title": "Test code without real network calls",
       "text": "In tests, your assistant swaps the network for a fake that returns ready answers, so tests run offline and never hit a paid service.",
       "idea": false
      },
      {
       "title": "Download big files without filling memory",
       "text": "Your app saves a large export or video to disk piece by piece instead of holding the whole file in memory.",
       "idea": false
      },
      {
       "title": "Test your own FastAPI app directly",
       "text": "Tests call your FastAPI or other async web app straight in Python, with no server started.",
       "idea": false
      },
      {
       "title": "Faster calls to AI model services",
       "text": "An app that sends many requests to one AI service turns on HTTP/2, so they share one connection.",
       "idea": true
      }
     ]
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "httpx popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "78",
       "of": "/ 100",
       "l": "Gid Score, #140 overall"
      },
      {
       "n": "198M",
       "l": "downloads a week, pypi"
      },
      {
       "n": "15.8K",
       "l": "GitHub stars"
      },
      {
       "n": "280",
       "l": "agent projects use it"
      }
     ]
    },
    {
     "t": "small",
     "text": "Gid Score measures public popularity and activity, not quality.",
     "link": "How the Gid Score is calculated",
     "path": "tools/top/"
    }
   ]
  },
  {
   "id": "usage",
   "nav": "How it is used",
   "h2": "How httpx is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "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%)."
     ]
    },
    {
     "t": "h3",
     "text": "By coding agent"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "144 projects, 4.4%",
       "v": "Claude Code",
       "path": "agents/claude-code/"
      },
      {
       "l": "128 projects, 4.2%",
       "v": "GitHub Copilot",
       "path": "agents/github-copilot/"
      },
      {
       "l": "85 projects, 3.5%",
       "v": "Cursor",
       "path": "agents/cursor/"
      },
      {
       "l": "26 projects, 7.8%",
       "v": "OpenClaw",
       "path": "agents/openclaw/"
      },
      {
       "l": "16 projects, 3.4%",
       "v": "Gemini CLI",
       "path": "agents/gemini-cli/"
      },
      {
       "l": "13 projects, 3.8%",
       "v": "OpenCode",
       "path": "agents/opencode/"
      },
      {
       "l": "11 projects, 2.3%",
       "v": "OpenAI Codex",
       "path": "agents/openai-codex/"
      },
      {
       "l": "6 projects, 2.2%",
       "v": "Devin Desktop",
       "path": "agents/devin-desktop/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 56.8% of its projects",
       "v": "Pydantic",
       "path": "tools/pydantic/"
      },
      {
       "l": "In 52.5% of its projects",
       "v": "Uvicorn",
       "path": "tools/uvicorn/"
      },
      {
       "l": "In 50.4% of its projects",
       "v": "python-dotenv",
       "path": "tools/python-dotenv/"
      },
      {
       "l": "In 48.6% of its projects",
       "v": "FastAPI",
       "path": "tools/fastapi/"
      },
      {
       "l": "In 43.9% of its projects",
       "v": "Model Context Protocol SDK (Python)",
       "path": "tools/mcp/"
      },
      {
       "l": "In 32.9% of its projects",
       "v": "PyYAML",
       "path": "tools/pyyaml/"
      },
      {
       "l": "In 32.1% of its projects",
       "v": "Pydantic Settings",
       "path": "tools/pydantic-settings/"
      },
      {
       "l": "In 26.1% of its projects",
       "v": "Rich",
       "path": "tools/rich/"
      }
     ]
    }
   ]
  },
  {
   "id": "profile",
   "nav": "Profile",
   "h2": "httpx in practice",
   "parts": [
    {
     "t": "h3",
     "text": "Strengths"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "Close to requests, with async on the side",
       "v": "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\"."
      },
      {
       "l": "Calls into WSGI and ASGI apps without a socket",
       "v": "httpx can send requests directly to a WSGI or ASGI application rather than to a network address. The docs list this among the features."
      },
      {
       "l": "raise_for_status() chains inline",
       "v": "<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."
      },
      {
       "l": "Streaming without loading the whole body",
       "v": "<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."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Watch out for"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "Intermittent ReadError reported under heavy traffic",
       "v": "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."
      },
      {
       "l": "HTTP/2 and SOCKS need extras",
       "v": "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."
      },
      {
       "l": "Python 3.9+, and two pages name different brotli packages",
       "v": "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\"."
      }
     ]
    },
    {
     "t": "h3",
     "text": "A first GET request"
    },
    {
     "t": "tabs",
     "label": "Example",
     "items": [
      {
       "tab": "Pycon",
       "code": ">>> import httpx\n>>> r = httpx.get('https://www.example.org/')\n>>> r\n<Response [200 OK]>\n>>> r.status_code\n200\n>>> r.headers['content-type']\n'text/html; charset=UTF-8'\n>>> r.text\n'<!doctype html>\\n<html>\\n<head>\\n<title>Example Domain</title>...'"
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "profile",
   "h2": "More about httpx",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "Funding",
       "path": "tools/funding/",
       "items": [
        "GitHub Sponsors: https://github.com/encode",
        "29 GitHub sponsors"
       ]
      },
      {
       "title": "Head to head",
       "items": [
        {
         "text": "Requests vs httpx",
         "note": "used together in 56 projects",
         "path": "tools/compare/requests-vs-httpx/"
        },
        {
         "text": "httpx vs aiohttp",
         "note": "used together in 32 projects",
         "path": "tools/compare/httpx-vs-aiohttp/"
        },
        {
         "text": "httpx vs urllib3",
         "note": "used together in 14 projects",
         "path": "tools/compare/httpx-vs-urllib3/"
        }
       ]
      },
      {
       "title": "Packages around it",
       "items": [
        "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"
       ]
      },
      {
       "title": "More in HTTP clients and networking",
       "path": "tools/http-clients/",
       "items": [
        {
         "text": "Axios",
         "path": "tools/axios/"
        },
        {
         "text": "ws",
         "path": "tools/ws/"
        },
        {
         "text": "postgres",
         "path": "tools/postgres/"
        },
        {
         "text": "websockets",
         "path": "tools/websockets/"
        },
        {
         "text": "redis (Python)",
         "path": "tools/redis-pypi/"
        },
        {
         "text": "undici",
         "path": "tools/undici/"
        },
        {
         "text": "node-fetch",
         "path": "tools/node-fetch/"
        },
        {
         "text": "ioredis",
         "path": "tools/ioredis/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "httpx",
       "me": true,
       "facts": [
        "BSD",
        "Gid 78",
        "198M/wk"
       ]
      },
      {
       "name": "Requests",
       "why": "Pick Requests for plain sync scripts where async is never needed; it follows redirects by default and has no default timeout.",
       "path": "tools/requests-py/",
       "facts": [
        "Apache-2.0",
        "Gid 88",
        "35M/wk"
       ]
      },
      {
       "name": "aiohttp",
       "why": "Pick aiohttp for an asyncio-only app that also needs a web server or WebSocket client in the same library.",
       "path": "tools/aiohttp/",
       "facts": [
        "Apache-2.0 AND MIT",
        "Gid 81",
        "134M/wk"
       ]
      },
      {
       "name": "urllib3",
       "why": "Pick urllib3 for a lower-level sync client with built-in retries on error answers and connection pooling.",
       "path": "tools/urllib3/",
       "facts": [
        "MIT",
        "Gid 75",
        "376M/wk"
       ]
      }
     ],
     "more": "Compare httpx with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "prompt",
     "text": "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."
    },
    {
     "t": "steps",
     "items": [
      {
       "text": "Install HTTPX into your project's Python environment.",
       "code": "pip install httpx",
       "src": "https://github.com/encode/httpx/blob/master/README.md"
      },
      {
       "text": "Make a request and read the answer.",
       "code": ">>> import httpx\n>>> r = httpx.get('https://www.example.org/')\n>>> r.status_code\n200\n",
       "src": "https://github.com/encode/httpx/blob/master/docs/index.md"
      },
      {
       "text": "In async code, use AsyncClient inside an async with block.",
       "code": ">>> async with httpx.AsyncClient() as client:\n...     r = await client.get('https://www.example.com/')\n",
       "src": "https://github.com/encode/httpx/blob/master/docs/async.md"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Rules for your agent"
    },
    {
     "t": "rules",
     "label": "Paste into AGENTS.md or CLAUDE.md",
     "text": "## httpx\n- 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.\n- 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=`.\n- Call `raise_for_status()` when non-2xx responses should fail. It returns the response, so `httpx.get(...).raise_for_status().json()` works inline.\n- For large downloads, use `httpx.stream(...)` as a context manager with `iter_bytes()`, `iter_text()` or `iter_lines()` instead of reading `r.content`.\n- Use `iter_raw()` only when you need the body without gzip, deflate, brotli or zstd decoding.\n- 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`.\n- Target Python 3.9+.\n"
    },
    {
     "t": "h3",
     "text": "Mistakes to avoid"
    },
    {
     "t": "mistakes",
     "items": [
      {
       "dont": "httpx.Client(proxies={\"https://\": \"http://proxy:8080\"})",
       "fix": "httpx.Client(proxy=\"http://proxy:8080\"), or mounts= with httpx.HTTPTransport(proxy=...) for per-scheme routes",
       "why": "proxies= was removed in 0.28; in our run on 0.28.1 it raised TypeError: unexpected keyword argument 'proxies'."
      },
      {
       "dont": "httpx.AsyncClient(app=app, base_url=\"http://test\") in FastAPI tests",
       "fix": "httpx.AsyncClient(transport=httpx.ASGITransport(app=app), base_url=\"http://test\")",
       "why": "app= was removed in 0.28; in our run it raised TypeError: unexpected keyword argument 'app'."
      },
      {
       "dont": "Porting requests code as is and expecting redirects to be followed",
       "fix": "Pass follow_redirects=True to the client or to the call",
       "why": "HTTPX returns the 301/302 answer itself; our demo got 301 until follow_redirects=True."
      },
      {
       "dont": "Calling an AI model or slow export service with the default timeout",
       "fix": "Set timeout=60.0 (or httpx.Timeout(...)) on the client for slow services",
       "why": "The default raises a timeout after 5 seconds of inactivity; our demo got ReadTimeout with timeout=1.0."
      },
      {
       "dont": "pip install --pre httpx or uv add httpx --pre",
       "fix": "pip install httpx==0.28.1",
       "why": "Pre-release 1.0 builds are a redesigned client-and-server toolkit, not a drop-in upgrade of 0.28."
      }
     ]
    }
   ]
  },
  {
   "id": "faq",
   "nav": "Questions",
   "h2": "Questions",
   "parts": [
    {
     "t": "faq",
     "items": [
      {
       "q": "Can I switch from Requests by changing the import?",
       "a": "Mostly. The interface is close to Requests, but redirects are off by default, timeouts are on, and requests.Session becomes httpx.Client.",
       "evidence": {
        "url": "https://github.com/encode/httpx/blob/master/docs/compatibility.md",
        "quote": "The HTTPX equivalent of requests.Session is httpx.Client."
       }
      },
      {
       "q": "Why does my request fail with a timeout when Requests worked?",
       "a": "HTTPX stops after 5 seconds without network activity. Set timeout=30.0 or more, or timeout=None to wait forever.",
       "evidence": {
        "url": "https://github.com/encode/httpx/blob/master/docs/compatibility.md",
        "quote": "To get the same behavior as Requests, set the timeout parameter to None"
       }
      },
      {
       "q": "Does it support HTTP/2?",
       "a": "Yes, after pip install httpx[http2] and http2=True on the client.",
       "evidence": {
        "url": "https://github.com/encode/httpx/blob/master/README.md",
        "quote": "Or, to include the optional HTTP/2 support, use"
       }
      },
      {
       "q": "Can I use it in a paid app?",
       "a": "Yes. BSD-3-Clause allows commercial and closed-source use; keep the copyright notice if you ship its code.",
       "evidence": {
        "url": "https://github.com/encode/httpx/blob/master/LICENSE.md",
        "quote": "Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer."
       }
      },
      {
       "q": "How do I send requests through a proxy?",
       "a": "Pass proxy=\"http://...\" to the client. The old proxies= argument was removed in 0.28.",
       "evidence": {
        "url": "https://github.com/encode/httpx/blob/master/CHANGELOG.md",
        "quote": "The deprecated proxies argument has now been removed."
       }
      }
     ]
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "pypi httpx"
  ],
  [
   "Category",
   "HTTP clients and networking"
  ],
  [
   "License",
   "BSD"
  ],
  [
   "Latest version",
   "0.28.1, December 6, 2024"
  ],
  [
   "On GitHub since",
   "April 2019"
  ],
  [
   "Gid Score",
   "77.7"
  ],
  [
   "Rank in category",
   "#3 of 126"
  ],
  [
   "GitHub",
   "encode/httpx"
  ],
  [
   "Last change",
   "Nov 16, 2026"
  ]
 ],
 "good": [
  "Unlike Requests, it does not follow redirects unless you ask, so a moved page comes back as a 301 or 302 answer.",
  "It gives up after 5 seconds of no network activity by default; slow services, such as AI models, need a longer timeout.",
  "Its own retries cover only failed connections; for retrying busy or error answers the docs point to a general retry tool such as tenacity."
 ],
 "checked_line": "Read by AgentGid from 16 official pages, card checked Nov 11, 2026; numbers update daily.",
 "logo": "https://agentgid.com/media/avatars/encode.png"
}