Skip to main content

A fast HTTP client library for Python powered by Rust

Project description

🚀 pikahttp

CI PyPI version License: MIT Python Versions

A blazingly fast HTTP client for Python, powered by Rust and Hyper.

pikahttp combines Python's ease of use with Rust's performance, providing a simple yet powerful HTTP client that's up to 18% faster than traditional Python HTTP libraries.


📖 Documentation Languages


✨ Features

  • Fast: Built with Rust and Hyper for maximum performance
  • 🔄 Simple: Clean, intuitive Python API
  • 🛡️ Reliable: Battle-tested Rust libraries under the hood
  • 💾 Efficient: Minimal memory allocations and zero-copy operations
  • 🔒 Safe: Thread-safe and memory-safe by design
  • 🚀 Async-first: Fully asynchronous HTTP requests

🔧 Installation

pip install pikahttp

From Source

git clone https://github.com/GrandmaEJ/pikahttp.git
cd pikahttp
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
pip install -r requirements-dev.txt
pip install maturin
maturin develop

🚀 Quick Start

Using Session

from pikahttp import Session
import json

# Create a session
session = Session()

# GET request
response = session.request(
    "GET",
    "https://httpbin.org/get",
    headers={"User-Agent": "pikahttp/0.1.0"}
)
print(f"Status code: {response['status_code']}")
print(f"Content: {response['content']}")

# POST request with JSON
data = {"hello": "world"}
response = session.request(
    "POST",
    "https://httpbin.org/post",
    headers={
        "User-Agent": "pikahttp/0.1.0",
        "Content-Type": "application/json"
    },
    body=json.dumps(data)
)
print(f"Status code: {response['status_code']}")
print(f"Response: {response['content']}")

Using Convenience Functions

from pikahttp import Session

# Create a session
session = Session()

# GET request
response = session.get("https://api.github.com/zen")
print(f"Status: {response['status_code']}")
print(f"Headers: {response['headers']}")

# POST request
response = session.post(
    "https://httpbin.org/post",
    headers={"Content-Type": "application/json"},
    body='{"key": "value"}'
)
print(f"Response: {response['content']}")

⚡ Performance

Based on benchmarks with 100 requests each:

Library Mean (s) Median (s) Min (s) Max (s) StdDev (s)
urllib 0.2389 0.2351 0.2291 0.6488 0.0415
requests 0.2590 0.2575 0.2524 0.3014 0.0071
pikahttp 0.2193 0.2202 0.2162 0.2252 0.0021
  • 🚀 18.1% faster than requests
  • 🎯 8.9% faster than urllib
  • 📊 More consistent performance (lower standard deviation)

🛠️ Development

Running Tests

python -m venv .venv
source .venv/bin/activate
pip install -r requirements-dev.txt
pytest tests/

Running Benchmarks

python benchmark.py

🔒 Security & Features

  • Async-first design powered by Rust and Tokio
  • HTTP/2 support
  • Cookie handling
  • Custom headers, query parameters, and JSON/form support
  • Proper error handling and timeout configuration
  • Session support

📖 Documentation


📝 License

MIT License. See LICENSE for details.

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 Distribution

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

pikahttp-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

File details

Details for the file pikahttp-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pikahttp-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 be8e4db1e9958e201b7fbb8d6690e506f5836a94f9840de75c6e719910e5a978
MD5 218b84010a6192f669b50a07693d6a2d
BLAKE2b-256 592c4de721a5c97893522b6ac6a72fa431082f03528fea26afa90372c4bfff0f

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