LLM Skills
~/catalog/backend//api-endpoints
BackendGitHub source

FastAPI Endpoint Generator

/api-endpoints

Create fully functional FastAPI endpoints with proper structure, validation, and documentation.

davila7davila7
30.6k
May 22, 2026
MIT License
// skill content

FastAPI Endpoints Generator Create comprehensive FastAPI endpoints with proper structure, validation, and documentation. ## Purpose This command helps you quickly create FastAPI endpoints with Pydantic models, dependency injection, and automaticAPI documentation. ## Usage `` /api-endpoints ## What this command does 1. **Creates API endpoints** with proper HTTP methods 2. **Adds Pydantic models** for request/response validation 3. **Implements dependency injection** for database and auth 4. **Includes error handling** and status codes 5. **Generates automatic documentation** with OpenAPI ## Example Output python # main.py from fastapi import FastAPI, Depends, HTTPException, status from fastapi.middleware.cors import CORSMiddleware from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials from sqlalchemy.orm import Session import uvicorn from app.database import get_db, engine from app.models import models from app.routers import auth, users, posts, comments from app.core.config import settings # Create database tables models.Base.metadata.create_all(bind=engine) # Initialize FastAPI app app = FastAPI( title="Blog API", description="A comprehensive blog API built with FastAPI", version="1.0.0", docs_url="/docs", redoc_url="/redoc" ) # Add CORS middleware app.add_middleware( CORSMiddleware, allow_origins=settings.ALLOWED_HOSTS, allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) # Include routers app.include_router(auth.router, prefix="/auth", tags=["Authentication"]) app.include_router(users.router, prefix="/users", tags=["Users"]) app.include_router(posts.router, prefix="/posts", tags=["Posts"]) app.include_router(comments.router, prefix="/comments", tags=["Comments"]) @app.get("/", tags=["Root"]) async def root(): """API root endpoint.""" return { "message": "Welcome to Blog API", "version": "1.0.0", "docs": "/docs", "redoc": "/redoc" } @app.get("/health", tags=["Health"]) async def health_check(): """Health check endpoint.""" return {"status": "healthy", "timestamp": "2024-01-01T00:00:00Z"} if __name__ == "__main__": uvicorn.run( "main:app", host="0.0.0.0", port=8000, reload=True ) ``python # app/routers/posts.py from typing import List, Optional from fastapi import APIRouter, Depends, HTTPException, status, Query from sqlalchemy.orm import Session from app.database importgetdb from app.schemas importpostschemas from app.services importpostservice from app.core.dependencies importgetcurrentuser ,getcurrentactiveuser from app.models.user import User router = APIRouter() @router .get("/",responsemodel = List[postschemas .PostResponse]) async defgetposts ( skip: int = Query(0, ge=0, description="Number of posts to skip"), limit: int = Query(10, ge=1, le=100, description="Number of posts to return"), search: Optional[str] = Query(None, description="Search in title and content"), category: Optional[str] = Query(None, description="Filter by category"), published: Optional[bool] = Query(True, description="Filter by published status"), db: Session = Depends(getdb ) ): """ Get all posts with pagination and filtering. - skip: Number of posts to skip (for pagination) - limit: Maximum number of posts to return (1:100) - search: Search term for title and content - category: Filter posts by category - published: Filter by published status """ posts =postservice .getposts ( db=db, skip=skip, limit=limit, search=search, category=category, published=published ) return posts @router .get("/{postid }",responsemodel =postschemas .PostResponse) async defgetpost ( postid : int, db: Session = Depends(getdb ) ): """ Get a specific post by ID. - post_id : Unique identifier for the post """ post =postservice .getpost (db=db,postid =postid ) if not post: raise HTTPException( statuscode =status.HTTP404NOTFOUND , detail="Post not

// original public source
davila7/claude-code-templates
/cli-tool/templates/python/examples/fastapi-app/.claude/commands/api-endpoints.md
License: MIT License
Independent project, not affiliated with Anthropic. This skill remains the property of its original author.
// install this skill
Paste this command in your terminal at the root of your project:
mkdir -p .claude/commands && curl -o ".claude/commands/api-endpoints.md" "https://raw.githubusercontent.com/davila7/claude-code-templates/main/cli-tool/templates/python/examples/fastapi-app/.claude/commands/api-endpoints.md"
Then in Claude Code, type /api-endpoints to activate it.
open_in_newOpen original source
// save
Save available after sign in.
loginSign in to save
// information
Creatordavila7
Stars 30.6k
CategoryBackend
LicenseMIT License
UpdatedMay 22, 2026
Format.md
AccessFree
// similar

Skills Backend

View allarrow_forward