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

ExtensionPerformance
Pydantic v2-compatible validationSub-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 /redocZero runtime overhead
REST API generatorCode 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, @query and @returns also 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 kid is not in cache
  • Rate limits: per IP by default, per user with auth
  • Presets: strict at 10 per minute, moderate at 60

Robyn or FastAPI?

Pick by what the API needs

FastAPIRobyn + Extensions
RuntimePython (Starlette)Rust (Actix)
ValidationPydantic in PythonPydantic API, Rust execution
Rate limitingThird-partyBuilt in
EcosystemMassiveGrowing

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.

Read the full article

Open source: github.com/KellerKev/robyn-extensions