Robyn Extensions
Python ergonomics, Rust execution
Validation, auth, rate limiting and OpenAPI docs for the Robyn web framework.
Kevin Keller · kevinkeller.org
Why it matters
Robyn is fast but intentionally minimal
- A Python web framework with a Rust runtime
- Out of the box: no request validation
- No built-in auth, no rate limiting
- No auto-generated API docs
What you get
Five extensions, all heavy lifting in Rust
| Extension | Performance |
|---|---|
| Pydantic v2-compatible validation | Sub-microsecond per field |
| Token-bucket rate limiting | ~100 ns per check |
| JWT and OAuth2/OIDC auth | ~500 μs with cached JWKS |
OpenAPI docs at /docs and /redoc | Zero runtime overhead |
| REST API generator | Code generation |
The idea
Python writes the decorators. Rust runs the checks.
PyO3 bindings hand validation, token parsing and rate counting to four focused Rust crates.
Validation
The Pydantic patterns you already know
- Field constraints, type coercion and nested models
- Field validators and model validators
- Computed fields
- Every
@body_v2,@queryand@returnsalso registers the API schema
Auth and rate limits
Production basics as decorators
- Providers: Auth0, Google, Okta, Azure AD or any JWKS endpoint
- Key rotation: JWKS refreshed when a
kidis not in cache - Rate limits: per IP by default, per user with auth
- Presets:
strictat 10 per minute,moderateat 60
Robyn or FastAPI?
Pick by what the API needs
| FastAPI | Robyn + Extensions | |
|---|---|---|
| Runtime | Python (Starlette) | Rust (Actix) |
| Validation | Pydantic in Python | Pydantic API, Rust execution |
| Rate limiting | Third-party | Built in |
| Ecosystem | Massive | Growing |
Honest positioning
Not a replacement for every project
For performance-critical APIs where you want Python's ergonomics with Rust's speed, it is a compelling option.
FastAPI's ecosystem is unmatched. The extensions ship with 19 Python tests and 12 Rust tests.
Takeaway
FastAPI's developer experience without giving up Robyn's speed.
Open source: github.com/KellerKev/robyn-extensions