# RustAPI
**High-performance APIs in Rust — define handlers, get OpenAPI, deploy to HTTPS in minutes.**
Native AI/LLM support · compile-time routes · `cargo rustapi` CLI
Website ·
Golden Path ·
Cookbook ·
Production Checklist ·
Deploy to Cloud ·
crates.io
Write a 5-line handler → auto OpenAPI → cargo rustapi deploy cloud → live on *.rustapi.cloud
[](https://crates.io/crates/rustapi-rs)
[](docs/cookbook/src/SUMMARY.md)
[](LICENSE)
[](Cargo.toml)
[](https://github.com/Tuntii/RustAPI/actions/workflows/audit.yml)
[](https://github.com/Tuntii/RustAPI/actions/workflows/ci.yml)
[](https://deepwiki.com/Tuntii/RustAPI)
---
## Golden Path (start here)
**Handler → OpenAPI (`/docs`) → production probes → (optional) MCP / deploy.**
```bash
cargo run -p rustapi-rs --example golden_path
# curl http://127.0.0.1:8080/api/v1/ping
# open http://127.0.0.1:8080/docs
```
Full walkthrough: **[docs/GOLDEN_PATH.md](docs/GOLDEN_PATH.md)** · example: [`golden_path.rs`](crates/rustapi-rs/examples/golden_path.rs)
Everything else (JWT, jobs, WS, full extras) branches off this path.
---
## Overview
RustAPI is a Rust web framework built on **hyper 1.x** and **tokio**, designed for minimal boilerplate while retaining full control over performance. It uses a **facade architecture** (`rustapi-rs`) that shields user code from internal crate changes, keeping the public API stable as internals evolve.
Key design goals:
- **Ergonomic handler signatures** inspired by FastAPI and Axum
- **Native TOON format** for token-efficient LLM responses
- **Auto-discovery** of routes via procedural macros and link-time registration
- **Three-tier request execution** (ultra fast / fast / full) to minimize overhead
## What Sets RustAPI Apart
### Three-Tier Request Execution
Unlike other Rust frameworks that always run the full middleware chain, RustAPI dynamically selects the cheapest execution path per request:
| Path | When | Overhead |
|:-----|:-----|:---------|
| **Ultra Fast** | No middleware, no interceptors | Zero Arc cloning, direct handler call |
| **Fast** | Interceptors only, no middleware layers | Interceptor functions only |
| **Full** | Middleware layers present | Complete `LayerStack` execution |
This means a simple `GET /health` endpoint with no middleware runs at near-zero overhead, while other endpoints on the same server can use JWT, CORS, and rate limiting through the full path.
### Facade Architecture with Contract Enforcement
User code imports only from `rustapi-rs`. Internal crates (`rustapi-core`, `rustapi-macros`, etc.) can be refactored freely without breaking user code. The public API surface is tracked via committed `cargo public-api` snapshots, and CI enforces labeling rules (`breaking` / `feature`) on any PR that changes them.
### Link-Time Auto-Discovery
Routes annotated with `#[rustapi_rs::get("/...")]` are registered to a `linkme` distributed slice at link time — no manual route registration or inventory macros needed. `RustApi::auto()` collects them and builds a `BTreeMap`-ordered radix tree router via `matchit`.
### TOON: Token-Oriented Object Notation
A compact serialization format that reduces token counts by **50-58%** compared to JSON. `Toon