Ushka

API reference

Generated from the docstrings. Every module has an index of its classes and functions at the top.

Core

The application object, routing, configuration and error handling.

ushka.core.appThis module defines the core Ushka application class, which serves as the central entry point for handling ASGI requests, managing…
ushka.core.routerThis module defines the Router class, which acts as the central route manager for the Ushka framework.
ushka.core.configApplication configuration: defaults < ushka.toml < .env < environment.
ushka.core.error_handlerThis module provides centralized exception handling for the Ushka framework.
ushka.core.settingsEvery setting Ushka reads, in one place: its default and what it does.
ushka.core.serverThe production server: Uvicorn with an idle loop that does not burn CPU.
ushka.core.logTerminal output for Ushka: coloured, compact, standard-library only.

HTTP

Requests, responses, typed parameters, validation, sessions, streaming and WebSockets.

ushka.http.requestThis module defines the Request class for handling incoming HTTP requests.
ushka.http.responseThis module defines the Response class for handling HTTP responses.
ushka.http.paramsDeclared handler parameters: typed path/query/header/cookie/body and Depends.
ushka.http.validationType-driven validation of request data, with no dependencies.
ushka.http.cookiesThis module provides a full-stack cookie management utility, the Cookies class.
ushka.http.redirectThis module provides a helper function for generating HTTP redirection responses.
ushka.http.streamStreaming responses and Server-Sent Events (SSE).
ushka.http.websocketWebSockets. A handler named websocket in routes/, or @app.websocket::
ushka.http.multipartThis module provides utilities for parsing multipart/form-data requests, commonly used for file uploads in web applications.
ushka.http.errorThis module provides a convenient helper function for raising HTTP errors within the Ushka framework.
ushka.http.exceptionsThis module defines custom HTTP exception classes for the Ushka framework.

Sessions

The signed-cookie session and revocable server-side sessions.

ushka.sessions.sessionThis module provides the Session class, a secure client-side session manager for the Ushka framework.
ushka.sessions.storesWhere server-side sessions live.
ushka.sessions.forgeForging a session for tests: the supported way to be "logged in" without a login.

Security

The security middleware that is on by default: CSRF, headers, CORS and trusted hosts.

ushka.security.middlewareSecurity middleware, on by default.
ushka.security.verifyushka verify: attack your own app and report what got through.

Encryption

Fernet encrypt and decrypt with key rotation (needs ushka[crypto]).

ushka.crypto.fernetFernet encryption: encrypt, decrypt, generate_key and key rotation.

Sign in (OAuth)

Login with Google and GitHub: the helpers for your routes and the providers.

ushka.authLogin with OAuth 2.0 / OpenID Connect: Google and GitHub, no extra dependency.
ushka.auth.providersOAuth 2.0 / OpenID Connect providers: Google and GitHub, on the standard library.
ushka.auth.flowThe built-in login routes: /auth/<provider>/login and /auth/<provider>/callback.

Guard

Ushka Guard: taint tracking for untrusted input, checked sinks and the safe helpers.

ushka.guard.untrustedThe Untrusted string type and its propagation rules.
ushka.guard.safeExplicit sanitisers: the only sanctioned way to turn Untrusted into trusted.
ushka.guard.sinksChecks run by dangerous sinks before they use a value.
ushka.guard.templatesSafe-by-construction HTML and SQL from t-strings (PEP 750, Python 3.14+).
ushka.guard.rewriteCompile-time rewriting that keeps the Untrusted mark where CPython drops it.
ushka.guard.errorsThe error raised when an untrusted value reaches a dangerous sink.

Guard integrations

Ushka Guard for Starlette, FastAPI and Django.

ushka.guard.integrations.starletteUshka Guard for Starlette and FastAPI.
ushka.guard.integrations.fastapiUshka Guard for FastAPI.
ushka.guard.integrations.djangoUshka Guard for Django.

Data, templates and files

The ORM, the Jinja engine, static files and flash messages.

ushka.orm.databaseThis module provides an asynchronous Object-Relational Mapper (ORM) for the Ushka framework, built on top of SQLAlchemy 2.0.
ushka.orm.reflectReads an existing database and writes Ushka models for it.
ushka.templating.engineThis module provides advanced templating functionality using Jinja2.
ushka.static.filesStatic file serving: the [static] directory and any number of mounts.
ushka.templating.flashThis module provides "flash messaging" functionality for the Ushka framework, allowing messages to be stored in the user's session and…

Mail

Reading e-mail over IMAP, with everything from the message marked Untrusted.

ushka.mail.imapImapClient: read the inbox of a mailbox (support, leads, receipts) from an app.

Web: SEO, PWA and i18n

What browsers and search engines see.

ushka.web.seoSEO that ships ready: meta tags for your templates, robots.txt and sitemap.xml.
ushka.web.pwaProgressive Web App support, configured in [pwa] of ushka.toml.
ushka.web.i18nInternationalisation: translations from standard gettext catalogs, no extra packages.
ushka.web.i18n.toolsTools behind ushka i18n: find messages, write a .pot, compile .po to .mo.

Agents and tooling

Routes as MCP tools, OpenAPI from signatures, and `ushka verify`.

ushka.api.openapiOpenAPI 3.1 description of your app, generated from the handler signatures.
ushka.api.mcpRoutes as agent tools, over MCP (Model Context Protocol).
ushka.testingA test client for Ushka apps, on the standard library only.

CLI commands

The commands behind the `ushka` program.

ushka.cli.commands.newushka new: scaffolds a project that is secure and runnable from the start.
ushka.cli.commands.devushka dev: development server with reload and debug on.
ushka.cli.commands.runushka run (production) and the server logic shared with ushka dev.
ushka.cli.commands.routesushka routes: list, add, remove and move filesystem routes.
ushka.cli.commands.checkushka check: validates configuration and security settings.
ushka.cli.commands.dbThis module provides the Command Line Interface (CLI) commands for database migration management using Alembic.