Fast Python HTTP client based on Rust reqwest
402
stars
310
commits
Python
primary language
Sep 10, 2026
updated
pyreqwest - Powerful and fast Rust based HTTP client. Built on top of and inspired by reqwest.
unsafe codeUsing this is a good choice when:
This is not a good choice when:
reqwest# uv add pyreqwest
from pyreqwest.client import ClientBuilder, SyncClientBuilder
async def example_async():
async with ClientBuilder().error_for_status(True).build() as client:
response = await client.get("https://httpbun.com/get").query({"q": "val"}).build().send()
print(await response.json())
def example_sync():
with SyncClientBuilder().error_for_status(True).build() as client:
print(client.get("https://httpbun.com/get").query({"q": "val"}).build().send().json())
Context manager usage is optional, but recommended. Also close() methods are available.
from pyreqwest.client import ClientBuilder
from pyreqwest.pytest_plugin import ClientMocker
async def test_client(client_mocker: ClientMocker) -> None:
client_mocker.get(path="/api").with_body_text("Hello Mock")
async with ClientBuilder().build() as client:
response = await client.get("http://example.invalid/api").build().send()
assert response.status == 200 and await response.text() == "Hello Mock"
assert client_mocker.get_call_count() == 1
Manual mocking is available via ClientMocker.create_mocker(MonkeyPatch).
This is only recommended for simple use-cases such as scripts. Usually, the full client API should be used which reuses connections and has other optimizations.
# Sync example
from pyreqwest.simple.sync_request import pyreqwest_get
response = pyreqwest_get("https://httpbun.com/get").query({"q": "val"}).send()
print(response.json())
# Async example
from pyreqwest.simple.request import pyreqwest_get
response = await pyreqwest_get("https://httpbun.com/get").query({"q": "val"}).send()
print(await response.json())
See docs
See examples
Python
64.1%
Rust
35.6%
Fast Python HTTP client based on Rust reqwest
402
stars
310
commits
Python
primary language
Sep 10, 2026
updated
pyreqwest - Powerful and fast Rust based HTTP client. Built on top of and inspired by reqwest.
unsafe codeUsing this is a good choice when:
This is not a good choice when:
reqwest# uv add pyreqwest
from pyreqwest.client import ClientBuilder, SyncClientBuilder
async def example_async():
async with ClientBuilder().error_for_status(True).build() as client:
response = await client.get("https://httpbun.com/get").query({"q": "val"}).build().send()
print(await response.json())
def example_sync():
with SyncClientBuilder().error_for_status(True).build() as client:
print(client.get("https://httpbun.com/get").query({"q": "val"}).build().send().json())
Context manager usage is optional, but recommended. Also close() methods are available.
from pyreqwest.client import ClientBuilder
from pyreqwest.pytest_plugin import ClientMocker
async def test_client(client_mocker: ClientMocker) -> None:
client_mocker.get(path="/api").with_body_text("Hello Mock")
async with ClientBuilder().build() as client:
response = await client.get("http://example.invalid/api").build().send()
assert response.status == 200 and await response.text() == "Hello Mock"
assert client_mocker.get_call_count() == 1
Manual mocking is available via ClientMocker.create_mocker(MonkeyPatch).
This is only recommended for simple use-cases such as scripts. Usually, the full client API should be used which reuses connections and has other optimizations.
# Sync example
from pyreqwest.simple.sync_request import pyreqwest_get
response = pyreqwest_get("https://httpbun.com/get").query({"q": "val"}).send()
print(response.json())
# Async example
from pyreqwest.simple.request import pyreqwest_get
response = await pyreqwest_get("https://httpbun.com/get").query({"q": "val"}).send()
print(await response.json())
See docs
See examples
Python
64.1%
Rust
35.6%