DocumentationIntroduction to LenAPI
API referenceGitHub

Introduction to LenAPI

A lightweight ASGI framework that helps developers spin up APIs quickly in a few steps.

YOUR API, WITHOUT THE BUSYWORK

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 routing
main.py
from lenapi import LENAPI

app = LENAPI()

@app.get("/hello")
def hello():
return {"message": "Hello, world!"}
Ready to run python lenora.py run
19step-by-step guides
Sync + asyncroutes and database access
One toolkitAPI, data, security, realtime

Understand what LenAPI includes, then follow the quickstart and focused guides to build your application step by step.

01

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.

02

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
  • Caching, background tasks, file uploads, middleware, and request throttling
  • Optional OpenAI, Ollama, and Faker integrations
03

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.

Python
from lenapi import LENAPI

app = LENAPI()

@app.get("/health")
def health():
    return {"status": "ok"}
TIP

The generated development server defaults to http://127.0.0.1:8009, and Swagger UI is available at /docs/.

Explore every feature

20 guides
01Build your first LenAPI appInstall the framework, generate an app, and run a typed API locally.02Routes and routersOrganize endpoints with app decorators, reusable routers, prefixes, tags, and all common HTTP verbs.03Request and response schemasValidate request bodies with Pydantic and describe response shapes in Swagger.04Image upload and media servingAccept multipart uploads, save public or private files, and serve private files only through authorized routes.05Models and fieldsDeclare SQLAlchemy-backed tables with model.Model and typed fields, then evolve them through migrations.06Migrations and database setupChoose one database backend, detect model changes, and safely apply migration revisions.07CRUD, search, and paginationCreate records, perform unique lookups, filter and search collections, aggregate values, and paginate results.08Async endpoints and database accessUse async handlers and SQLAlchemy AsyncSession with the same configured database URL.09Authentication patternsChoose JWT, API-key, or Basic authentication, then protect the whole app, a router, or an individual endpoint.10Social sign-in with OAuth and OIDCGenerate explicit login and callback routes for Google, GitHub, and LinkedIn.11Middleware, throttling, and docs protectionAdd security and observability middleware, rate limits, IP cooldowns, CSRF checks, and private Swagger docs.12Dependencies and shared logicReuse route logic for authentication, database access, and request-scoped services.13WebSockets: chat, video signaling, JSON, text, and bytesMount a ready-made WebSocket service or handle low-level ASGI WebSocket connections directly.14Cache dataStore JSON-compatible values with expiration in process memory, the configured database, or Redis.15Webhooks: receiving and sending eventsBuild webhook endpoints, choose provider signature verification, handle unsigned senders safely, and process retries without duplicate work.16Background tasks and durable queuesRun small post-response tasks or persist jobs for a separate worker process.17OpenAI, Ollama, and Faker servicesCall OpenAI or local Ollama models asynchronously and generate deterministic fake data for development.18Automated testingRun the framework test suite or generate application endpoint checks and CSV reports.19Configuration and deploymentConfigure the server, database, secrets, proxy boundary, and production process.