LLM Skills
~/catalogue/backend//api-endpoints
Backendsource GitHub

Générateur de points de terminaison fastapi

/api-endpoints

Créer des points de terminaison FastAPI complets, dotés d'une structure, d'une validation et d'une documentation adéquates.

davila7davila7
30.6k
22 mai 2026
MIT License
// contenu du skill

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 automatic API 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 import get_db
from app.schemas import post_schemas
from app.services import post_service
from app.core.dependencies import get_current_user, get_current_active_user
from app.models.user import User

router = APIRouter()

@router.get("/", response_model=List[post_schemas.PostResponse])
async def get_posts(
    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(get_db)
):
    """
    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 = post_service.get_posts(
        db=db,
        skip=skip,
        limit=limit,
        search=search,
        category=category,
        published=published
    )
    return posts

@router.get("/{post_id}", response_model=post_schemas.PostResponse)
async def get_post(
    post_id: int,
    db: Session = Depends(get_db)
):
    """
    Get a specific post by ID.
    
    - **post_id**: Unique identifier for the post
    """
    post = post_service.get_post(db=db, post_id=post_id)
    if not post:
        raise HTTPException(
            status_code=status.HTTP_404_NOT_FOUND,
            detail="Post not found"
        )
    return post

@router.post("/", response_model=post_schemas.PostResponse, status_code=status.HTTP_201_CREATED)
async def create_post(
    post: post_schemas.PostCreate,
    db: Session = Depends(get_db),
    current_user: User = Depends(get_current_active_user)
):
    """
    Create a new post.
    
    - **title**: Post title (required)
    - **content**: Post content (required)
    - **category**: Post category (optional)
    - **published**: Publication status (default: false)
    """
    return post_service.create_post(
        db=db,
        post=post,
        user_id=current_user.id
    )

@router.put("/{post_id}", response_model=post_schemas.PostResponse)
async def update_post(
    post_id: int,
    post_update: post_schemas.PostUpdate,
    db: Session = Depends
// source originale publique
davila7/claude-code-templates
/cli-tool/templates/python/examples/fastapi-app/.claude/commands/api-endpoints.md
Licence : MIT License
Projet indépendant, non affilié à Anthropic. Ce skill reste la propriété de son auteur original.
// installer ce skill
Collez cette commande dans votre terminal à la racine de votre projet :
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"
Ensuite dans Claude Code, tapez /api-endpoints pour l'activer.
open_in_newVoir la source originale
// sauvegarder
Sauvegarde disponible après connexion.
loginSe connecter pour sauvegarder
// informations
Créateurdavila7
Étoiles 30.6k
CatégorieBackend
LicenceMIT License
Mis à jour22 mai 2026
Format.md
AccèsGratuit
// similaires

Skills Backend

Voir toutarrow_forward