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 `.pyi` type 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`. ## PerformanceHello-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](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: 1. **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. 2. **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; see [`ROADMAP.md`](ROADMAP.md) for 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). See [`ROADMAP.md`](ROADMAP.md) for the full, explicitly-labeled future list. ## Requirements * **Python 3.11+** * **Rust 1.85+** (only for building from source) ## Installation| 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 |
| 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 |