Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

fastapi-development

БесплатноБез исполняемых скриптовНе проверен

Modern Python API development with FastAPI covering async patterns, Pydantic validation, dependency injection, and production deployment

manutejот manutej★ 64 звезды на GitHub17 установок в других каталогах

Об этом скилле

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

  1. Type Hints: Python 3.6+ type hints for validation and documentation
  2. Async Support: Native async/await for high-performance I/O operations
  3. Pydantic Models: Automatic request/response validation and serialization
  4. Dependency Injection: Elegant system for sharing logic across endpoints
  5. OpenAPI Docs: Automatic interactive API documentation
  6. Security: Built-in support for OAuth2, JWT, API keys, and more
  7. Testing: Easy to test with TestClient and async test support

Core Architecture Components

  1. FastAPI App: The main application instance
  2. Path Operations: Endpoint definitions with HTTP methods
  3. Pydantic Models: Data validation and serialization schemas
  4. Dependencies: Reusable logic for authentication, database, etc.
  5. Routers: Organize endpoints into modules
  6. Middleware: Process requests/responses globally
  7. 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
Полный SKILL.md на GitHub

Установить fastapi-development в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

EXAMPLES.mdREADME.md

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), без исполняемых скриптов.

Похожие скиллы

Сравнить fastapi-development с