Skip to main content

⚡ High-performance async HTTP client in Rust with Python bindings for blazing-fast batch requests.

Project description

rusty-req

A high-performance asynchronous request library based on Rust + Python, suitable for scenarios that require batch HTTP requests. It implements concurrent request logic in Rust and packages it into a Python module using maturin , combining performance with ease of use.

🔧 Installation

pip install rusty-req

Or build from source:

maturin build --release
pip install target/wheels/rusty_req-*.whl

Development & Debugging

cargo watch -s "maturin develop"

🚀 Features

  • Batch asynchronous HTTP requests (supports GET / POST)
  • Customizable headers / params / timeout / tag
  • Global timeout control (total_timeout)
  • Returns response body, exception info, and meta data
  • Built with Rust + Tokio for high throughput

📦 Example Usage

import asyncio
import time
import rusty_req


async def main():
    # Using JSONPlaceholder - a free test API
    requests = [
        rusty_req.RequestItem(
            url="https://httpbin.org/delay/2",
            method="GET",
            headers={
                "Accept-Encoding": "gzip, deflate, br",
                "Connection": "keep-alive",
                "X-Test-Header": "ChatGPT"
            },
            timeout=2.9,
            tag=f"json-test-{i}",
        )
        for i in range(100)  # 100 concurrent requests
    ]

    # Disable debug logs
    rusty_req.set_debug(False)

    print("🚀 Starting 100 concurrent JSON API requests...")
    start_time = time.perf_counter()

    responses = await rusty_req.fetch_requests(
        requests,
        total_timeout=3.0
    )

    total_time = time.perf_counter() - start_time

    # Process results
    success = 0
    failed = 0
    status_codes = {}
    response_times = []

    for r in responses:
        if r.get("exception"):
            failed += 1
        else:
            meta = r.get("meta", {})
            status_code = meta.get("status_code", 0)
            process_time = float(meta.get("process_time", 0))

            status_codes[status_code] = status_codes.get(status_code, 0) + 1
            response_times.append(process_time)
            success += 1

    # Calculate metrics
    avg_response_time = sum(response_times) / len(response_times) if response_times else 0
    min_response_time = min(response_times) if response_times else 0
    max_response_time = max(response_times) if response_times else 0
    req_per_sec = success / total_time if total_time > 0 else 0

    print("\n📊 Load Test Summary:")
    print(f"⏱️ Total time: {total_time:.2f}s")
    print(f"📈 Requests per second: {req_per_sec:.1f}")
    print(f"✅ Successful requests: {success}")
    print(f"⚠️ Failed requests: {failed}")
    print(f"🔄 Status code distribution: {status_codes}")
    print(f"⏳ Response time - Avg: {avg_response_time:.4f}s, Min: {min_response_time:.4f}s, Max: {max_response_time:.4f}s")


if __name__ == "__main__":
    asyncio.run(main())

🧱 Data Structure

RequestItem Parameters

Field Type Required Description
url str Target URL
method str HTTP method ("GET" or "POST")
params dict / None No Query parameters (GET) or form data (POST)
headers dict / None No Custom HTTP headers
timeout float Timeout for a single request (in seconds)
tag str No Tag for tracing origin or indexing the request

Response Format

{
    "http_status": 200,
    "response": "{\"code\":403,\"msg\":\"Method Not Allowed.\"}",
    "meta": {
        "process_time": "0.2439",
        "request_time": "2025-07-29 19:17:11 -> 2025-07-29 19:17:11",
        "tag": "test-baidu1"
    },
    "exception": {
        "message": "HTTP status error: 500 - ", 
        "type": "HttpStatusError"
    }
}

📄 License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

rusty_req-0.2.7-cp312-cp312-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.12Windows x86-64

rusty_req-0.2.7-cp312-cp312-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

rusty_req-0.2.7-cp312-cp312-macosx_10_12_universal2.whl (3.5 MB view details)

Uploaded CPython 3.12macOS 10.12+ universal2 (ARM64, x86-64)

rusty_req-0.2.7-cp311-cp311-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.11Windows x86-64

rusty_req-0.2.7-cp311-cp311-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

rusty_req-0.2.7-cp311-cp311-macosx_10_12_universal2.whl (3.5 MB view details)

Uploaded CPython 3.11macOS 10.12+ universal2 (ARM64, x86-64)

rusty_req-0.2.7-cp310-cp310-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.10Windows x86-64

rusty_req-0.2.7-cp310-cp310-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

rusty_req-0.2.7-cp310-cp310-macosx_10_12_universal2.whl (3.5 MB view details)

Uploaded CPython 3.10macOS 10.12+ universal2 (ARM64, x86-64)

rusty_req-0.2.7-cp39-cp39-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.9Windows x86-64

rusty_req-0.2.7-cp39-cp39-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

rusty_req-0.2.7-cp39-cp39-macosx_10_12_universal2.whl (3.5 MB view details)

Uploaded CPython 3.9macOS 10.12+ universal2 (ARM64, x86-64)

File details

