fastapi

Installation
Summary

FastAPI best practices and conventions for clean, modern API development.

  • Use Annotated for all parameter and dependency declarations to maintain type safety, reusability, and compatibility with other contexts
  • Declare return types or response models on path operations to enable automatic validation, filtering, serialization, and OpenAPI documentation
  • Use async def only when calling async code with await; default to regular def for blocking operations to avoid event loop blocking
  • Apply router-level configuration (prefix, tags, dependencies) on the APIRouter itself rather than in include_router() calls
  • Avoid deprecated patterns like Ellipsis (...) for required fields, RootModel, and custom JSON response classes; rely on Pydantic's Rust-based serialization for performance
SKILL.md

FastAPI

Official FastAPI skill to write code with best practices, keeping up to date with new versions and features.

Use the fastapi CLI

Run the development server on localhost with reload:

fastapi dev

Run the production server:

fastapi run
Installs
2.5K
Repository
fastapi/fastapi
GitHub Stars
98.2K
First Seen
Feb 25, 2026