Skip to content
Myr

api.md

This file

Path

docs/api.md

173 lines · 4.2 KiB · Markdown

Last changed by

Fix Client Docstring and add AsyncClient to API docs (#883)Ed Singletonbefore adoptionfc980e7

History of this file

Take it

The walk stopped after 200 commits: lines older than 1c326d5 point at it.

Stringify the given file name (#545)Taoufikbefore adoption1c326d5

lines 1–34why, one step back
1# Developer Interface
23## Helper Functions45!!! note6 Only use these functions if you're testing HTTPX in a console7 or making a small number of requests. Using a `Client` will8 enable HTTP/2 and connection pooling for more efficient and9 long-lived connections.1011::: httpx.request12 :docstring:1314::: httpx.get15 :docstring:1617::: httpx.options18 :docstring:1920::: httpx.head21 :docstring:2223::: httpx.post24 :docstring:2526::: httpx.put27 :docstring:2829::: httpx.patch30 :docstring:3132::: httpx.delete33 :docstring:34

Proposed 0.11 docs (#727)Tom Christiebefore adoption2038919

line 35why, one step back
35## `Client`

Stringify the given file name (#545)Taoufikbefore adoption1c326d5

line 36why, one step back
36

Proposed 0.11 docs (#727)Tom Christiebefore adoption2038919

line 37why, one step back
37::: httpx.Client

Stringify the given file name (#545)Taoufikbefore adoption1c326d5

line 38why, one step back
38 :docstring:

Proposed 0.11 docs (#727)Tom Christiebefore adoption2038919

line 39why, one step back
39 :members: headers cookies params request get head options post put patch delete build_request send close

Stringify the given file name (#545)Taoufikbefore adoption1c326d5

line 40why, one step back
40

Fix Client Docstring and add AsyncClient to API docs (#883)Ed Singletonbefore adoptionfc980e7

lines 41–47why, one step back
41## `AsyncClient`
4243::: httpx.AsyncClient44 :docstring:45 :members: headers cookies params request get head options post put patch delete build_request send4647

Stringify the given file name (#545)Taoufikbefore adoption1c326d5

lines 48–65why, one step back
48## `Response`
4950*An HTTP response.*5152* `def __init__(...)`53* `.status_code` - **int**54* `.reason_phrase` - **str**55* `.http_version` - `"HTTP/2"` or `"HTTP/1.1"`56* `.url` - **URL**57* `.headers` - **Headers**58* `.content` - **bytes**59* `.text` - **str**60* `.encoding` - **str**61* `.is_redirect` - **bool**62* `.request` - **Request**63* `.cookies` - **Cookies**64* `.history` - **List[Response]**65* `.elapsed` - **[timedelta](https://docs.python.org/3/library/datetime.html)**

response.elapsed now reflects entire request/response time. (#692)Tom Christiebefore adoption6a1ee0e

line 66why, one step back
66 * The amount of time elapsed between sending the request and calling `close()` on the corresponding response received for that request.

Stringify the given file name (#545)Taoufikbefore adoption1c326d5

lines 67–70why, one step back
67 [total_seconds()](https://docs.python.org/3/library/datetime.html#datetime.timedelta.total_seconds) to correctly get
68 the total elapsed seconds.69* `def .raise_for_status()` - **None**70* `def .json()` - **Any**

Proposed 0.11 docs (#727)Tom Christiebefore adoption2038919

line 71why, one step back
71* `def .read()` - **bytes**

Document that iter_* methods are synchronous (#807)Colin Bounouarbefore adoptioncfe2278

lines 72–75why, one step back
72* `def .iter_raw()` - **bytes iterator**
73* `def .iter_bytes()` - **bytes iterator**74* `def .iter_text()` - **text iterator**75* `def .iter_lines()` - **text iterator**

Proposed 0.11 docs (#727)Tom Christiebefore adoption2038919

lines 76–77why, one step back
76* `def .close()` - **None**
77* `def .next()` - **Response**

Rename 'read/close' to 'aread/aclose' on Response (#674)Florimond Mancabefore adoptionf9d18a8

line 78why, one step back
78* `def .aread()` - **bytes**

Fix out-of-date methods on Response API docs (#673)Florimond Mancabefore adoptione30ec85

lines 79–82why, one step back
79* `def .aiter_raw()` - **async bytes iterator**
80* `def .aiter_bytes()` - **async bytes iterator**81* `def .aiter_text()` - **async text iterator**82* `def .aiter_lines()` - **async text iterator**

Rename 'read/close' to 'aread/aclose' on Response (#674)Florimond Mancabefore adoptionf9d18a8

line 83why, one step back
83* `def .aclose()` - **None**

Rename 'next' to 'anext' on Response (#676)Florimond Mancabefore adoption3462999

line 84why, one step back
84* `def .anext()` - **Response**

Stringify the given file name (#545)Taoufikbefore adoption1c326d5

lines 85–92why, one step back
85
86## `Request`8788*An HTTP request. Can be constructed explicitly for more control over exactly89what gets sent over the wire.*9091```python92>>> request = httpx.Request("GET", "https://example.org", headers={'host': 'example.org'})

Proposed 0.11 docs (#727)Tom Christiebefore adoption2038919

line 93why, one step back
93>>> response = client.send(request)

Stringify the given file name (#545)Taoufikbefore adoption1c326d5

lines 94–98why, one step back
94```
9596* `def __init__(method, url, [params], [data], [json], [headers], [cookies])`97* `.method` - **str**98* `.url` - **URL**

Proposed 0.11 docs (#727)Tom Christiebefore adoption2038919

line 99why, one step back
99* `.content` - **byte**, **byte iterator**, or **byte async iterator**

Stringify the given file name (#545)Taoufikbefore adoption1c326d5

lines 100–173why, one step back
100* `.headers` - **Headers**
101* `.cookies` - **Cookies**102103## `URL`104105*A normalized, IDNA supporting URL.*106107```python108>>> url = URL("https://example.org/")109>>> url.host110'example.org'111```112113* `def __init__(url, allow_relative=False, params=None)`114* `.scheme` - **str**115* `.authority` - **str**116* `.host` - **str**117* `.port` - **int**118* `.path` - **str**119* `.query` - **str**120* `.full_path` - **str**121* `.fragment` - **str**122* `.is_ssl` - **bool**123* `.origin` - **Origin**124* `.is_absolute_url` - **bool**125* `.is_relative_url` - **bool**126* `def .copy_with([scheme], [authority], [path], [query], [fragment])` - **URL**127* `def .resolve_with(url)` - **URL**128129## `Origin`130131*A normalized, IDNA supporting set of scheme/host/port info.*132133```python134>>> Origin('https://example.org') == Origin('HTTPS://EXAMPLE.ORG:443')135True136```137138* `def __init__(url)`139* `.scheme` - **str**140* `.is_ssl` - **bool**141* `.host` - **str**142* `.port` - **int**143144## `Headers`145146*A case-insensitive multi-dict.*147148```python149>>> headers = Headers({'Content-Type': 'application/json'})150>>> headers['content-type']151'application/json'152```153154* `def __init__(self, headers)`155156## `Cookies`157158*A dict-like cookie store.*159160```python161>>> cookies = Cookies()162>>> cookies.set("name", "value", domain="example.org")163```164165* `def __init__(cookies: [dict, Cookies, CookieJar])`166* `.jar` - **CookieJar**167* `def extract_cookies(response)`168* `def set_cookie_header(request)`169* `def set(name, value, [domain], [path])`170* `def get(name, [domain], [path])`171* `def delete(name, [domain], [path])`172* `def clear([domain], [path])`173* *Standard mutable mapping interface*