Details for the file rusty_req-0.2.7-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: rusty_req-0.2.7-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for rusty_req-0.2.7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 2a6054d0e7def92b9ae5c3d29c12f2cf2387124b53df27b152106c3a21ded6c9
MD5 168242e20b33d53f908adaa149e2a4d2
BLAKE2b-256 e8f66d394f894953d81148842214bf290dbe161c683c0b3aa4c0a9285a09e13a

See more details on using hashes here.

File details

Details for the file rusty_req-0.2.7-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rusty_req-0.2.7-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 87d674bbf4000b3d656508e34dabc5e6352bec7f448e192505e65b43c0147c5c
MD5 f9a26e7b65b7010729cd83d17d0eb2fe
BLAKE2b-256 5a1309a6e91f6c4fe9607f38a30931b49e62d500596494d92bce458881075cbc

See more details on using hashes here.

File details

Details for the file rusty_req-0.2.7-cp312-cp312-macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for rusty_req-0.2.7-cp312-cp312-macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 81e52cef19ab6016394ae0030ad265c5d401a3533b2dcb6fb045f9a94026c482
MD5 9d1433bdd127162854eb9f4c97fb09ee
BLAKE2b-256 22c8fca4cde3768677393d4d461a9dc8ae33a51072b7d00484d3786b0a407cbc

See more details on using hashes here.

File details

Details for the file rusty_req-0.2.7-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: rusty_req-0.2.7-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for rusty_req-0.2.7-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ee0e8fb60f3699ef0c787bc827e2aee20592c6a9106c399197028827adc9614e
MD5 d21fb2c89fa0301b093cc7ef1bb0ee52
BLAKE2b-256 d0ef94cd99288f73f6ce9e6bfce575646de1ce2fd9fd4fc164470f7f02047a84

See more details on using hashes here.

File details

Details for the file rusty_req-0.2.7-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rusty_req-0.2.7-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 80c6f41d0af70efd953c6b7eb788733199b36760b7d91b2ef128afd9b1833f6b
MD5 6c9280b95d7033ac09d9bfec2e0ff604
BLAKE2b-256 d2afd0973bd88fdd16eedb333c476022312cfe24c1e070a9941e8cd93de197b2

See more details on using hashes here.

File details

Details for the file rusty_req-0.2.7-cp311-cp311-macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for rusty_req-0.2.7-cp311-cp311-macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 1403e7794f317397db6fc1aa58ed164da1d9189c151d34edc207bcefdc02a66a
MD5 a37bda6b751c4fe7a38d48a3bfb02b47
BLAKE2b-256 83f5c443242dcdfc9464ceb799b4a5433a5aff13ad80be307ad350a1383f75a3

See more details on using hashes here.

File details

Details for the file rusty_req-0.2.7-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: rusty_req-0.2.7-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for rusty_req-0.2.7-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a51c190070b3c893f2a2788ecc8e5a3c0bb16520f821be0ef949cc4b62f18fac
MD5 41c0c4a1506269df50e016bbff664dab
BLAKE2b-256 b6a79899433fb3d1b5da1c7f3371d04aa7b15070b3aff5a5d8dcb201092f041f

See more details on using hashes here.

File details

Details for the file rusty_req-0.2.7-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rusty_req-0.2.7-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6dc7558fcf28acd74b37a375f7817eb03303781009f60c3201c39fd67f453cff
MD5 a5ae013690890d27f6156644cb3c4c1e
BLAKE2b-256 f6fe917bbc7e465f54d65a1c8eeeb074332db44c3ce80098207919d254c92ea2

See more details on using hashes here.

File details

Details for the file rusty_req-0.2.7-cp310-cp310-macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for rusty_req-0.2.7-cp310-cp310-macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 81d2f308517a1f9418acb51b567a0bca7273c195a72244d31e281b37abfc5574
MD5 2e4609f2bddbc19105122a92254faa53
BLAKE2b-256 23b88d89a3ea84217ae60bf94c4e8ff7d065908dba6a24d6b1df396a7106905f

See more details on using hashes here.

File details

Details for the file rusty_req-0.2.7-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: rusty_req-0.2.7-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for rusty_req-0.2.7-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 6534ea3be9633f9ae7b894fb5f1087ab57941344fc4c3fb90fe26684e82ac5a4
MD5 12c978f1281416390da60f4b658061a0
BLAKE2b-256 b3d13ec29bac9cf265dfde599278fa1f506175036f77324f0cd3e85a4ae9f70e

See more details on using hashes here.

File details

Details for the file rusty_req-0.2.7-cp39-cp39-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rusty_req-0.2.7-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 aaeb3f3aca67274cf3abfcf0c8948cfb8c9570bfc58aa9a45e0ebf327cc79183
MD5 85fad8c8fa401d23c355fc0c3c250a24
BLAKE2b-256 f30587c8ca5a6db46e72769ffd54d4b2c99cb929e47b070294f100a83370607f

See more details on using hashes here.

File details

Details for the file rusty_req-0.2.7-cp39-cp39-macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for rusty_req-0.2.7-cp39-cp39-macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 d70b77dbc12366a93db8b2c9fa0d2fc4145653c90a3af4a466bb5f30b7956e23
MD5 409d2aafa18e706a3f60b7d6f7c1bfea
BLAKE2b-256 85b5a4c03e46a46f9479752ee4655d97859f522ade866bb557164c290e631612

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page