Skip to main content

High-performance Python web framework with Rust backend

Project description

BustAPI — High-Performance Python Web Framework

BustAPI - Fast Python Web Framework powered by Rust and Actix-Web

The fastest Python web framework for building REST APIs
Flask-like syntax • Rust-powered performance • Up to 20,000+ requests/sec

BustAPI on PyPI CI Status Python 3.10 3.11 3.12 3.13 3.14 MIT License


⚡ What is BustAPI?

BustAPI is a production-ready Python web framework that combines the best of both worlds: Python's simplicity and Rust's raw performance.

Under the hood, BustAPI runs on Actix-Web — consistently ranked among the fastest web frameworks across all programming languages. But you never touch Rust. You write clean, familiar Python code with Flask-style decorators.

Why BustAPI?

Problem BustAPI Solution
Python web frameworks are slow Rust core handles HTTP, JSON, routing
ASGI/WSGI adds overhead Built-in server, no middleware layers
Scaling requires complex setup Native multiprocessing with SO_REUSEPORT
Auth is always a pain JWT, sessions, Argon2 hashing built-in

Key Highlights

  • 🚀 20,000+ RPS out of the box — 5x faster than Flask
  • 🦀 Rust-powered — Zero-copy JSON, mimalloc allocator, Actix-Web
  • 🐍 Pure Python API — No Rust knowledge required
  • 🔒 Security built-in — JWT, sessions, CSRF, rate limiting
  • 🛡️ Robust Header System — Case-insensitive, multi-value support, high-performance cookie parsing
  • 📦 Zero configpip install bustapi and you're ready
  • 🔥 Hot reload — Rust-native file watcher for instant restarts
from bustapi import BustAPI

app = BustAPI()

@app.route("/")
def hello():
    return {"message": "Hello, world!"}

if __name__ == "__main__":
    app.run()

No ASGI servers needed. No complex configuration. Just run your file.


🏗️ Architecture

┌─────────────────────────────────────────────────────────────┐
│                     Your Python Code                        │
│              (Flask-like decorators & handlers)             │
├─────────────────────────────────────────────────────────────┤
│                    PyO3 Bindings (v0.27)                    │
│              (Zero-cost Python ↔ Rust bridge)               │
├─────────────────────────────────────────────────────────────┤
│                  Rust Core (bustapi_core)                   │
│  ┌─────────────┐ ┌─────────────┐ ┌─────────────────────────┐│
│  │ Actix-Web   │ │ serde_json  │ │ mimalloc allocator      ││
│  │ HTTP Server │ │ Zero-copy   │ │ Optimized memory        ││
│  └─────────────┘ └─────────────┘ └─────────────────────────┘│
└─────────────────────────────────────────────────────────────┘
Component Technology Purpose
HTTP Server Actix-Web 4.x Ultra-fast async HTTP handling
Serialization serde_json Zero-copy JSON encoding
Memory mimalloc High-performance allocator
Bindings PyO3 0.27 Python 3.10–3.14 support
Async Runtime Tokio Non-blocking I/O

📦 Installation

pip install bustapi

Supports: Python 3.10 – 3.14 | Linux, macOS, Windows | x86_64 & ARM64

Pre-built wheels available — no Rust toolchain required!


✨ Features

🛣️ Routing

  • Dynamic Routes/users/<int:id> with automatic type validation
  • Blueprints — Modular app organization (Flask-style)
  • Turbo Routes — Zero-overhead handlers for maximum speed
  • Wildcard Paths<path:filepath> for catch-all routes

🔐 Authentication & Security

  • JWT — Create/validate tokens (HS256, HS384, HS512)
  • Sessions — Flask-Login compatible user management
  • Password Hashing — Argon2id (OWASP recommended)
  • CSRF Protection — Built-in token validation
  • Rate Limiting — Rust-powered request throttling

🌐 HTTP Features

  • WebSocket — Full duplex communication + Turbo mode
  • Streaming — HTTP Range requests, video seeking
  • File Uploads — Multipart form handling
  • Static Files — Efficient serving with caching

🛠️ Developer Experience

  • Hot Reload — Rust-native file watcher (instant restarts)
  • Templates — Built-in Jinja2 via MiniJinja
  • CLI Toolbustapi new, bustapi run, bustapi routes
  • Auto-docs — OpenAPI/Swagger generation
  • Testing — Built-in TestClient for unit tests

🔌 Compatibility

  • ASGI/WSGI — Works with Uvicorn, Gunicorn, Hypercorn
  • FastAPI-styleQuery(), Path(), Body(), Depends()
  • Flask-stylerequest, session, g, current_app

🚀 Quick Start

1. Create app.py:

from bustapi import BustAPI, jsonify

app = BustAPI()

@app.route("/")
def home():
    return {"status": "running", "framework": "BustAPI"}

@app.route("/users/<int:user_id>")
def get_user(user_id):
    return jsonify({"id": user_id, "name": "Alice"})

