fastapi-development
БесплатноБез исполняемых скриптовНе проверенModern Python API development with FastAPI covering async patterns, Pydantic validation, dependency injection, and production deployment
Об этом скилле
FastAPI Development
A comprehensive skill for building modern, high-performance Python APIs with FastAPI. Master async/await patterns, Pydantic data validation, dependency injection, authentication, database integration, and production-ready deployment strategies.
When to Use This Skill
Use this skill when:
- Building RESTful APIs with Python for web, mobile, or microservices
- Developing high-performance, asynchronous backend services
- Creating APIs with automatic interactive documentation (OpenAPI/Swagger)
- Implementing OAuth2, JWT authentication, or other security patterns
- Integrating with SQL or NoSQL databases in Python applications
- Building APIs that require strong data validation and type safety
- Developing microservices with automatic request/response validation
- Creating APIs with WebSocket support for real-time features
- Migrating from Flask, Django REST Framework, or other Python frameworks
- Building production-ready APIs with proper error handling and testing
Core Concepts
FastAPI Philosophy
FastAPI is built on three foundational principles:
- Fast to Code: Reduce development time with automatic validation and documentation
- Fast to Run: High performance comparable to NodeJS and Go (via Starlette and Pydantic)
- Fewer Bugs: Automatic validation reduces human errors by about 40%
- Standards-Based: Built on OpenAPI and JSON Schema standards
- Editor Support: Full autocomplete, type checking, and inline documentation
Key FastAPI Features
- Type Hints: Python 3.6+ type hints for validation and documentation
- Async Support: Native async/await for high-performance I/O operations
- Pydantic Models: Automatic request/response validation and serialization
- Dependency Injection: Elegant system for sharing logic across endpoints
- OpenAPI Docs: Automatic interactive API documentation
- Security: Built-in support for OAuth2, JWT, API keys, and more
- Testing: Easy to test with TestClient and async test support
Core Architecture Components
- FastAPI App: The main application instance
- Path Operations: Endpoint definitions with HTTP methods
- Pydantic Models: Data validation and serialization schemas
- Dependencies: Reusable logic for authentication, database, etc.
- Routers: Organize endpoints into modules
- Middleware: Process requests/responses globally
- Background Tasks: Execute code after returning responses
Getting Started
Installation
# Basic installation
pip install fastapi
# With ASGI server for production
pip install "fastapi[all]"
# Or install separately
pip install fastapi uvicorn[standard]
# Additional dependencies
pip install python-multipart # For form data
pip install python-jose[cryptography] # For JWT
pip install passlib[bcrypt] # For password hashing
pip install sqlalchemy # For SQL databases
pip install databases # For async database support
Minimal FastAPI Application
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def root():
return {"message": "Hello World"}
# Run with: uvicorn main:app --reload
Pydantic Models for Data Validation
Basic Model Definition
from pydantic import BaseModel, Field, EmailStr, HttpUrl
from typing import Optional, List
from datetime import datetime
class User(BaseModel):
id: int
username: str = Field(..., min_length=3, max_length=50)
email: EmailStr
full_name: Optional[str] = None
is_active: bool = True
created_at: datetime = Field(default_factory=datetime.utcnow)
class UserCreate(BaseModel):
username: str = Field(..., min_length=3, max_length=50)
email: EmailStr
password: str = Field(..., min_length=8)
full_name: Optional[str] = None
class UserResponse(BaseModel):
id: int
username: str
email: EmailStr
full_name: Optional[str]
is_active: bool
class Config:
orm_mode = True # For SQLAlchemy models
Nested Models
class Image(BaseModel):
url: HttpUrl
name: str
class Item(BaseModel):
name: str
description: Optional[str] = None
price: float = Field(..., gt=0)
tax: Optional[float] = None
tags: List[str] = []
images: Optional[List[Image]] = None
# Request example:
# {
# "name": "Laptop",
# "price": 999.99,
# "tags": ["electronics", "computers"],
# "images": [
# {"url": "http://example.com/img1.jpg", "name": "Front view"}
# ]
# }
Model Validation and Examples
from pydantic import BaseModel, Field, validator
class Product(BaseModel):
name: str = Field(..., example="MacBook Pro")
price: float = Field(..., gt=0, example=1999.99)
discount: Optional[float] = Field(None, ge=0, le=100, example=10.0)
@validator('discount')
def discount_check(cls, v, values):
if v and 'price' in values:
discounted = values['price'] * (1 - v/100)
if discounte
Установить fastapi-development в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл fastapi-development?
Modern Python API development with FastAPI covering async patterns, Pydantic validation, dependency injection, and production deployment
Как установить скилл fastapi-development?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл fastapi-development запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic