Skip to content

About

Unofficial Rust rewrite of Python Requests, with a drop-in Python API and native async/blocking Rust clients.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

246 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Requests Native

Requests Native

English · Español · 简体中文 · Français · हिन्दी · 日本語

Requests Native brings the familiar Python requests API to a shared Rust HTTP core. The same core is available directly as native async and blocking clients for Rust. Both Rust clients support connection pooling, configurable timeouts, proxy and TLS settings, and streaming request and response bodies.

1.0.1 release · crates.io · Installation · Issues

Rust: stable 1.0.1

This documentation and version-metadata patch leaves the implementation unchanged from 1.0.0.

Use Rust 1.98.1 or newer and add:

[dependencies]
requests-native = "1.0.1"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }

The crate name is requests-native; the library import is requests_native. Tokio is needed for the async example. The blocking client is included by default.

Async

use requests_native::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new()?;
    let response = client.get("https://httpbin.org/get").send().await?;
    println!("{}", response.text().await?);
    Ok(())
}

Blocking

use requests_native::blocking::Client;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new()?;
    let response = client.get("https://httpbin.org/get").send()?;
    println!("{}", response.text()?);
    Ok(())
}

Reuse a client to reuse its connection pool.

Python: install the improved 1.0.1 source

PyPI publication is planned for the coming days; publishing setup is being finalized. The Python distribution is not published to PyPI yet; use the improved v1.0.1 source now. This release does not include stable Python wheels.

You need CPython 3.10+, Git, the repository-pinned Rust 1.98.1 toolchain, and a native C/C++ compiler (MSVC Build Tools on Windows). Install Rust through rustup, then create a fresh environment:

rustup toolchain install 1.98.1 --profile minimal
python -m venv .venv

Activate it on Linux/macOS:

source .venv/bin/activate

Or in Windows PowerShell:

.venv\Scripts\Activate.ps1

Install the tagged source:

python -m pip install "requests-native @ git+https://github.com/puneet-chandna/requests-native.git@v1.0.1"

Use the familiar API:

import requests

with requests.Session() as session:
    response = session.get("https://httpbin.org/get", timeout=10)
    response.raise_for_status()
    print(response.json())

The distribution is requests-native 1.0.1; import requests and requests.__version__ == "2.34.2" retain the Requests compatibility identity.

Use a separate environment from upstream requests. Both distributions own the same import paths; dependencies on the package named requests can reinstall upstream Requests. See installation details.

Current Windows checks passed without accepted TLS failures; the unreproduced historical issue #1 remains open.

Performance

The published 1.0.0 Rust core was measured in a local loopback comparison in five pairs, with 16 matched workloads per native client. Version 1.0.1 has the same runtime implementation.

Native client Median throughput ratio vs original Requests Max observed throughput ratio vs original Requests Peak observed throughput (requests/s) Median throughput ratio vs beta
Async 2.65x 11.92x 13,479 1.005x
Blocking 2.23x 9.96x 10,513 1.055x

Median ratios summarize the 16 per-workload median ratios across five pairs. Peaks are the highest single-report observations, not typical performance; the maximum ratio and peak requests/s can come from different observations. Gains vary by workload; unstable oracle controls leave statistical uncertainty. See the methodology and exact-source evidence.

Compatibility and development

Built-in Session/HTTPAdapter traffic uses the native transport. Custom adapters, subclasses, monkeypatching and unsupported extension behavior can fall back to Python before native I/O. Test integrations with your own workload.

See the API compatibility inventory, porting guide and contributing guide. Report vulnerabilities through the security policy.

Attribution

Requests Native is an unofficial, independent rewrite of PSF Requests, maintained by Puneet Chandna. It is not affiliated with or endorsed by the Python Software Foundation or upstream Requests maintainers.

The derivative retains Apache-2.0 licensing, notices, history and the original contributor record. See LICENSE, NOTICE, AUTHORS.rst, runtime notices and HISTORY.md.

About

Unofficial Rust rewrite of Python Requests, with a drop-in Python API and native async/blocking Rust clients.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages