| Crates.io | legalis-api |
| lib.rs | legalis-api |
| version | 0.1.3 |
| created_at | 2026-01-05 08:11:40.93482+00 |
| updated_at | 2026-01-21 04:06:58.004271+00 |
| description | REST/GraphQL API server for Legalis-RS |
| homepage | https://github.com/cool-japan/legalis |
| repository | https://github.com/cool-japan/legalis |
| max_upload_size | |
| id | 2023394 |
| size | 1,467,939 |
REST API server for Legalis-RS.
legalis-api provides a production-ready REST API server built with Axum for managing and evaluating legal statutes programmatically.
| Method | Path | Description |
|---|---|---|
GET |
/api/v1/statutes |
List all statutes |
GET |
/api/v1/statutes/:id |
Get statute by ID |
POST |
/api/v1/statutes |
Create new statute |
PUT |
/api/v1/statutes/:id |
Update statute |
DELETE |
/api/v1/statutes/:id |
Delete statute |
| Method | Path | Description |
|---|---|---|
POST |
/api/v1/verify |
Verify statute(s) |
POST |
/api/v1/verify/:id |
Verify specific statute |
| Method | Path | Description |
|---|---|---|
POST |
/api/v1/evaluate |
Evaluate entity against statutes |
POST |
/api/v1/evaluate/:id |
Evaluate against specific statute |
| Method | Path | Description |
|---|---|---|
GET |
/health |
Health check |
GET |
/ready |
Readiness check |
use legalis_api::{create_router, AppState};
use std::sync::Arc;
#[tokio::main]
async fn main() {
let state = Arc::new(AppState::new());
let app = create_router(state);
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
axum::serve(listener, app).await.unwrap();
}
# Start API server
legalis serve --host 0.0.0.0 --port 3000
# Create a statute
curl -X POST http://localhost:3000/api/v1/statutes \
-H "Content-Type: application/json" \
-d '{"id": "adult-rights", "title": "Adult Rights", ...}'
# Verify all statutes
curl -X POST http://localhost:3000/api/v1/verify
# Evaluate an entity
curl -X POST http://localhost:3000/api/v1/evaluate \
-H "Content-Type: application/json" \
-d '{"entity": {"age": 25, "income": 50000}}'
| Environment Variable | Default | Description |
|---|---|---|
HOST |
127.0.0.1 |
Server bind address |
PORT |
3000 |
Server port |
LOG_LEVEL |
info |
Logging level |
The following features are available:
cargo build
If you don't need the gRPC API and want to reduce dependencies:
[dependencies]
legalis-api = { version = "0.1", default-features = false }
Or build with:
cargo build --no-default-features
[dependencies]
legalis-api = { version = "0.1", default-features = false, features = ["redis-cache", "oauth2-auth"] }
MIT OR Apache-2.0