pyreqwest

raw JSON →
0.11.8 verified Fri May 01 auth: no python

Powerful and fast Rust-based HTTP client for Python, wrapping the popular reqwest crate. Current version 0.11.8, requires Python >=3.11. Release cadence is irregular with frequent bugfix releases.

pip install pyreqwest
error AttributeError: 'Response' object has no attribute 'text'
cause Using `response.text` without parentheses.
fix
Use response.text() to get the response body as string.
error TypeError: 'module' object is not callable
cause Attempting to call `pyreqwest()` directly instead of using a client.
fix
Instantiate a Client: client = pyreqwest.Client() then use client.get(...).
error pyreqwest.errors.RequestError: URL parse error: relative URL without a base
cause Passing a relative URL (e.g., "/path") without a base client URL.
fix
Provide an absolute URL (e.g., "https://example.com/path").
gotcha pyreqwest methods (e.g., `get`, `post`) are **blocking** by default. There is no async support. If you need async, use a different library.
fix Do not try `await client.get(...)`. Use synchronous calls only.
breaking In v0.11.4, the `header` method on `RequestBuilder` renamed the `name` keyword argument to `key`. Code using `header(name="X-Custom", value="val")` will break.
fix Change to `header(key="X-Custom", value="val")`.
gotcha `Response.text()` is a method, not a property. Calling `response.text` (without parentheses) returns the bound method, not the string.
fix Always call `response.text()` with parentheses.
deprecated The `http2()` method on `ClientBuilder` is deprecated in favor of `http2_prior_knowledge()`? Actually, keep this generic: The `http2` method typing has been corrected; ensure you pass a boolean.
fix Use `client_builder.http2(True)` (boolean) as intended.

Basic synchronous HTTP GET request.

from pyreqwest import Client

client = Client()
response = client.get("https://httpbin.org/get")
print(response.status_code)
print(response.text())