34 releases
| new 0.1.443 | Mar 18, 2026 |
|---|---|
| 0.1.417 | Mar 10, 2026 |
| 0.1.397 | Feb 26, 2026 |
| 0.1.233 | Jan 30, 2026 |
| 0.1.2 | Dec 31, 2025 |
#867 in HTTP server
1.5MB
27K
SLoC
π Vision
RustAPI brings the developer experience (DX) of modern frameworks like FastAPI to the Rust ecosystem.
We believe that writing high-performance, type-safe web APIs in Rust shouldn't require fighting with complex trait bounds or massive boilerplate. RustAPI provides a polished, battery-included experience where:
- API Design is First-Class: Define your schema, and let the framework handle Validation and OpenAPI documentation automatically.
- The Engine is Abstracted: We rely on industry standards like
tokio,hyper, andmatchitinternally, but we expose a stable, user-centric API. - Zero Boilerplate: Extractors and macros do the heavy lifting.
β¨ Features
- β‘ Fast & Async: Built on top of
tokioandhyper1.0. - π‘οΈ Type-Safe: Request/Response bodies are strictly typed using generic extractors (
Json,Query,Path). - π Auto-Docs: Generates OpenAPI 3.0 specifications and serves Swagger UI automatically.
- β
Validation: Declarative validation using
#[derive(Validate)]. - π Batteries Included:
- Authentication: JWT support.
- Database: SQLx integration.
- WebSockets: Real-time communication.
- Templating: Tera view engine.
- Jobs: Background task processing (Redis/Postgres).
Feature taxonomy on the facade:
core-*: core runtime and HTTP behavior (core-openapi,core-tracing, etc.)protocol-*: optional protocol crates (protocol-toon,protocol-ws,protocol-view,protocol-grpc)extras-*: optional production middleware/integrations (extras-jwt,extras-cors, etc.)
π¦ Quick Start
Add rustapi-rs to your Cargo.toml.
[dependencies]
rustapi-rs = { version = "0.1", features = ["full"] }
The "Hello World"
use rustapi_rs::prelude::*;
/// Define your response schema
#[derive(Serialize, Schema)]
struct HelloResponse {
message: String,
}
/// Define an endpoint
#[rustapi_rs::get("/")]
#[rustapi_rs::tag("General")]
#[rustapi_rs::summary("Hello World Endpoint")]
async fn hello() -> Json<HelloResponse> {
Json(HelloResponse {
message: "Hello from RustAPI!".to_string(),
})
}
/// Run the server
#[rustapi_rs::main]
async fn main() -> Result<()> {
RustApi::new()
.api_name("My Awesome API")
.api_version("1.0.0")
.mount_route(hello_route()) // Auto-generated route handler
.docs("/docs") // Enable Swagger UI
.run("127.0.0.1:8080")
.await
}
Visit http://127.0.0.1:8080/docs to see your interactive API documentation!
πΊοΈ Architecture
RustAPI follows a Facade Architecture:
rustapi-rs: The public-facing entry point. Always import from here.rustapi-core: The internal engine (Hyper/Tower).rustapi-macros: Procedural macros (#[get],#[main]).cargo-rustapi: The CLI tool for scaffolding projects.
π€ Contributing
We welcome contributions! Please see CONTRIBUTING.md for details.
π License
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Dependencies
~22β45MB
~710K SLoC