Introduction
wreq is a Python HTTP client built on Rust. You can make async or blocking requests, reuse connections and stream bodies. It also lets you configure TLS and HTTP/2 behavior.
Use it for everyday HTTP calls or for services that expect browser-like network behavior. Browser profiles configure the network stack; they don't run a browser, execute JavaScript or render pages. A profile won't guarantee access to a protected website.
Start with a reusable client
import asyncio
from wreq import Client, Emulation
async def main():
async with Client(emulation=Emulation.Chrome154) as client:
async with client.get("https://example.com") as response:
print(response.status)
print(await response.text())
asyncio.run(main())
For synchronous code, use the blocking client. It has the same HTTP capabilities. Keep a client open across requests to reuse connections, and use context managers to close resources when you're done.
What you can configure
-
Browser profiles
Configure TLS handshakes, HTTP/2 settings, and headers with Chrome, Firefox, Safari, Edge, Opera, or OkHttp profiles. Platform options cover Windows, macOS, Linux, Android, and iOS.
-
HTTP essentials
Send JSON, forms, and multipart bodies. Configure cookies, redirects, authentication, proxies, timeouts, and connection pooling.
-
Streaming and buffers
Stream request and response bodies, or read a complete body. Rust-backed binary outputs are read-only
memoryviewobjects. Convert tobyteswhen an API requires that type; the conversion copies the data. -
Runtime configuration
Clients share a runtime by default. Supply your own
Runtimeto choose worker settings for a workload, including a single-worker runtime. -
Protocol settings
Change HTTP/1, HTTP/2 or TLS settings when the defaults don't fit your service. You can also configure certificate verification and client certificates.
-
WebSockets
Open a WebSocket connection through the client to send and receive text or binary frames.
Measure your workload
Payload size, concurrency and protocol affect performance. So do runtime settings and the way you read responses. Our HTTPS benchmarks include those settings, repeated measurements and raw data, with the source commit tested. Use them to reproduce a workload and check how close it is to your application. Performance rankings can change with the workload.
Next steps
Install wreq, follow the quick start, or browse the API reference. The project is licensed under Apache-2.0.