fastapi-utilities
Reusable utilities for FastAPI
What it is and what it does
fastapi-utilities is a collection of helper functions and decorators for FastAPI applications. It reduces boilerplate by providing task scheduling (via repeat_every and repeat_at decorators), a TTL-aware LRU cache decorator, middleware for logging request timing, and a session manager that wraps SQLAlchemy. The package also includes a CLI tool to scaffold new FastAPI projects.
The package depends on click-spinner, croniter, fastapi, pydantic, and sqlalchemy. It is classified as Alpha and has not been actively maintained for over a year, so some features may not align with the latest FastAPI API changes—the description includes guidance on adapting to newer lifespan patterns. It is suitable for developers seeking quick utilities to avoid writing common patterns, but should be evaluated against current FastAPI best practices before adoption in production.
Use it for:
- Schedule periodic background tasks (e.g., cleanup, health checks) using @repeat_every or @repeat_at cron decorators within FastAPI startup.
- Add automatic request timing and performance logging to all endpoints via add_timer_middleware.
- Cache expensive function results with automatic expiration using @ttl_lru_cache with configurable TTL and size limits.
- Manage database sessions across requests using FastAPISessionMaker context manager instead of manual get_db patterns.
- Generate a FastAPI project skeleton quickly using the CLI tool to avoid manual boilerplate setup.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides reusable utilities for FastAPI applications including scheduled task decorators, TTL-based LRU caching, request timing middleware, session management, and a CLI tool for project scaffolding.
Yes, with conditions. The package offers genuine utility for FastAPI developers seeking to reduce boilerplate—particularly task scheduling and caching—and carries no security vulnerabilities. However, the aging maintenance status (507 days since last release) and Alpha classification mean you should verify that features work with your FastAPI version and be prepared to adapt or fork if compatibility issues arise. Best suited for projects where you can tolerate limited upstream support or are willing to maintain patches yourself.
Install
fastapi-utilities on PyPI
pip
pip install fastapi-utilitiesuv
uv add fastapi-utilitiespoetry
poetry add fastapi-utilitiesInstalling fastapi-utilities
Before you install
Low friction installation with a pure-Python wheel. Maintenance status is aging—last release was 507 days ago—so expect limited active development and potential compatibility gaps with newer FastAPI versions, though the description notes workarounds for recent FastAPI lifespan changes.
License in practice
MIT license is permissive, allowing use in commercial and private projects with minimal restrictions; attribution is required but no copyleft obligations apply.
Quickstart
pip install fastapi-utilities
from fastapi import FastAPI
from contextlib import asynccontextmanager
from fastapi_utilities import repeat_every
@asynccontextmanager
async def lifespan(app: FastAPI):
yield
app = FastAPI(lifespan=lifespan)
@repeat_every(seconds=2)
async def scheduled_task():
print("task")
Requires Python 3.7+; latest FastAPI versions require using asynccontextmanager lifespan pattern instead of deprecated on_event decorator.
Verify before relying
- Whether repeat_every and repeat_at work reliably with current FastAPI versions beyond the documented workaround.
- Performance characteristics of ttl_lru_cache under high concurrency or with large datasets.
- Whether the CLI tool generates projects compatible with modern FastAPI and dependency versions.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<4.0,>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 5 — click-spinner, croniter, fastapi, pydantic, sqlalchemy |
| Maintenance | aging — 507 days since the last release |
| First released | |
| Downloads | 140,447/month — #11,272 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: fastapi_utilities-0.3.1-py3-none-any.whl
Keywords: fastapi, utilities, utils, fastapi-utilities, python, library, framework, web, api
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
fastapi-utilsProvides reusable utilities and base classes…
permissive · top 5,000 on PyPI
fastapi-restfulProvides utilities and base classes to reduce…
permissive · top 15,000 on PyPI
fastapi-cache2Caches FastAPI endpoint and function results…
permissive · top 5,000 on PyPI
FastAPI-SQLAlchemyProvides middleware and helpers to integrate…
permissive · top 15,000 on PyPI
asyncacheProvides decorator-based caching for async…
permissive · top 5,000 on PyPI
rq-schedulerAdds job scheduling capabilities to RQ (Redis…
permissive · top 15,000 on PyPI
fastapi-lifespan-managerProvides a lifespan manager for FastAPI that…
permissive · top 15,000 on PyPI
essentialsEssentials provides reusable core classes and…
permissive · top 15,000 on PyPI
fastapi-cliFastAPI CLI is a command-line tool that runs…
permissive · top 1,000 on PyPI
nc-py-apiPython client library for interacting with…
permissive · top 5,000 on PyPI