Registry / web-framework / fastapi-utilities

fastapi-utilities

JSON →
library0.3.1pypypi✓ verified 86d ago

A collection of reusable utilities for FastAPI including repeat, repeat_every, on_startup, and task decorators. Version 0.3.1 (requires Python >=3.7, <4.0). Release cadence is irregular.

pip install fastapi-utilities
INSTALL
IMPORT
SIG · FASTAPI-UTILITIES
F
fastapi-utilities
web-frameworkpythonv0.3.1
Install
5.6s avg
Import
1876ms
Disk
56MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.3.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 1.972s · 58MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 5.6s · import 1.780s · 55MB
56MB installed
● package 56MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

repeat_every
from fastapi_utilities import repeat_every
from fastapi_utilities.repeat import repeat_every
repeat_every is exposed at package level; do not use submodule path.
repeat_at
from fastapi_utilities import repeat_at
Added in 0.2.0.
on_startup
from fastapi_utilities import on_startup
Simple decorator; do not use app.add_event_handler with this.

Minimal example: on_startup and repeat_every decorator.

from fastapi import FastAPI from fastapi_utilities import repeat_every, on_startup app = FastAPI() @on_startup async def startup(): print("App started") @app.on_event("startup") @repeat_every(seconds=30) async def periodic_task(): print("Task executed")
Debug
Known issues
gotchaThe decorator order matters when combining @app.on_event('startup') with @repeat_every: @app.on_event must be the outermost decorator.
fix
Apply @app.on_event on top, then @repeat_every.
affects: >=0.1.0
deprecatedThe `repeat` decorator (without _every) is deprecated and may be removed in future versions.
fix
Use `repeat_every` or `repeat_at` instead.
affects: >=0.2.0
gotchaTask functions must be async; the decorator does not support synchronous functions.
fix
Define the task with `async def`.
affects: >=0.1.0
breakingIn version 0.2.0, the package name was changed from `fastapi-utils` to `fastapi-utilities`. Install with the new name.
fix
Use `pip install fastapi-utilities`.
affects: >=0.2.0
Errors
Common errors & fixes
AttributeError: module 'fastapi_utilities' has no attribute 'repeat_every'
Old import path used, or package not installed correctly.
fix
Run `pip install --upgrade fastapi-utilities` and use `from fastapi_utilities import repeat_every`.
ImportError: cannot import name 'repeat_on_startup' from 'fastapi_utilities'
Incorrect function name (does not exist).
fix
Use `from fastapi_utilities import on_startup`.
TypeError: 'NoneType' object is not callable
Decorator order reversed: `@repeat_every` placed above `@app.on_event`.
fix
Ensure `@app.on_event('startup')` is the outermost decorator.
Upgrade
Version history
0.3.1latest on PyPI · released Mar 25, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
fastapi-utilities — pip install fastapi-utilities · libregistry