Skip to content
Back to skills

Fastapi Endpoint

ASecurity

Add a FastAPI endpoint with Pydantic request/response models and DI

  • 3 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 3, 2026
ai-agentsgofastapiapi

Works with

  • cli
  • api

Security analysis

A100/100

Scanned September 3, 2026

npx -y skills add black141312/ada --skill fastapi-endpoint --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Fastapi Endpoint?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Fastapi Endpoint
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/black141312-fastapi-endpoint/badge)](https://www.skillsdirectory.com/skills/black141312-fastapi-endpoint)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: fastapi-endpoint
description: Add a FastAPI endpoint with Pydantic request/response models and DI
category: frameworks
---

# FastAPI Endpoint

Use to add a typed FastAPI route with Pydantic schemas for validation and serialization, plus dependency injection where needed.

1. Define Pydantic models for the request body and response (`response_model=`); use separate input/output schemas to avoid leaking fields.
2. Add the path operation on a `router`/`app` with the right verb decorator (`@router.post("/items")`) and type-annotated params.
3. Declare params by source: path (`item_id: int`), query (defaults), body (Pydantic model) — FastAPI infers from the annotation.
4. Inject shared resources (DB session, current user) via `Depends(...)`; raise `HTTPException` for error cases.
5. Set `status_code=` and `response_model=` explicitly; keep the handler thin and delegate logic to functions/services.
6. Run `uvicorn app:app --reload`, check `/docs`, and exercise the endpoint to confirm validation and shape.

## Rules
- Use distinct input vs output Pydantic models; never return ORM objects without a `response_model` to filter fields.
- Type every parameter — FastAPI's validation and docs derive entirely from annotations.
- Use `Depends` for DB sessions/auth instead of globals; it makes endpoints testable.
- Raise `HTTPException(status_code, detail)` for expected errors; don't return ad-hoc error dicts.
- For DB or external I/O, prefer `async def` with async clients, or keep blocking calls in `def` handlers (FastAPI offloads them).

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…