{"id":21328,"library":"fastapi-utilities","title":"FastAPI Utilities","description":"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.","status":"active","version":"0.3.1","language":"python","source_language":"en","source_url":"https://github.com/steve-nz/fastapi-utilities","tags":["fastapi","utilities","scheduling","background-tasks"],"install":[{"cmd":"pip install fastapi-utilities","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"note":"repeat_every is exposed at package level; do not use submodule path.","wrong":"from fastapi_utilities.repeat import repeat_every","symbol":"repeat_every","correct":"from fastapi_utilities import repeat_every"},{"note":"Added in 0.2.0.","symbol":"repeat_at","correct":"from fastapi_utilities import repeat_at"},{"note":"Simple decorator; do not use app.add_event_handler with this.","symbol":"on_startup","correct":"from fastapi_utilities import on_startup"}],"quickstart":{"code":"from fastapi import FastAPI\nfrom fastapi_utilities import repeat_every, on_startup\n\napp = FastAPI()\n\n@on_startup\nasync def startup():\n    print(\"App started\")\n\n@app.on_event(\"startup\")\n@repeat_every(seconds=30)\nasync def periodic_task():\n    print(\"Task executed\")","lang":"python","description":"Minimal example: on_startup and repeat_every decorator."},"warnings":[{"fix":"Apply @app.on_event on top, then @repeat_every.","message":"The decorator order matters when combining @app.on_event('startup') with @repeat_every: @app.on_event must be the outermost decorator.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use `repeat_every` or `repeat_at` instead.","message":"The `repeat` decorator (without _every) is deprecated and may be removed in future versions.","severity":"deprecated","affected_versions":">=0.2.0"},{"fix":"Define the task with `async def`.","message":"Task functions must be async; the decorator does not support synchronous functions.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use `pip install fastapi-utilities`.","message":"In version 0.2.0, the package name was changed from `fastapi-utils` to `fastapi-utilities`. Install with the new name.","severity":"breaking","affected_versions":">=0.2.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run `pip install --upgrade fastapi-utilities` and use `from fastapi_utilities import repeat_every`.","cause":"Old import path used, or package not installed correctly.","error":"AttributeError: module 'fastapi_utilities' has no attribute 'repeat_every'"},{"fix":"Use `from fastapi_utilities import on_startup`.","cause":"Incorrect function name (does not exist).","error":"ImportError: cannot import name 'repeat_on_startup' from 'fastapi_utilities'"},{"fix":"Ensure `@app.on_event('startup')` is the outermost decorator.","cause":"Decorator order reversed: `@repeat_every` placed above `@app.on_event`.","error":"TypeError: 'NoneType' object is not callable"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}