class AsyncClient(BaseClient):
An asynchronous HTTP client, with connection pooling, HTTP/2, redirects, cookie persistence, etc. Usage: ```python >>> async with httpx.AsyncClient() as client: >>> response = await client.get('https://example.org') ``` **Parameters:** * **auth** - *(optional)* An authentication class to use when sending requests. * **params** - *(optional)* Query parameters to include in request URLs, as a string, dictionary, or sequence of two-tuples. * **headers** - *(optional)* Dictionary of HTTP headers to include when sending requests. * **cookies** - *(optional)* Dictionary of Cookie items to include when sending requests. * **verify** - *(optional)* SSL certificates (a.k.a CA bundle) used to verify the identity of requested hosts. Either `True` (default CA bundle), a path to an SSL certificate file, or `False` (disable verification). * **cert** - *(optional)* An SSL certificate used by the requested host to authenticate the client. Either a path to an SSL certificate file, or two-tuple of (certificate file, key file), or a three-tuple of (certificate file, key file, password). * **http2** - *(optional)* A boolean indicating if HTTP/2 support should be enabled. Defaults to `False`. * **proxies** - *(optional)* A dictionary mapping HTTP protocols to proxy URLs. * **timeout** - *(optional)* The timeout configuration to use when sending requests. * **limits** - *(optional)* The limits configuration to use. * **max_redirects** - *(optional)* The maximum number of redirect responses that should be followed. * **base_url** - *(optional)* A URL to use as the base when building request URLs. * **transport** - *(optional)* A transport class to use for sending requests over the network. * **app** - *(optional)* An ASGI application to send requests to, rather than sending actual network requests. * **trust_env** - *(optional)* Enables or disables usage of environment variables for configuration.
Async Method | __aenter__ |
Undocumented |
Async Method | __aexit__ |
Undocumented |
Method | __init__ |
Undocumented |
Async Method | aclose |
Close transport and proxies. |
Async Method | delete |
Send a DELETE request. |
Async Method | get |
Send a GET request. |
Async Method | head |
Send a HEAD request. |
Async Method | options |
Send an OPTIONS request. |
Async Method | patch |
Send a PATCH request. |
Async Method | post |
Send a POST request. |
Async Method | put |
Send a PUT request. |
Async Method | request |
Build and send a request. |
Async Method | send |
Send a request. |
Async Method | stream |
Alternative to httpx.request() that streams the response body instead of loading it into memory at once. |
Method | _init_proxy_transport |
Undocumented |
Method | _init_transport |
Undocumented |
Async Method | _send_handling_auth |
Undocumented |
Async Method | _send_handling_redirects |
Undocumented |
Async Method | _send_single_request |
Sends a single request, without handling any redirections. |
Method | _transport_for_url |
Returns the transport instance that should be used for a given URL. This will either be the standard connection pool, or a proxy. |
Instance Variable | _mounts |
Undocumented |
Instance Variable | _state |
Undocumented |
Instance Variable | _transport |
Undocumented |
Inherited from BaseClient
:
Method | auth.setter |
Undocumented |
Method | base_url.setter |
Undocumented |
Method | build_request |
Build and return a request instance. |
Method | cookies.setter |
Undocumented |
Method | event_hooks.setter |
Undocumented |
Method | headers.setter |
Undocumented |
Method | params.setter |
Undocumented |
Method | timeout.setter |
Undocumented |
Instance Variable | follow_redirects |
Undocumented |
Instance Variable | max_redirects |
Undocumented |
Property | auth |
Authentication class used when none is passed at the request-level. |
Property | base_url |
Base URL to use when sending requests with relative URLs. |
Property | cookies |
Cookie values to include when sending requests. |
Property | event_hooks |
Undocumented |
Property | headers |
HTTP headers to include when sending requests. |
Property | is_closed |
Check if the client being closed |
Property | params |
Query parameters to include in the URL when sending requests. |
Property | timeout |
Undocumented |
Property | trust_env |
Undocumented |
Method | _build_auth |
Undocumented |
Method | _build_redirect_request |
Given a request and a redirect response, return a new request that should be used to effect the redirect. |
Method | _build_request_auth |
Undocumented |
Method | _enforce_trailing_slash |
Undocumented |
Method | _get_proxy_map |
Undocumented |
Method | _merge_cookies |
Merge a cookies argument together with any cookies on the client, to create the cookies used for the outgoing request. |
Method | _merge_headers |
Merge a headers argument together with any headers on the client, to create the headers used for the outgoing request. |
Method | _merge_queryparams |
Merge a queryparams argument together with any queryparams on the client, to create the queryparams used for the outgoing request. |
Method | _merge_url |
Merge a URL argument together with any 'base_url' on the client, to create the URL used for the outgoing request. |
Method | _redirect_headers |
Return the headers that should be used for the redirect request. |
Method | _redirect_method |
When being redirected we may want to change the method of the request based on certain specs or browser behavior. |
Method | _redirect_stream |
Return the body that should be used for the redirect request. |
Method | _redirect_url |
Return the URL for the redirect to follow. |
Instance Variable | _auth |
Undocumented |
Instance Variable | _base_url |
Undocumented |
Instance Variable | _cookies |
Undocumented |
Instance Variable | _event_hooks |
Undocumented |
Instance Variable | _headers |
Undocumented |
Instance Variable | _netrc |
Undocumented |
Instance Variable | _params |
Undocumented |
Instance Variable | _timeout |
Undocumented |
Instance Variable | _trust_env |
Undocumented |
Undocumented
Parameters | |
exc_type:typing.Type[ | Undocumented |
exc_value:BaseException | Undocumented |
traceback:TracebackType | Undocumented |
httpx._client.BaseClient.__init__
Undocumented
Parameters | |
auth:AuthTypes | Undocumented |
params:QueryParamTypes | Undocumented |
headers:HeaderTypes | Undocumented |
cookies:CookieTypes | Undocumented |
verify:VerifyTypes | Undocumented |
cert:CertTypes | Undocumented |
http1:bool | Undocumented |
http2:bool | Undocumented |
proxies:ProxiesTypes | Undocumented |
mounts:typing.Mapping[ | Undocumented |
timeout:TimeoutTypes | Undocumented |
follow_redirects:bool | Undocumented |
limits:Limits | Undocumented |
max_redirects:int | Undocumented |
event_hooks:typing.Mapping[ | Undocumented |
base_url:URLTypes | Undocumented |
transport:AsyncBaseTransport | Undocumented |
app:typing.Callable | Undocumented |
trust_env:bool | Undocumented |
Send a DELETE
request.
Parameters: See httpx.request
.
Parameters | |
url:URLTypes | Undocumented |
params:QueryParamTypes | Undocumented |
headers:HeaderTypes | Undocumented |
cookies:CookieTypes | Undocumented |
auth:typing.Union[ | Undocumented |
follow_redirects:typing.Union[ | Undocumented |
timeout:typing.Union[ | Undocumented |
extensions:dict | Undocumented |
Returns | |
Response | Undocumented |
Send a GET
request.
Parameters: See httpx.request
.
Parameters | |
url:URLTypes | Undocumented |
params:QueryParamTypes | Undocumented |
headers:HeaderTypes | Undocumented |
cookies:CookieTypes | Undocumented |
auth:typing.Union[ | Undocumented |
follow_redirects:typing.Union[ | Undocumented |
timeout:typing.Union[ | Undocumented |
extensions:dict | Undocumented |
Returns | |
Response | Undocumented |
Send a HEAD
request.
Parameters: See httpx.request
.
Parameters | |
url:URLTypes | Undocumented |
params:QueryParamTypes | Undocumented |
headers:HeaderTypes | Undocumented |
cookies:CookieTypes | Undocumented |
auth:typing.Union[ | Undocumented |
follow_redirects:typing.Union[ | Undocumented |
timeout:typing.Union[ | Undocumented |
extensions:dict | Undocumented |
Returns | |
Response | Undocumented |
Send an OPTIONS
request.
Parameters: See httpx.request
.
Parameters | |
url:URLTypes | Undocumented |
params:QueryParamTypes | Undocumented |
headers:HeaderTypes | Undocumented |
cookies:CookieTypes | Undocumented |
auth:typing.Union[ | Undocumented |
follow_redirects:typing.Union[ | Undocumented |
timeout:typing.Union[ | Undocumented |
extensions:dict | Undocumented |
Returns | |
Response | Undocumented |
Send a PATCH
request.
Parameters: See httpx.request
.
Parameters | |
url:URLTypes | Undocumented |
content:RequestContent | Undocumented |
data:RequestData | Undocumented |
files:RequestFiles | Undocumented |
json:typing.Any | Undocumented |
params:QueryParamTypes | Undocumented |
headers:HeaderTypes | Undocumented |
cookies:CookieTypes | Undocumented |
auth:typing.Union[ | Undocumented |
follow_redirects:typing.Union[ | Undocumented |
timeout:typing.Union[ | Undocumented |
extensions:dict | Undocumented |
Returns | |
Response | Undocumented |
Send a POST
request.
Parameters: See httpx.request
.
Parameters | |
url:URLTypes | Undocumented |
content:RequestContent | Undocumented |
data:RequestData | Undocumented |
files:RequestFiles | Undocumented |
json:typing.Any | Undocumented |
params:QueryParamTypes | Undocumented |
headers:HeaderTypes | Undocumented |
cookies:CookieTypes | Undocumented |
auth:typing.Union[ | Undocumented |
follow_redirects:typing.Union[ | Undocumented |
timeout:typing.Union[ | Undocumented |
extensions:dict | Undocumented |
Returns | |
Response | Undocumented |
Send a PUT
request.
Parameters: See httpx.request
.
Parameters | |
url:URLTypes | Undocumented |
content:RequestContent | Undocumented |
data:RequestData | Undocumented |
files:RequestFiles | Undocumented |
json:typing.Any | Undocumented |
params:QueryParamTypes | Undocumented |
headers:HeaderTypes | Undocumented |
cookies:CookieTypes | Undocumented |
auth:typing.Union[ | Undocumented |
follow_redirects:typing.Union[ | Undocumented |
timeout:typing.Union[ | Undocumented |
extensions:dict | Undocumented |
Returns | |
Response | Undocumented |
Build and send a request.
Equivalent to:
`python request = client.build_request(...) response = await client.send(request, ...) `
See AsyncClient.build_request()
, AsyncClient.send()
and [Merging of configuration][0] for how the various parameters
are merged with client-level configuration.
[0]: /advanced/#merging-of-configuration
Parameters | |
method:str | Undocumented |
url:URLTypes | Undocumented |
content:RequestContent | Undocumented |
data:RequestData | Undocumented |
files:RequestFiles | Undocumented |
json:typing.Any | Undocumented |
params:QueryParamTypes | Undocumented |
headers:HeaderTypes | Undocumented |
cookies:CookieTypes | Undocumented |
auth:typing.Union[ | Undocumented |
follow_redirects:typing.Union[ | Undocumented |
timeout:typing.Union[ | Undocumented |
extensions:dict | Undocumented |
Returns | |
Response | Undocumented |
Send a request.
The request is sent as-is, unmodified.
Typically you'll want to build one with AsyncClient.build_request()
so that any client-level configuration is merged into the request,
but passing an explicit httpx.Request()
is supported as well.
See also: [Request instances][0]
[0]: /advanced/#request-instances
Parameters | |
request:Request | Undocumented |
stream:bool | Undocumented |
auth:typing.Union[ | Undocumented |
follow_redirects:typing.Union[ | Undocumented |
Returns | |
Response | Undocumented |
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][0]
[0]: /quickstart#streaming-responses
Parameters | |
method:str | Undocumented |
url:URLTypes | Undocumented |
content:RequestContent | Undocumented |
data:RequestData | Undocumented |
files:RequestFiles | Undocumented |
json:typing.Any | Undocumented |
params:QueryParamTypes | Undocumented |
headers:HeaderTypes | Undocumented |
cookies:CookieTypes | Undocumented |
auth:typing.Union[ | Undocumented |
follow_redirects:typing.Union[ | Undocumented |
timeout:typing.Union[ | Undocumented |
extensions:dict | Undocumented |
Returns | |
typing.AsyncIterator[ | Undocumented |
Undocumented
Parameters | |
proxy:Proxy | Undocumented |
verify:VerifyTypes | Undocumented |
cert:CertTypes | Undocumented |
http1:bool | Undocumented |
http2:bool | Undocumented |
limits:Limits | Undocumented |
trust_env:bool | Undocumented |
Returns | |
AsyncBaseTransport | Undocumented |
Undocumented
Parameters | |
verify:VerifyTypes | Undocumented |
cert:CertTypes | Undocumented |
http1:bool | Undocumented |
http2:bool | Undocumented |
limits:Limits | Undocumented |
transport:AsyncBaseTransport | Undocumented |
app:typing.Callable | Undocumented |
trust_env:bool | Undocumented |
Returns | |
AsyncBaseTransport | Undocumented |
Parameters | |
url:URL | Undocumented |
Returns | |
AsyncBaseTransport | Undocumented |