--- id: fastapi-utilities version: "0.3.1" license: MIT license_treatment: permissive maintenance: aging --- # fastapi-utilities — Reusable utilities for FastAPI License: permissive · Maintenance: aging · Downloads: 140.4K/mo ## 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 above — 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 pip install fastapi-utilities uv add fastapi-utilities poetry add fastapi-utilities ## Installing 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_current - Install friction: low - Maintenance: aging - Downloads: 140.4K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags fastapi scheduling decorators, fastapi cron jobs, fastapi middleware utilities, fastapi session management, fastapi caching ttl lru, fastapi boilerplate tools, fastapi repeated tasks, fastapi-addon, task-scheduling, caching [View on SkillFed](https://skillfed.io/packages/fastapi-utilities) · [View on PyPI](https://pypi.org/project/fastapi-utilities/)