JustAPI — Rust-powered Python web framework. FastAPI compatibility, 20× the throughput.
Documentation: https://github.com/swadhinbiswas/JustAPI/docs
Source Code: https://github.com/swadhinbiswas/JustAPI
JustAPI is a modern, blazing-fast web framework for building APIs with Python, powered by a Rust core. It's designed as a drop-in replacement for FastAPI — same decorator syntax, same Pydantic models, same developer experience — but with the entire networking, routing, serialization, and middleware stack written in Rust.
Python writes the logic. Rust does everything else.
The key features are:
- Fast: 700,000+ req/s on a single machine — 20× faster than FastAPI+Uvicorn. The Rust runtime handles networking, TLS, routing, serialization, and middleware at near-native speed.
- FastAPI-compatible: Same
@app.get()decorators, same Pydantic models, same dependency injection. Migrate existing FastAPI apps with minimal changes. - Type-safe: Full
.pyitype stubs for every module. Autocomplete and type checking work out of the box in VS Code, PyCharm, and Neovim. - Production-ready: Built-in JWT auth, rate limiting, circuit breakers, distributed tracing (OpenTelemetry), Prometheus metrics, and health checks — all in Rust, not Python middleware.
- Standards-based: Auto-generated OpenAPI 3.1 docs, JSON Schema validation, gRPC and GraphQL support.
- Batteries included: WebSockets, SSE, background tasks, dependency injection, database ORM, file uploads, static files, template rendering, and a plugin system — all from a single
pip install.
Performance
Hello-world benchmark · 100 concurrent connections · 30 seconds · same hardware
| Framework | Requests/sec | p50 Latency | p99 Latency |
|---|---|---|---|
| JustAPI 🦀 | 701,234 | 0.07 ms | 0.19 ms |
| Granian | 69,195 | 0.72 ms | 3.87 ms |
| FastAPI + Uvicorn | 36,189 | 1.72 ms | 24.63 ms |
20× faster than FastAPI and 10× faster than Granian on the same workload. See BENCHMARKS.md for full methodology, hardware specs, and JSON/echo benchmarks.
How is this possible?
JustAPI moves the entire request pipeline out of Python:
Kernel (epoll/io_uring)
→ Connection Manager (tokio)
→ TLS termination (rustls)
→ HTTP parse (hyper)
→ Router (matchit)
→ Middleware chain (Rust: auth, CORS, rate-limit, compression)
→ Python boundary (zero-copy via PyO3 buffer protocol)
→ Your application code (async Python)
→ Rust serializer (serde_json / simd-json)
→ Response write → Socket
Python only executes your business logic. Everything else — TLS, parsing, routing, auth, serialization, compression — runs in Rust at native speed with zero GIL contention.
What makes JustAPI different
Two things, stated plainly:
- Throughput. A Rust networking core (hyper + tokio + rustls) moves TLS,
routing, serialization, and middleware out of Python. The number above
(701k req/s hello-world) is the payoff — ~20× FastAPI+Uvicorn on that
workload. - Agent-native serving. Beyond REST, JustAPI has a first-class
introspection + tool-serving layer for AI agents: every app can expose its
routes as MCP tools (python -m justapi.mcp_server), stream validated
structured output as tokens arrive, and carry multi-turn session state —
without bolting a third-party SDK onto generic HTTP routes. This is the part
we invest in most; seeROADMAP.mdfor how far it goes.
Competitors, named honestly
We are not the first Rust-backed Python framework, and we don't claim to be:
- Robyn — Rust runtime, decorator API, commonly cited ~40–60% faster than
FastAPI on simple endpoints. Real project; we benchmark against it. - Granian — Rust ASGI server that drops under existing ASGI apps. Different
bet: it replaces the server, not the framework. - Litestar / BlackSheep — Python frameworks with first-class ASGI and
rich feature sets; we borrow ergonomics from them. - FastAPI — the compatibility target. JustAPI mirrors its decorator API and
Pydantic models so migration is low-friction.
Where we deliberately differ from Robyn: JustAPI keeps an ASGI shim (so it
runs under Uvicorn/Granian and reuses Starlette-ecosystem middleware) and treats
agent/MCP serving as a built-in primitive rather than an afterthought.
Non-goals & not-yet-built
JustAPI is not trying to be everything in v1. We do not ship a custom
edge/WASM runtime, a from-scratch ORM/migrations system, a multi-tenant auth
platform, or a new validator (we wrap Pydantic v2 core / JSON Schema). SeeROADMAP.md for the full, explicitly-labeled future list.
Requirements
- Python 3.11+
- Rust 1.85+ (only for building from source)
Installation
$ pip install justapi
---> 100%
Successfully installed justapi-2.0.0
Or build from source with maturin:
cd crates/justapi-py
maturin develop --release
Example
Create it
Create a file main.py with:
from justapi import JustAPIApp
app = JustAPIApp()
@app.get("/")
def read_root():
return {"Hello": "World"}
@app.get("/items/{item_id}")
def read_item(item_id: int, q: str | None = None):
return {"item_id": item_id, "q": q}
Run it
$ python main.py
INFO: JustAPI running on http://127.0.0.1:8000
INFO: Rust runtime started with 4 worker threads
Check it
Open your browser at http://127.0.0.1:8000/items/5?q=somequery.
You will see the JSON response as:
{"item_id": 5, "q": "somequery"}
You already created an API that:
- Receives HTTP requests at the paths
/and/items/{item_id}. - Both paths take
GEToperations (also known as HTTP methods). - The path
/items/{item_id}has a path parameteritem_idthat should be anint. - The path
/items/{item_id}has an optionalstrquery parameterq.
Interactive API docs
Now go to http://127.0.0.1:8000/docs.
You will see the automatic interactive API documentation (provided by Swagger UI), auto-generated from your code.
Example upgrade
Now modify the file main.py to receive a body from a PUT request.
Declare the body using standard Python types, thanks to Pydantic:
from justapi import JustAPIApp
from pydantic import BaseModel
app = JustAPIApp()
class Item(BaseModel):
name: str
description: str | None = None
price: float
tax: float | None = None
@app.get("/")
def read_root():
return {"Hello": "World"}
@app.get("/items/{item_id}")
def read_item(item_id: int):
return {"item_id": item_id}
@app.put("/items/{item_id}")
def update_item(item_id: int, item: Item):
return {"item_name": item.name, "item_id": item_id, "price_with_tax": item.price + (item.tax or 0)}
The server will reload automatically (when using --reload).
Interactive API docs upgrade
Now go to http://127.0.0.1:8000/docs.
- The interactive API documentation will be automatically updated, including the new body.
- Click on the "Try it out" button, it allows you to fill the parameters and directly interact with the API.
- Then click on the "Execute" button, the user interface will communicate with your API, send the parameters, get the results and show them on the screen.
Alternative API docs
And now go to http://127.0.0.1:8000/redoc.
- The alternative documentation will also reflect the new query parameter and body.
Example with dependencies
JustAPI supports FastAPI-style dependency injection:
from justapi import JustAPIApp, Depends
app = JustAPIApp()
def common_parameters(q: str | None = None, skip: int = 0, limit: int = 100):
return {"q": q, "skip": skip, "limit": limit}
@app.get("/items/")
def read_items(commons: dict = Depends(common_parameters)):
return {"message": "Reading items", "params": commons}
@app.get("/users/")
def read_users(commons: dict = Depends(common_parameters)):
return {"message": "Reading users", "params": commons}
Example with WebSockets
from justapi import JustAPIApp
app = JustAPIApp()
@app.websocket("/ws")
async def websocket_endpoint(ws):
await ws.accept()
while True:
data = await ws.receive_text()
await ws.send_text(f"Echo: {data}")
Features
FastAPI-compatible, Rust-accelerated
JustAPI gives you the same developer experience as FastAPI, but with a Rust engine underneath. Here's what you get:
| Category | Feature | Details |
|---|---|---|
| 🚀 Performance | HTTP/1.1 & HTTP/2 | 700k+ req/s hello-world |
| TLS (rustls) | ~10% overhead, no OpenSSL dependency | |
| Serialization | serde_json with optional simd-json | |
| Compression | gzip / deflate / brotli / zstd | |
| 🔒 Security | JWT Authentication | RS256/ES256, per-route roles & scopes |
| Rate Limiting | GCRA algorithm, Redis-backed distributed | |
| CORS | Configurable, preflight caching | |
| Request Validation | JSON Schema, Pydantic v2 bridge | |
| Security Headers | HSTS, CSP, X-Frame-Options, etc. | |
| 📡 Protocols | REST | Full HTTP method support with OpenAPI 3.1 |
| WebSocket | Full-duplex with streaming support | |
| Server-Sent Events | Token-generation optimized streaming | |
| gRPC | Native Tonic integration | |
| GraphQL | async-graphql with Apollo Federation | |
| 🧩 Application | Dependency Injection | Litestar-style tiered DI container |
| Background Tasks | Thread-safe task scheduling | |
| Database ORM | SQLite / PostgreSQL / MySQL via sqlx | |
| Template Engine | Jinja2 integration | |
| File Uploads | Streaming multipart/form-data | |
| 🔧 Operations | Observability | OpenTelemetry tracing, Prometheus metrics |
| Resilience | Circuit breakers, retry, fallback, bulkhead | |
| Health Checks | Liveness & readiness probe endpoints | |
| Plugin System | Third-party extension API with lifecycle hooks | |
| WASM Plugins | wasmtime-powered WebAssembly middleware | |
| 🛡️ Quality | Memory Safety | Miri-verified, 6 fuzz targets |
| Type Stubs | Complete .pyi for all public modules | |
| Test Utilities | Built-in TestClient & snapshot testing |
Coming from FastAPI?
JustAPI is designed to feel familiar. Here's a side-by-side:
| FastAPI | JustAPI | |
|---|---|---|
| Import | from fastapi import FastAPI |
from justapi import JustAPIApp |
| Create app | app = FastAPI() |
app = JustAPIApp() |
| Decorators | @app.get("/items/{id}") |
@app.get("/items/{id}") |
| Pydantic | ✅ Native | ✅ Native |
| Depends() | ✅ Built-in | ✅ Built-in |
| OpenAPI docs | /docs and /redoc |
/docs and /redoc |
| Server | uvicorn (Python) | Built-in Rust server (hyper + tokio) |
| Performance | ~36k req/s | ~700k req/s |
👉 See the full migration guide.
Architecture
justapi/
├── crates/
│ ├── justapi-core/ # 🦀 Networking, routing, middleware, serialization
│ ├── justapi-py/ # 🐍 PyO3 bindings, ASGI shim, native Python API
│ ├── justapi-cli/ # ⚡ CLI binary (serve, gen-client, profile)
│ ├── justapi-bench/ # 📊 Internal benchmark harness
│ └── justapi-inference/ # 🧠 ML inference engine (optional)
├── examples/ # 📖 10 progressive tutorial examples
├── tests/ # 🧪 End-to-end integration tests
├── fuzz/ # 🔒 6 cargo-fuzz security targets
├── docs/ # 📚 MkDocs documentation site
├── deploy/ # ☁️ Multi-cloud deployment guides
├── helm/ # ⎈ Kubernetes Helm chart
├── benchmarks/ # 🏎️ Performance workload scripts
└── website/ # 🌐 Project landing page
Crate dependency graph
justapi-cli ──→ justapi-core
justapi-py ──→ justapi-core
justapi-bench ─→ justapi-core
Development
Prerequisites
- Rust 1.85+ (edition 2021) — install via rustup
- Python 3.11+ — download
- maturin —
pip install maturin
Building
# Build the workspace
cargo build --workspace
# Build in release mode
cargo build --workspace --release
# Build the Python package (dev mode)
cd crates/justapi-py && maturin develop --release
Testing
# Run all Rust tests
cargo test --workspace
# Lint
cargo clippy --workspace --tests -- -D warnings
# Format check
cargo fmt --check
# Memory safety verification (requires nightly)
cargo miri test -p justapi-core
# Python tests
cd crates/justapi-py && python -m pytest
Benchmarking
# Install load generator
cargo install oha
# Run the baselines (FastAPI, Granian, JustAPI)
bash benchmarks/run_baselines.sh
See BENCHMARKS.md for full methodology, hardware specs, and historical results.
Deployment
Docker
docker build -t justapi-app .
docker run -p 8000:8000 justapi-app
Docker Compose
docker-compose up
Kubernetes (Helm)
helm install my-api helm/justapi/ \
--set image.repository=your-registry/justapi-app \
--set image.tag=latest
Cloud platforms
Step-by-step deployment guides are available for:
Documentation
| Document | Description |
|---|---|
| Getting Started | Installation, first app, and core concepts |
| API Reference | Complete API documentation |
| Migrating from FastAPI | Step-by-step migration guide |
| Plugin Guide | Building and distributing plugins |
| Security | OWASP checklist, pentest guide, disclosure policy |
| BENCHMARKS.md | Performance results (append-only ledger) |
| PLAN.md | Living roadmap and current phase |
| ROADMAP.md | Aspirational future work — explicitly not yet built |
| DECISIONS.md | Architecture decision records |
| AGENTS.md | Development rules and conventions |
Contributing
Contributions are welcome! Please read AGENTS.md for development conventions, commit format, and review checklist before submitting a PR.
# Fork and clone
git clone https://github.com/YOUR_USERNAME/JustAPI.git
cd JustAPI
# Create a branch
git checkout -b feat/my-feature
# Make changes, then run the full check suite
cargo test --workspace
cargo clippy --workspace --tests -- -D warnings
cargo fmt --check
# Submit a PR
License
This project is licensed under the terms of the MIT License.