@app.route("/greet", methods=["POST"])
def greet():
    from bustapi import request
    data = request.json
    return {"message": f"Hello, {data.get('name', 'World')}!"}

if __name__ == "__main__":
    app.run(debug=True)  # Hot reload enabled

2. Run it:

python app.py

3. Visit http://127.0.0.1:5000


⚡ Turbo Routes

For maximum performance, use @app.turbo_route(). Path parameters are parsed entirely in Rust:

# Zero-overhead static route
@app.turbo_route("/health")
def health():
    return {"status": "ok"}

# Dynamic route with typed params (parsed in Rust)
@app.turbo_route("/users/<int:id>")
def get_user(id: int):
    return {"id": id, "name": f"User {id}"}

# Cached response (140k+ RPS!)
@app.turbo_route("/config", cache_ttl=60)
def get_config():
    return {"version": "1.0", "env": "production"}

Supported types: int, float, str, path

⚠️ Note: Turbo routes skip middleware, sessions, and request context for speed. Use @app.route() when you need those features.


📊 Benchmarks

Standard Routes (@app.route())

Platform RPS Mode
Linux ~25,000 Single-process
macOS ~20,000 Single-process
Windows ~17,000 Single-process

Turbo Routes (@app.turbo_route()) — Linux

Configuration RPS
Static route ~30,000 (single)
Multiprocessing (4 workers) ~105,000
Cached (60s TTL) ~140,000

Framework Comparison (Turbo + Multiprocessing)

BustAPI vs Other Frameworks


🌍 Platform Support

🐧 Linux (Recommended for Production)

Linux delivers the best performance with native multiprocessing:

  • ~25k RPS standard routes, 100k+ RPS with Turbo + multiprocessing
  • Kernel-level load balancing via SO_REUSEPORT
  • Automatic worker scaling to CPU cores
python app.py  # Automatically uses multiprocessing

🍎 macOS (Development)

Fully supported for development. Single-process mode (~35k RPS):

pip install bustapi && python app.py

🪟 Windows (Development)

Fully supported for development. Single-process mode (~17k RPS):

pip install bustapi && python app.py

💡 Tip: For production, deploy on Linux servers to unlock multiprocessing performance.


🔐 Authentication

JWT Tokens

from bustapi import BustAPI
from bustapi.jwt import JWT

app = BustAPI()
jwt = JWT(app, secret_key="your-secret-key")

@app.route("/login", methods=["POST"])
def login():
    # Validate credentials...
    token = jwt.create_access_token(identity=user_id)
    return {"access_token": token}

@app.route("/protected")
@jwt.jwt_required()
def protected():
    return {"user": jwt.get_jwt_identity()}

Session Login

from bustapi.auth import LoginManager, login_user, current_user, login_required

login_manager = LoginManager(app)

@login_manager.user_loader
def load_user(user_id):
    return User.get(user_id)

@app.route("/login", methods=["POST"])
def login():
    user = authenticate(request.form)
    login_user(user)
    return redirect("/dashboard")

@app.route("/dashboard")
@login_required
def dashboard():
    return f"Welcome, {current_user.name}!"

Password Hashing

from bustapi.auth import hash_password, verify_password

# Hash (Argon2id)
hashed = hash_password("mysecretpassword")

# Verify
if verify_password("mysecretpassword", hashed):
    print("Password correct!")

🌐 WebSocket

@app.websocket("/ws")
async def websocket_handler(ws):
    await ws.accept()
    while True:
        message = await ws.receive_text()
        await ws.send_text(f"Echo: {message}")

Turbo WebSocket (Pure Rust, ~74% faster):

@app.turbo_websocket("/ws/turbo")
def turbo_handler(message: str) -> str:
    return f"Echo: {message}"  # Processed entirely in Rust

🧪 Testing

from bustapi.testing import TestClient

def test_homepage():
    client = TestClient(app)
    response = client.get("/")
    assert response.status_code == 200
    assert response.json() == {"status": "running"}

def test_create_user():
    response = client.post("/users", json={"name": "Alice"})
    assert response.status_code == 201

📁 Project Structure

bustapi/
├── src/                    # Rust core
│   ├── lib.rs              # PyO3 module entry
│   ├── bindings/           # Python ↔ Rust bridge
│   ├── router/             # URL matching engine
│   ├── server/             # Actix-Web handlers
│   ├── websocket/          # WS session management
│   ├── jwt.rs              # Token encoding/decoding
│   └── crypto.rs           # Argon2, CSRF, tokens
│
├── python/bustapi/         # Python package
│   ├── app.py              # BustAPI main class
│   ├── auth/               # JWT, sessions, CSRF
│   ├── routing/            # Blueprints, decorators
│   ├── params.py           # Query/Path/Body validators
│   └── websocket.py        # WebSocket API
│
├── examples/               # 30+ usage examples
├── tests/                  # Comprehensive test suite
├── docs/                   # MkDocs documentation
└── benchmarks/             # Performance tools

🛠️ CLI Tool

# Create new project
bustapi new myproject

# Run with hot reload
bustapi run

