Introduction to LenAPI
A lightweight ASGI framework that helps developers spin up APIs quickly in a few steps.
Start with the shape of your idea.
Follow a guide, copy a working example, and build up one part of your backend at a time.
Explore routingfrom lenapi import LENAPI
app = LENAPI()
@app.get("/hello")
def hello():
return {"message": "Hello, world!"}Understand what LenAPI includes, then follow the quickstart and focused guides to build your application step by step.
What is LenAPI?
LenAPI is a lightweight Python ASGI framework shaped by real-world backend development. It helps developers spin up APIs quickly in a few steps, with routing, validation, data access, and interactive documentation in one toolkit.
What can you build with it?
Key features include:
- Typed routes, Pydantic validation, and interactive Swagger/OpenAPI docs
- ORM models, migrations, and sync or async database access
- Authentication options including JWT, API keys, sessions, OIDC, and social sign-in
- WebSockets for chat, video signaling, JSON, text, and binary messages
- Built-in webhook handling for flexible JSON payloads and verified senders
- Public and private file uploads, middleware, optional gzip, and request throttling
- Sync/async cache operations and durable background queues with retry and delay options
- An optional model admin console with per-model permissions and resource monitoring
- Independent projects that can run separately or mount under a chosen URL prefix
- Optional OpenAI, Ollama, and Faker integrations
Which databases can you use?
LenAPI's supported SQL databases are SQLite (the default), MySQL, and PostgreSQL. MongoDB is the non-relational option and is currently in beta: its separate MongoDocument API is available for developers who want to try it and share feedback. MongoDB does not yet have the same relationship and migration workflow as the SQL backends, so review its guide and limitations before choosing it for production.
- SQL: SQLite, MySQL, and PostgreSQL use LenAPI's SQL model and migration workflow.
- Non-relational beta: MongoDB uses MongoDocument for document-based sync and async CRUD and is open for testing.
Changing DATABASE_TYPE selects the backend; it does not convert existing SQL models, tables, or data. See the MongoDB guide for setup, model differences, and migration limitations.
How this documentation is organized
Start with the quickstart to install LenAPI and create your first app. Then follow the guides for routing, validation, data access, security, realtime features, testing, and deployment. Each guide includes practical code you can adapt.
from lenapi import LENAPI
app = LENAPI()
@app.get("/health")
def health():
return {"status": "ok"}The generated development server defaults to http://127.0.0.1:8009, and Swagger UI is available at /docs/.