py-cheema-api
py-cheema-api is a small, fast ASGI web framework built from scratch (stdlib-only) with a focus on predictable performance.
Features
- Trie router with
{param}path params APIRoutercomposition with prefixes/tags viainclude_router()- Compiled route plans (signature inspection happens at route registration, not per request)
- Dependency injection with
Depends()including nested and yield-based dependencies - Parameter source markers:
Query,Header,Cookie,Form,File - Built-in validation with
Model+field()(supportsAnnotated,Literal,Enum,datetime,UUID,Decimal) - Optional Pydantic v2 compatibility (request/response models + OpenAPI schema integration when installed)
- Multipart/form-data parsing with
UploadFile - Multipart hardening: per-file/part/field limits + upload spooling to disk
StreamingResponse,FileResponse,BackgroundTask, and static file mounting- Response primitives:
RedirectResponse,NegotiatedResponse, cache header helpers, andEventSourceResponsefor SSE - File hardening:
ETag/If-None-Match+ byte range (206/416) support - WebSocket route support via
@app.websocket(...) - Sub-app mounting via
app.mount("/prefix", sub_app)and host routing viaapp.mount_host("*.example.com", app) - WebSocket auth helpers (
websocket_token_auth,websocket_jwt_auth) and OpenAPI WS extension docs (x-cheema-websockets) - Security primitives:
api_key_auth(),bearer_auth(),jwt_auth(), OAuth2 password/auth-code/client-credentials helpers with OpenAPI security schemas - Session + CSRF protection primitives (
SessionMiddleware,CSRFMiddleware, CSRF helpers) - Testing utilities: sync
TestClientand asyncAsyncTestClientwith WebSocket test sessions - OpenAPI at
/openapi.json - Swagger UI at
/docsand ReDoc at/redoc - Lifespan startup/shutdown handlers
- Lifespan state resources with cleanup guarantees (
app.add_state_resource(...)) - App-state dependency helpers (
app.state_dependency(...),app_state_dependency(...),get_app_state(...)) - Custom exception handlers with
@app.exception_handler(...) - Reliability defaults: request timeout, max body size, max concurrency
- Runtime settings model (
CheemaSettings) +Cheema.from_env()for env-driven deploy config - Graceful shutdown request draining (
shutdown_drain_timeout) - Background job primitives:
InMemoryJobQueuewith retries, delay/schedule, and idempotency keys - Queue adapters:
CeleryQueueAdapter,RQQueueAdapter,RedisQueueAdapter - CI release gates: Python matrix tests/lint + package build and
twine check, with trusted publishing workflow - Benchmark suite + perf regression gates in CI (
benchmarks/bench_runtime.py) HTTPException(alias forHTTPError) and apy_cheema_apiimport alias for FastAPI-style migrationsdefault=onQuery/Header/Cookie/Form/File/Host/Bodyfor FastAPI-style optional params (e.g.Query(default=10))- Native
Model/field()validated data supports bothitem["field"]anditem.fieldaccess TestClient/AsyncTestClientacceptjson=and query strings embedded in the path, matching FastAPI'sTestClient- Pluggable
MemoryCacheprimitive, shareable betweenResponseCacheMiddlewareand your own route handlers - Built-in ops status endpoint via
app.add_status_route()(route table, middleware stack, uptime, inflight requests, optional auth gate and customextrapayload) response_class=on route decorators (@app.get(..., response_class=HTMLResponse)), matching FastAPI's pattern for wrapping plain return values- SPA fallback routing on
mount_static(..., spa_fallback=True), servingindex.htmlfor extensionless client-side routes while still 404ing missing real assets
What's New
v1.0.1
FastAPI migration parity fixes — see MIGRATION.md for the full guide:
HTTPExceptionalias forHTTPErrordefault=support on all parameter markers (Query,Header,Cookie,Form,File,Host,Body)- Pydantic
BaseModelresponses now serialize cleanly instead of being wrapped in an envelope - Native
Modelvalidated data supports attribute access (item.name) alongside existing dict access (item["name"]) TestClient/AsyncTestClientacceptjson=and parse query strings embedded directly in the pathpy_cheema_apiimport alias, matching the PyPI distribution name
New primitives:
MemoryCache: a pluggable in-process cache with per-entry TTL, usable directly by app code and shareable withResponseCacheMiddleware(cache=...)so both can read/write the same storeapp.add_status_route(): a built-in ops status endpoint reporting the route table, middleware stack, app title/version, uptime, and inflight-request count, with an optionalauthgate and anextrahook for custom stats (e.g. queue depth, connection counts)response_class=onroute()/get()/post()/etc. (bothCheemaandAPIRouter): wraps a plain return value in the givenResponsesubclass, e.g.@app.get("/page", response_class=HTMLResponse)returning a bare string. An explicitResponsereturn still takes precedence.mount_static(prefix, directory, spa_fallback=True, index_file="index.html"): serves the mount'sindex.htmlfor any unmatched path with no file extension (client-side routes), so a React/Vue/Angular build's own router can take over on refresh/direct navigation, while a genuinely missing asset (has a file extension, e.g./assets/app.js) still 404s correctly. Off by default; existingmount_static()calls are unaffected.
v1.0.0
Initial stable release under the py-cheema-api name (renamed from TurboAPI/py-turbo-api).
Stability
- Compatibility policy:
API_COMPATIBILITY.md - Current status: v1.0.1
Install
From PyPI
pip install py-cheema-api
Optional: Pydantic v2 compatibility
pip install "py-cheema-api[pydantic]"
PyPI: https://pypi.org/project/py-cheema-api/
Run example
uvicorn app:app --reload
Open:
Documentation Tracks
- Docs home (GitHub Pages entry):
docs/index.md - Complete API reference:
docs/api-reference.md - Tutorial:
docs/tutorial.md - Advanced:
docs/advanced.md - Deployment:
docs/deployment.md - Security recipes:
docs/security-recipes.md - Why py-cheema-api + benchmark method:
docs/why-py-cheema-api.md - Migrating from FastAPI:
MIGRATION.md - Benchmark methodology:
BENCHMARKS.md
Benchmarks
python benchmarks/bench_runtime.py --baseline benchmarks/baseline.json --tolerance 1.20 --gate
License
Apache-2.0 (see LICENSE).
Metadata
Release files for py-cheema-api 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| py_cheema_api-1.0.1.tar.gz | 96.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| py_cheema_api-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 173.9 kB
Release files / py_cheema_api-1.0.1.tar.gz
| Download URL | py_cheema_api-1.0.1.tar.gz |
|---|---|
| Size | 96.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a6750f0a4b3821ff76eec0d2298c3432b418980314cff827475ca6dd137fc6f7
|
|
BLAKE2b-256 checksum How to use checksums |
30f51ba53ad2c4fc33e8e4e59381f73db38d46ed9a16f2813fd4ceb9a47c58f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 26, 2026.
Transparency logRelease files / py_cheema_api-1.0.1-py3-none-any.whl
| Download URL | py_cheema_api-1.0.1-py3-none-any.whl |
|---|---|
| Size | 77.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
23c22618833d816f997b79232948b6e14e754debd5858ec7b1119007e17a4f67
|
|
BLAKE2b-256 checksum How to use checksums |
da414349782dc0eb216535958cf93817c09112064245f77f44c6167f4df4f136
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 26, 2026.
Transparency log