# List all routes
bustapi routes

# Show system info
bustapi info

🚢 Deployment

Built-in Server (Recommended)

python app.py

Uses the internal Rust HTTP server. Best performance, zero dependencies.

With ASGI (Uvicorn)

pip install uvicorn
uvicorn app:app.asgi_app --host 0.0.0.0 --port 8000

With Docker

FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
EXPOSE 5000
CMD ["python", "app.py"]

📖 Documentation

📚 Full Documentation


🤝 Contributing

We welcome contributions! Here's how:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing)
  5. Open a Pull Request

Found a bug? Have a feature request?


💰 Support

If BustAPI helps your project, consider supporting its development:

Binance ID: 1010167458


🌠 Star History

Star History Chart


📄 License

MIT © 2025-2026 GrandpaEJ


Built with 🦀 Rust + 🐍 Python
Fast. Simple. Production-ready.

Project details


Download files

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

Source Distribution

bustapi-0.13.1.tar.gz (1.2 MB view details)

Uploaded Source

Built Distributions

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

bustapi-0.13.1-cp310-abi3-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.10+Windows x86-64

bustapi-0.13.1-cp310-abi3-musllinux_1_2_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ x86-64

bustapi-0.13.1-cp310-abi3-musllinux_1_2_aarch64.whl (2.7 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

bustapi-0.13.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

bustapi-0.13.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.5 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

bustapi-0.13.1-cp310-abi3-macosx_11_0_arm64.whl (2.3 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

bustapi-0.13.1-cp310-abi3-macosx_10_12_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file bustapi-0.13.1.tar.gz.

File metadata

  • Download URL: bustapi-0.13.1.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for bustapi-0.13.1.tar.gz
Algorithm Hash digest
SHA256 cf5006fb66c58036fcbf1698baee02d720a5f5e632e238894a8a430cd323e8a7
MD5 d2ec0f942587b3f465420a22706b9f6b
BLAKE2b-256 f251a4ee28ecaf125cac2f56311a659d654f13d62a066f5c99e0e82613e1e2a7

See more details on using hashes here.

File details

Details for the file bustapi-0.13.1-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: bustapi-0.13.1-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for bustapi-0.13.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 9fd92672194a3ec8819c646969d6282eecfc97d7f0c0221b68ec882bc0ba5e32
MD5 d626bfe3573062c698f6bbd984fecabc
BLAKE2b-256 6137c4f1632595887ba18e4b4a207a1ab8107b4fdce264beebcfcc38285eb6b0

See more details on using hashes here.

File details

Details for the file bustapi-0.13.1-cp310-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for bustapi-0.13.1-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d79eb8da61c254d45077ca67a016cc4de58741ba416232d187ecfee01884d487
MD5 3ad45890aaf3b84f709713605122a97c
BLAKE2b-256 ad053b69083f64e022fa14efa531b1bf741ec0f8f216ea6022745087f5b76792

See more details on using hashes here.

File details

Details for the file bustapi-0.13.1-cp310-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for bustapi-0.13.1-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 f962b7f59132f6ccaa7f9fd81715b869500a94a568c1f744b466b3abe6991db3
MD5 18a5cceb7c0aee7e85400ad5edbdb118
BLAKE2b-256 2ebdf5fbc0143acc258797ad369add4513a42f37c4a5b90d14f9c532f537f63c

See more details on using hashes here.

File details

Details for the file bustapi-0.13.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bustapi-0.13.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f3a8b3a86d994fcfcb55a7f72c74299f10511d7be98ad8d42298e92b07b76687
MD5 629fd21cb50b25ce364b29a00ddba30f
BLAKE2b-256 b927cf153a78fde7a023531fd1117e541b1e88fcba23b51e7eaa0435c709fabe

See more details on using hashes here.

File details

Details for the file bustapi-0.13.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for bustapi-0.13.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5bd6c6bdfd592abe7e5af737ae6e1a9d90170a3780a635fcba41518da43fc1ad
MD5 f390fbbb85fe584c8f237713a27f37bd
BLAKE2b-256 d2e46cb17cf9290a9b7715e04704e1bd68b7acde121ace5ee26057d732d287e7

See more details on using hashes here.

File details

Details for the file bustapi-0.13.1-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for bustapi-0.13.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 59fc345688ceb7cf89c7836a07587f13bdbb1bc08b84b4c912fb7a60c6025353
MD5 73d192b81a01830ca2e9b2b76a456cb3
BLAKE2b-256 6fcc95e5c656fcd134a7adbc0952d23f3a16e0f645a026ea5c33f2bb9223f4b1

See more details on using hashes here.

File details

Details for the file bustapi-0.13.1-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for bustapi-0.13.1-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 74ce090a4a850dbe4a5716d6301ff5986600864bf1ddd431653e05324fa4e9c1
MD5 b79beef1e21070c732dc173ecb4c0f65
BLAKE2b-256 0c451fc11bb862a8f9b374db79961b66652df5a63982a654478715a0b59b2386

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