ProvenPin Install

Stacks

FastAPI recipes

16 tested FastAPI integration recipes with Pydantic, PyJWT, SQLAlchemy, SQLite. Exact pinned versions and a last-passed receipt, last run 2026-10-15.

passed4/4python

FastAPI + Pydantic v2 validators, discriminated unions and serializers

Pydantic v2 patterns in FastAPI that agents often get wrong: field_validator, model_validator, discriminated unions, computed_field and response_model filtering.

fastapi@0.143.1pydantic@2.14.1httpx@0.28.1
last passed 2026-10-15 13:29 UTC
passed2/2python

FastAPI + PyJWT bearer auth

OAuth2 password flow in FastAPI issuing PyJWT tokens, with a current-user dependency guarding routes.

fastapi@0.143.1pyjwt@2.15.1httpx@0.28.1
last passed 2026-10-15 13:29 UTC
passed2/2python

FastAPI + SQLAlchemy 2 CRUD with dependency-injected sessions

FastAPI routes backed by SQLAlchemy 2.x typed models, a per-request session dependency, and TestClient tests on SQLite.

fastapi@0.143.1sqlalchemy@2.1.4httpx@0.28.1
last passed 2026-10-15 13:29 UTC
passed3/3python

FastAPI + Stripe webhook signature verification

Verify Stripe webhook signatures in FastAPI from the raw request body and dispatch on event type. Tested offline with locally signed payloads.

fastapi@0.143.1stripe@16.0.0httpx@0.28.1
last passed 2026-10-15 13:29 UTC
passed1/1python

FastAPI background tasks + dependency overrides

FastAPI BackgroundTasks for post-response work, with dependency_overrides to swap services in tests.

fastapi@0.143.1httpx@0.28.1pydantic@2.14.1
last passed 2026-10-15 13:29 UTC
passed5/5python

FastAPI config via pydantic-settings as a cached dependency

Load config from env vars with pydantic-settings, inject it into FastAPI routes through a cached dependency, and test it offline with monkeypatch and dependency_overrides.

fastapi@0.143.1pydantic-settings@2.16.0httpx@0.28.1
last passed 2026-10-15 13:29 UTC
passed5/5python

FastAPI endpoint with Pydantic v2 discriminated unions and Annotated validators

Accept a tagged union of payment methods with Field(discriminator), add Annotated validators, and test the exact 422 error shapes offline with TestClient.

fastapi@0.143.1pydantic@2.14.1httpx@0.28.1
last passed 2026-10-15 13:32 UTC
passed5/5python

FastAPI endpoints rate limited with slowapi, tested with TestClient

Add per-route and per-API-key rate limits to FastAPI with slowapi, then test 429 behavior offline with TestClient and the in-memory store.

fastapi@0.143.1slowapi@0.1.10httpx@0.28.1
last passed 2026-10-15 13:29 UTC
passed6/6python

FastAPI Jinja2 full pages vs HTMX partials via HX-Request

Serve a full HTML page to normal browsers and a bare HTML fragment to HTMX requests, chosen by the HX-Request header, with Vary set for caches. Tested offline with the sync TestClient.

fastapi@0.143.1jinja2@3.1.6httpx@0.28.1
last passed 2026-10-15 13:29 UTC
passed6/6python

FastAPI lifespan state tested with httpx ASGITransport and asgi-lifespan

A FastAPI app that opens a SQLite connection in its lifespan, then test it offline through httpx ASGITransport, with asgi-lifespan running startup and shutdown.

fastapi@0.143.1httpx@0.28.1asgi-lifespan@2.1.0
last passed 2026-10-15 13:29 UTC
passed6/6python

FastAPI login with argon2-cffi hashing and rehash checks

A form-based FastAPI login that verifies argon2id hashes without leaking which users exist, and transparently upgrades outdated hashes on successful login, tested offline with TestClient and an in-memory store.

fastapi@0.143.1argon2-cffi@25.1.0httpx@0.28.1
last passed 2026-10-15 13:29 UTC
passed5/5python

FastAPI OAuth2 password flow with PyJWT tokens and scope checks

OAuth2 password login issuing PyJWT access tokens, Argon2 hashes via pwdlib, and per-route scope checks with SecurityScopes, tested offline with TestClient.

fastapi@0.143.1pyjwt@2.15.1pwdlib@0.3.1
last passed 2026-10-15 13:29 UTC
passed5/5python

FastAPI request ids in structlog contextvars, tested with capture_logs

Pure ASGI middleware binds a request id into structlog contextvars, echoes it in an X-Request-ID header, and is tested offline with TestClient and structlog.testing.capture_logs.

fastapi@0.143.1structlog@26.1.0httpx@0.28.1
last passed 2026-10-15 13:34 UTC
passed2/2python

FastAPI WebSockets with token auth and broadcast, tested with TestClient

FastAPI WebSocket endpoint that authenticates via query token, rejects with a close code and broadcasts to connected clients; tested with TestClient.websocket_connect.

fastapi@0.143.1httpx@0.28.1pytest@9.1.1
last passed 2026-10-15 13:29 UTC
passed4/4python

FastAPI with async SQLAlchemy 2 on aiosqlite, tested offline with per-test in-memory DBs

A FastAPI app using AsyncSession and async_sessionmaker on aiosqlite, tested with httpx.AsyncClient over ASGITransport, overriding the session dependency with a fresh in-memory database for each test.

fastapi@0.143.1sqlalchemy@2.1.4aiosqlite@0.22.1
last passed 2026-10-15 13:29 UTC
passed2/2python

SQLModel + FastAPI CRUD with in-memory SQLite

Full CRUD API with SQLModel table models, separate create/update schemas and a session dependency overridden for tests.

sqlmodel@0.0.48fastapi@0.143.1httpx@0.28.1
last passed 2026-10-15 13:33 UTC

Used together with FastAPI

PydanticPyJWTSQLAlchemySQLiteStripePydantic Settingshttpxslowapijinja2asgi-lifespanargon2-cffipython-multipartpwdlibstructlogstarletteaiosqlitepytest-asyncioSQLModel