requestx


Namerequestx JSON
Version 0.2.8 PyPI version JSON
download
home_pagehttps://github.com/neuesql/requestx
SummaryHigh-performance HTTP client for Python with requests-compatible API
upload_time2025-08-18 10:15:33
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT
keywords http requests client async performance
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # RequestX

[![PyPI version](https://img.shields.io/pypi/v/requestx.svg)](https://pypi.org/project/requestx/)
[![Python versions](https://img.shields.io/pypi/pyversions/requestx.svg)](https://pypi.org/project/requestx/)
[![Build status](https://github.com/neuesql/requestx/workflows/Test%20and%20Build/badge.svg)](https://github.com/neuesql/requestx/actions)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

RequestX is a high-performance HTTP client library for Python that provides a **drop-in replacement** for the popular `requests` library. Built with Rust for speed and memory safety, it offers both synchronous and asynchronous APIs while maintaining full compatibility with the familiar requests interface.

## 🚀 Key Features

* **Drop-in replacement** for requests library with identical API
* **High performance** leveraging Rust's speed and memory safety  
* **Dual API support** - both sync and async/await patterns
* **Cross-platform** compatibility (Windows, macOS, Linux)
* **Requests compatibility** for easy migration from existing codebases
* **Native async/await** support with automatic context detection
* **Session management** with persistent connections and cookies
* **Comprehensive error handling** with requests-compatible exceptions

## ⚡ Performance

RequestX delivers significant performance improvements over traditional Python HTTP libraries:

* **2-5x faster** than requests for synchronous operations
* **3-10x faster** than aiohttp for asynchronous operations  
* **Lower memory usage** due to Rust's efficient memory management
* **Better connection pooling** with hyper's advanced HTTP/2 support

## 📦 Installation

### Requirements

* **Python**: 3.8 or higher
* **Operating System**: Windows, macOS, or Linux
* **Architecture**: x86_64, ARM64 (Apple Silicon, ARM64 Windows)

No additional dependencies or build tools are required - RequestX comes with all Rust dependencies pre-compiled and bundled.

### Standard Installation

Install RequestX using pip:

```bash
pip install requestx
```



## 🚀 Quick Start

### Basic Usage

RequestX provides the exact same API as the popular `requests` library. If you're familiar with requests, you already know how to use RequestX!

```python
import requestx

# Make a simple GET request
response = requestx.get('https://httpbin.org/json')

# Check the status
print(f"Status: {response.status_code}")

# Get JSON data
data = response.json()
print(f"Data: {data}")
```

### Common HTTP Methods

```python
import requestx

# GET request
response = requestx.get('https://httpbin.org/get')

# POST request with JSON data
data = {'name': 'John Doe', 'email': 'john@example.com'}
response = requestx.post('https://httpbin.org/post', json=data)

# PUT request with form data
form_data = {'key': 'value'}
response = requestx.put('https://httpbin.org/put', data=form_data)

# DELETE request
response = requestx.delete('https://httpbin.org/delete')

# Custom headers
headers = {'Authorization': 'Bearer your-api-token'}
response = requestx.get('https://httpbin.org/headers', headers=headers)
```

### Session Usage

```python
import requestx

# Create a session for connection reuse
session = requestx.Session()

# Set default headers
session.headers.update({'Authorization': 'Bearer token'})

# Make requests using the session
response = session.get('https://httpbin.org/get')
print(response.status_code)
```

### Asynchronous Usage

RequestX automatically detects whether you're in a synchronous or asynchronous context:

```python
import asyncio
import requestx

# Synchronous context - runs immediately
def sync_function():
    response = requestx.get('https://httpbin.org/json')
    return response.json()

# Asynchronous context - returns awaitable
async def async_function():
    response = await requestx.get('https://httpbin.org/json')
    return response.json()

# Usage
sync_data = sync_function()  # Immediate result
async_data = asyncio.run(async_function())  # Awaitable result
```

### Concurrent Async Requests

```python
import asyncio
import requestx

async def fetch_url(url):
    response = await requestx.get(url)
    return response.json()

async def main():
    urls = [
        'https://httpbin.org/delay/1',
        'https://httpbin.org/delay/2',
        'https://httpbin.org/delay/3'
    ]
    
    # Run requests concurrently
    results = await asyncio.gather(*[fetch_url(url) for url in urls])
    return results

# Execute
results = asyncio.run(main())
```

## 🔄 Migration from Requests

RequestX is designed as a **drop-in replacement** for requests. The easiest way to migrate is to simply change your import statement:

**Before (requests):**
```python
import requests

response = requests.get('https://api.example.com/data')
print(response.json())
```

**After (requestx):**
```python
import requestx as requests  # Drop-in replacement

response = requests.get('https://api.example.com/data')
print(response.json())
```

Or use RequestX directly:
```python
import requestx

response = requestx.get('https://api.example.com/data')
print(response.json())
```

## 🏗️ Development

This project uses:
- **Rust** for the core HTTP implementation
- **PyO3** for Python bindings
- **maturin** for building and packaging
- **uv** for Python dependency management

### Setup Development Environment

```bash
# Install uv for Python dependency management
curl -LsSf https://astral.sh/uv/install.sh | sh

# Install development dependencies
uv sync --dev

# Build the extension
uv run maturin develop
```

### Running Tests

```bash
# Run Python tests
uv run pytest

# Run Rust tests
cargo test
```

### Building

```bash
# Build wheel
uv run maturin build --release

# Build and install locally
uv run maturin develop --release
```





## 📄 License

MIT License - see LICENSE file for details.

## 📧 Contact

For questions, issues, or contributions, please contact: **wu.qunfei@gmail.com**

## 🤝 Contributing

We welcome contributions! Please see our contributing guidelines for more information on how to get started.

## 📚 Documentation

For comprehensive documentation, examples, and advanced usage patterns, visit our [documentation site](https://requestx.readthedocs.io/).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/neuesql/requestx",
    "name": "requestx",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "http, requests, client, async, performance",
    "author": null,
    "author_email": "RequestX Team <wu.qunfei@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/28/f1/ebfccd7eda846c7218ed038e798aa768dd317962f775995ba64c3f6023b3/requestx-0.2.8.tar.gz",
    "platform": null,
    "description": "# RequestX\n\n[![PyPI version](https://img.shields.io/pypi/v/requestx.svg)](https://pypi.org/project/requestx/)\n[![Python versions](https://img.shields.io/pypi/pyversions/requestx.svg)](https://pypi.org/project/requestx/)\n[![Build status](https://github.com/neuesql/requestx/workflows/Test%20and%20Build/badge.svg)](https://github.com/neuesql/requestx/actions)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\nRequestX is a high-performance HTTP client library for Python that provides a **drop-in replacement** for the popular `requests` library. Built with Rust for speed and memory safety, it offers both synchronous and asynchronous APIs while maintaining full compatibility with the familiar requests interface.\n\n## \ud83d\ude80 Key Features\n\n* **Drop-in replacement** for requests library with identical API\n* **High performance** leveraging Rust's speed and memory safety  \n* **Dual API support** - both sync and async/await patterns\n* **Cross-platform** compatibility (Windows, macOS, Linux)\n* **Requests compatibility** for easy migration from existing codebases\n* **Native async/await** support with automatic context detection\n* **Session management** with persistent connections and cookies\n* **Comprehensive error handling** with requests-compatible exceptions\n\n## \u26a1 Performance\n\nRequestX delivers significant performance improvements over traditional Python HTTP libraries:\n\n* **2-5x faster** than requests for synchronous operations\n* **3-10x faster** than aiohttp for asynchronous operations  \n* **Lower memory usage** due to Rust's efficient memory management\n* **Better connection pooling** with hyper's advanced HTTP/2 support\n\n## \ud83d\udce6 Installation\n\n### Requirements\n\n* **Python**: 3.8 or higher\n* **Operating System**: Windows, macOS, or Linux\n* **Architecture**: x86_64, ARM64 (Apple Silicon, ARM64 Windows)\n\nNo additional dependencies or build tools are required - RequestX comes with all Rust dependencies pre-compiled and bundled.\n\n### Standard Installation\n\nInstall RequestX using pip:\n\n```bash\npip install requestx\n```\n\n\n\n## \ud83d\ude80 Quick Start\n\n### Basic Usage\n\nRequestX provides the exact same API as the popular `requests` library. If you're familiar with requests, you already know how to use RequestX!\n\n```python\nimport requestx\n\n# Make a simple GET request\nresponse = requestx.get('https://httpbin.org/json')\n\n# Check the status\nprint(f\"Status: {response.status_code}\")\n\n# Get JSON data\ndata = response.json()\nprint(f\"Data: {data}\")\n```\n\n### Common HTTP Methods\n\n```python\nimport requestx\n\n# GET request\nresponse = requestx.get('https://httpbin.org/get')\n\n# POST request with JSON data\ndata = {'name': 'John Doe', 'email': 'john@example.com'}\nresponse = requestx.post('https://httpbin.org/post', json=data)\n\n# PUT request with form data\nform_data = {'key': 'value'}\nresponse = requestx.put('https://httpbin.org/put', data=form_data)\n\n# DELETE request\nresponse = requestx.delete('https://httpbin.org/delete')\n\n# Custom headers\nheaders = {'Authorization': 'Bearer your-api-token'}\nresponse = requestx.get('https://httpbin.org/headers', headers=headers)\n```\n\n### Session Usage\n\n```python\nimport requestx\n\n# Create a session for connection reuse\nsession = requestx.Session()\n\n# Set default headers\nsession.headers.update({'Authorization': 'Bearer token'})\n\n# Make requests using the session\nresponse = session.get('https://httpbin.org/get')\nprint(response.status_code)\n```\n\n### Asynchronous Usage\n\nRequestX automatically detects whether you're in a synchronous or asynchronous context:\n\n```python\nimport asyncio\nimport requestx\n\n# Synchronous context - runs immediately\ndef sync_function():\n    response = requestx.get('https://httpbin.org/json')\n    return response.json()\n\n# Asynchronous context - returns awaitable\nasync def async_function():\n    response = await requestx.get('https://httpbin.org/json')\n    return response.json()\n\n# Usage\nsync_data = sync_function()  # Immediate result\nasync_data = asyncio.run(async_function())  # Awaitable result\n```\n\n### Concurrent Async Requests\n\n```python\nimport asyncio\nimport requestx\n\nasync def fetch_url(url):\n    response = await requestx.get(url)\n    return response.json()\n\nasync def main():\n    urls = [\n        'https://httpbin.org/delay/1',\n        'https://httpbin.org/delay/2',\n        'https://httpbin.org/delay/3'\n    ]\n    \n    # Run requests concurrently\n    results = await asyncio.gather(*[fetch_url(url) for url in urls])\n    return results\n\n# Execute\nresults = asyncio.run(main())\n```\n\n## \ud83d\udd04 Migration from Requests\n\nRequestX is designed as a **drop-in replacement** for requests. The easiest way to migrate is to simply change your import statement:\n\n**Before (requests):**\n```python\nimport requests\n\nresponse = requests.get('https://api.example.com/data')\nprint(response.json())\n```\n\n**After (requestx):**\n```python\nimport requestx as requests  # Drop-in replacement\n\nresponse = requests.get('https://api.example.com/data')\nprint(response.json())\n```\n\nOr use RequestX directly:\n```python\nimport requestx\n\nresponse = requestx.get('https://api.example.com/data')\nprint(response.json())\n```\n\n## \ud83c\udfd7\ufe0f Development\n\nThis project uses:\n- **Rust** for the core HTTP implementation\n- **PyO3** for Python bindings\n- **maturin** for building and packaging\n- **uv** for Python dependency management\n\n### Setup Development Environment\n\n```bash\n# Install uv for Python dependency management\ncurl -LsSf https://astral.sh/uv/install.sh | sh\n\n# Install development dependencies\nuv sync --dev\n\n# Build the extension\nuv run maturin develop\n```\n\n### Running Tests\n\n```bash\n# Run Python tests\nuv run pytest\n\n# Run Rust tests\ncargo test\n```\n\n### Building\n\n```bash\n# Build wheel\nuv run maturin build --release\n\n# Build and install locally\nuv run maturin develop --release\n```\n\n\n\n\n\n## \ud83d\udcc4 License\n\nMIT License - see LICENSE file for details.\n\n## \ud83d\udce7 Contact\n\nFor questions, issues, or contributions, please contact: **wu.qunfei@gmail.com**\n\n## \ud83e\udd1d Contributing\n\nWe welcome contributions! Please see our contributing guidelines for more information on how to get started.\n\n## \ud83d\udcda Documentation\n\nFor comprehensive documentation, examples, and advanced usage patterns, visit our [documentation site](https://requestx.readthedocs.io/).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "High-performance HTTP client for Python with requests-compatible API",
    "version": "0.2.8",
    "project_urls": {
        "Bug Tracker": "https://github.com/neuesql/requestx/issues",
        "Documentation": "https://requestx.readthedocs.io",
        "Homepage": "https://github.com/neuesql/requestx",
        "Repository": "https://github.com/neuesql/requestx"
    },
    "split_keywords": [
        "http",
        " requests",
        " client",
        " async",
        " performance"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "c25de461dc875a388028d9184bf51b108fa14500ac497765f249fe5747466142",
                "md5": "dca897f9f0265f7da0435fed3c2763ed",
                "sha256": "4563e562fa318713e4c2984b5ac1bd8fdaddb72c6220b2e2efaeb85abfa8e36e"
            },
            "downloads": -1,
            "filename": "requestx-0.2.8-cp38-abi3-macosx_11_0_arm64.whl",
            "has_sig": false,
            "md5_digest": "dca897f9f0265f7da0435fed3c2763ed",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.8",
            "size": 1215672,
            "upload_time": "2025-08-18T10:15:30",
            "upload_time_iso_8601": "2025-08-18T10:15:30.892064Z",
            "url": "https://files.pythonhosted.org/packages/c2/5d/e461dc875a388028d9184bf51b108fa14500ac497765f249fe5747466142/requestx-0.2.8-cp38-abi3-macosx_11_0_arm64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "28f1ebfccd7eda846c7218ed038e798aa768dd317962f775995ba64c3f6023b3",
                "md5": "611d5566141a9280c26da523728da89a",
                "sha256": "4ed7421478cdd553fd66bf0c7fe5b2f8df5649beb2a5dca2899d3f1dbf815f86"
            },
            "downloads": -1,
            "filename": "requestx-0.2.8.tar.gz",
            "has_sig": false,
            "md5_digest": "611d5566141a9280c26da523728da89a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 760667,
            "upload_time": "2025-08-18T10:15:33",
            "upload_time_iso_8601": "2025-08-18T10:15:33.547632Z",
            "url": "https://files.pythonhosted.org/packages/28/f1/ebfccd7eda846c7218ed038e798aa768dd317962f775995ba64c3f6023b3/requestx-0.2.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-18 10:15:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "neuesql",
    "github_project": "requestx",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "requestx"
}
        
Elapsed time: 0.77304s