httpx.Client — An HTTP client with connection pooling, HTTP/2, redirects, cookie persistence, and more. It can be shared between threads.
| Use Case | Command | Description |
|---|---|---|
| Create a client | client = httpx.Client() | Instantiate a client with default settings |
| Send a GET request | response = client.get('https://example.org') | Fetch a resource |
| Send a POST request | response = client.post('https://example.org', json={'key': 'value'}) | Submit data as JSON |
| Send a PUT request | response = client.put('https://example.org', data='updated') | Update a resource |
| Send a DELETE request | response = client.delete('https://example.org') | Delete a resource |
| Send a PATCH request | response = client.patch('https://example.org', files={'file': open('data.txt', 'rb')}) | Partially update a resource |
| Send a HEAD request | response = client.head('https://example.org') | Retrieve headers only |
| Send an OPTIONS request | response = client.options('https://example.org') | Discover allowed methods |
| Stream a response | with client.stream('GET', 'https://example.org') as r: ... | Stream response body without loading into memory |
| Build a request manually | request = client.build_request('GET', 'https://example.org') | Create a request with client-level defaults merged |
| Send a pre-built request | response = client.send(request) | Send a request as-is |
class httpx.Client(
*,
auth: AuthTypes | None = None,
params: QueryParamTypes | None = None,
headers: HeaderTypes | None = None,
cookies: CookieTypes | None = None,
verify: ssl.SSLContext | str | bool = True,
cert: CertTypes | None = None,
trust_env: bool = True,
http1: bool = True,
http2: bool = False,
proxy: ProxyTypes | None = None,
mounts: None | typing.Mapping[str, BaseTransport | None] = None,
timeout: TimeoutTypes = Timeout(timeout=5.0),
follow_redirects: bool = False,
limits: Limits = Limits(max_connections=100, max_keepalive_connections=20, keepalive_expiry=5.0),
max_redirects: int = 20,
event_hooks: None | typing.Mapping[str, list[EventHook]] = None,
base_url: URL | str = '',
transport: BaseTransport | None = None,
default_encoding: str | typing.Callable[[bytes], str] = 'utf-8'
) -> None
An HTTP client with connection pooling, HTTP/2, redirects, cookie persistence, etc. It can be shared between threads.
Usage:
>>> client = httpx.Client()
>>> response = client.get('https://example.org')
True to use an SSL context with the default CA bundle, False to disable verification, or an instance of ssl.SSLContext to use a custom context.False.__enter__() — Enter runtime context.__exit__(exc_type, exc_value, traceback) — Exit runtime context.__init__(...) — Initialize self. See help(type(self)) for accurate signature.close() — Close transport and proxies.delete(url, *, params, headers, cookies, auth, follow_redirects, timeout, extensions) — Send a DELETE request. Parameters: See httpx.request.get(url, *, params, headers, cookies, auth, follow_redirects, timeout, extensions) — Send a GET request. Parameters: See httpx.request.head(url, *, params, headers, cookies, auth, follow_redirects, timeout, extensions) — Send a HEAD request. Parameters: See httpx.request.options(url, *, params, headers, cookies, auth, follow_redirects, timeout, extensions) — Send an OPTIONS request. Parameters: See httpx.request.patch(url, *, content, data, files, json, params, headers, cookies, auth, follow_redirects, timeout, extensions) — Send a PATCH request. Parameters: See httpx.request.post(url, *, content, data, files, json, params, headers, cookies, auth, follow_redirects, timeout, extensions) — Send a POST request. Parameters: See httpx.request.put(url, *, content, data, files, json, params, headers, cookies, auth, follow_redirects, timeout, extensions) — Send a PUT request. Parameters: See httpx.request.request(method, url, *, content, data, files, json, params, headers, cookies, auth, follow_redirects, timeout, extensions) — Build and send a request. Equivalent to: request = client.build_request(...)
response = client.send(request, ...) See Client.build_request(), Client.send() and Merging of configuration.send(request, *, stream, auth, follow_redirects) — Send a request. The request is sent as-is, unmodified. Typically you'll want to build one with Client.build_request(). See also: Request instances.stream(method, url, *, content, data, files, json, params, headers, cookies, auth, follow_redirects, timeout, extensions) — Alternative to httpx.request() that streams the response body instead of loading it into memory at once. Parameters: See httpx.request. See also: Streaming Responses.build_request(method, url, *, content, data, files, json, params, headers, cookies, timeout, extensions) — Build and return a request instance. The params, headers and cookies arguments are merged with any values set on the client. The url argument is merged with any base_url set on the client. See also: Request instances.is_closed — Check if the client being closed.trust_env — (docstring from original)auth — Authentication class used when none is passed at the request-level. See also Authentication.base_url — Base URL to use when sending requests with relative URLs.cookies — Cookie values to include when sending requests.event_hooks — (docstring from original)headers — HTTP headers to include when sending requests.params — Query parameters to include in the URL when sending requests.timeout — (docstring from original)Additionally, there are __dict__ and __weakref__ descriptors.
httpx.request for parameter documentationGenerated by phpman v4.9.27-5-g2cb901d · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-20 04:03 @216.73.216.114
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format