| Crates.io | rusty-api |
| lib.rs | rusty-api |
| version | 0.2.1 |
| created_at | 2025-04-15 07:26:23.599206+00 |
| updated_at | 2025-06-05 00:20:11.632514+00 |
| description | A secure Rust API crate for rapid development, featuring HTTPS, authentication, privilege levels, and rate limiting. |
| homepage | |
| repository | https://github.com/AlexanderHeffernan/rusty-api |
| max_upload_size | |
| id | 1634078 |
| size | 127,037 |
Rusty API is a secure and lightweight Rust library for building backend APIs. It features HTTPS, password-protected routes, rate limiting, and more, making it ideal for rapid API development.
Add rusty-api to your Cargo.toml:
[dependencies]
rusty-api = "0.2.1"
Here's an example of how to use rusty-api to create an API with public and password-protected routes:
use rusty_api;
async fn password_route(_req: rusty_api::HttpRequest) -> rusty_api::HttpResponse {
rusty_api::HttpResponse::Ok().body("Password route accessed!")
}
async fn open_route(_req: rusty_api::HttpRequest) -> rusty_api::HttpResponse {
rusty_api::HttpResponse::Ok().body("Open route accessed!")
}
fn main() {
let routes = rusty_api::Routes::new()
.add_route_with_password("/password_route", password_route, "Password123")
.add_route("/open_route", open_route);
rusty_api::Api::new()
.certs("certs/cert.pem", "certs/key.pem")
.auth_db("users.db")
.rate_limit(3, 20)
.bind("127.0.0.1", 8443)
.configure_routes(routes)
.configure_cors(|| {
rusty_api::Cors::default()
.allow_any_origin()
.allow_any_method()
.allowed_header("ngrok-skip-browser-warning")
})
.start();
}
To enable HTTPS, generate self-signed certificates:
mkdir -p certs
openssl req -x509 -newkey rsa:4096 -keyout certs/key.pem -out certs/cert.pem
Run your API with:
cargo run
Here are some projects that use rusty-api for their API's. Want to add your project? See Contributing below!
| Project | Description | Links |
|---|---|---|
| ServerWatch | A lightweight system monitoring tool that collects metrics and exposes them via a secure HTTPS endpoint. Built for Raspberry Pi and other Linux systems. | GitHub | Website |
| Your Project Here | Have a project using this package? Submit a PR to add it! | See Contributing below! |
Contributions are welcome! Feel free to open issues or submit pull requests.
This project is licensed under the MIT License.