DocumentationBuild your first LenAPI app
API referenceGitHub

Build your first LenAPI app

Install the framework, generate an app, and run a typed API locally.

Work through each step in order. The examples use the generated LenAPI project structure and are designed to be adapted to your app.

01

Install LenAPI

Install from PyPI with pip, or use uv. In a uv-managed project, uv add records LenAPI in pyproject.toml and syncs the environment; uv pip install installs it into the active environment.

Python
# pip
python -m pip install lenapi

# Add LenAPI to a uv-managed project
uv add lenapi

# Or install into the active environment with uv
uv pip install lenapi
02

Generate the application scaffold

The scaffold separates application code from framework internals. It includes settings, a main module, app models and schemas, tests, and migrations.

Python
lenora startproject myproject
cd myproject
03

Add a typed route

LenAPI reads the Pydantic model from the handler signature, validates the incoming JSON body, and documents the operation in OpenAPI.

Python
from pydantic import BaseModel
from lenapi import LENAPI, Router

app = LENAPI()
api = Router(prefix="/api")

class Greeting(BaseModel):
    name: str

@api.post("/hello")
async def hello(data: Greeting):
    return {"message": f"Hello, {data.name}!"}

app.include_router(api)
04

Migrate, then run

Migrations are explicit. The first migration includes framework-owned tables and discovers models imported by the application.

Python
python lenora.py migration
python lenora.py run
TIP

The default development address is http://127.0.0.1:8009. Open /docs/ to try the endpoint in Swagger UI.