API design and implementation across REST, GraphQL, gRPC, and tRPC patterns. Use when building backend services, public APIs, or service-to-service communication. Covers REST frameworks (FastAPI, Axum, Gin, Hono), GraphQL libraries (Strawberry, async-graphql, gqlgen, Pothos), gRPC (Tonic, Connect-Go), tRPC for TypeScript, pagination strategies (cursor-based, offset-based), rate limiting, caching, versioning, and OpenAPI documentation generation. Includes frontend integration patterns for forms, tables, dashboards, and ai-chat skills.
Comprehensive guide for designing and implementing APIs across REST, GraphQL, gRPC, and tRPC patterns.
This skill provides framework selection guidance, pagination strategies, OpenAPI documentation, and frontend integration patterns for Python, TypeScript, Rust, and Go.
Status: Production-ready Version: 1.0.0 Date: December 2025
Choose API pattern based on consumers:
Reference SKILL.md for decision frameworks and quick examples
Use references/ for deep-dive guides:
rest-design-principles.md - REST best practicespagination-patterns.md - Cursor vs offset paginationtrpc-setup-guide.md - tRPC E2E type safetygraphql-schema-design.md - GraphQL schemas, N+1 preventiongrpc-protobuf-guide.md - gRPC and Protocol Buffersopenapi-documentation.md - Auto-generated docsExplore examples/ for complete working projects
Run scripts/ for token-free validation:
generate_openapi.py - Extract OpenAPI specsvalidate_api_spec.py - Validate OpenAPI 3.1benchmark_endpoints.py - Load test APIsSee init.md for master plan and architecture decisions.
implementing-api-patterns/
├── SKILL.md # Main skill file (<500 lines)
├── README.md # This file
├── init.md # Master plan
├── references/ # Detailed guides (one level deep)
│ ├── rest-design-principles.md
│ ├── pagination-patterns.md
│ ├── trpc-setup-guide.md
│ ├── graphql-schema-design.md
│ ├── grpc-protobuf-guide.md
│ └── openapi-documentation.md
├── examples/ # Working code examples
│ ├── python-fastapi/
│ │ ├── main.py
│ │ └── requirements.txt
│ └── typescript-hono/
│ ├── index.ts
│ └── package.json
└── scripts/ # Token-free utilities
├── generate_openapi.py
├── validate_api_spec.py
└── benchmark_endpoints.py
All framework recommendations validated with Context7:
/websites/fastapi_tiangolo (Score: 79.8, Snippets: 29,015)/llmstxt/hono_dev_llms_txt (Score: 92.1, Snippets: 1,817)/trpc/trpc (Score: 92.7, Snippets: 900)/websites/rs_axum_axum (Score: 77.5, Snippets: 7,260)| Framework | Req/s | Latency | Cold Start | Best For | |-----------|-------|---------|------------|----------| | Axum (Rust) | ~140k | <1ms | N/A | Max throughput | | Gin (Go) | ~100k+ | 1-2ms | N/A | Mature ecosystem | | Hono (TS) | ~50k | <5ms | <5ms | Edge deployment | | FastAPI (Python) | ~40k | 5-10ms | 1-2s | Developer experience |
Cursor-based (Recommended for Scale):
Offset-based (Simple Cases):
/docs, /redocExplicit patterns for connecting to all frontend skills:
cd examples/python-fastapi
pip install -r requirements.txt
python main.py
# Visit http://localhost:8000/docs
Features:
cd examples/typescript-hono
bun install
bun run dev
# Visit http://localhost:3000/docs
Features:
python scripts/generate_openapi.py examples/python-fastapi/main.py openapi.json
Extracts OpenAPI specification without running the server.
python scripts/validate_api_spec.py openapi.json
Validates against OpenAPI 3.1 schema, reports errors and warnings.
python scripts/benchmark_endpoints.py http://localhost:8000 --requests 1000 --concurrency 10
Load tests API endpoints and reports:
WHO CONSUMES YOUR API?
PUBLIC/THIRD-PARTY → REST
├─ Python → FastAPI
├─ TypeScript → Hono
├─ Rust → Axum
└─ Go → Gin
FRONTEND TEAM (same org)
├─ TypeScript full-stack → tRPC
└─ Complex data needs → GraphQL
SERVICE-TO-SERVICE → gRPC
└─ High performance needed
MOBILE APPS
├─ Bandwidth constrained → GraphQL
└─ Simple CRUD → REST
Python: FastAPI (modern, auto-docs) > Flask (lightweight) > Django REST
TypeScript: Hono (edge-first) > tRPC (full-stack TS) > Express (legacy)
Rust: Axum (ergonomics) > Actix-web (max perf) > Rocket (easy DX)
Go: Gin (standard) > net/http (stdlib) > Echo/Fiber (enterprise)
/api/v1/)Use POST/PUT endpoints with Pydantic/Zod validation for form submissions.
Implement cursor pagination for scalable table data fetching.
Combine REST endpoints with SSE for real-time dashboard updates.
Use SSE streaming for LLM response streaming to chat interfaces.
Implement GraphQL for flexible filtering and field selection.
Connect API endpoints to database operations (PostgreSQL, MongoDB, etc.).
/websites/fastapi_tiangolo, /fastapi/fastapi/llmstxt/hono_dev_llms_txt, /honojs/hono/trpc/trpc, /websites/trpc_io/websites/rs_axum_axum, /tokio-rs/axumforms - Form validation and submissiontables - Data table integration with paginationdashboards - Real-time dashboard APIsai-chat - SSE streaming for chat interfacesdatabases-sql - SQL database integrationauth-security - Authentication and authorization| Version | Date | Changes | |---------|------|---------| | 1.0.0 | 2025-12-02 | Initial production release |
MIT License - See repository root for details
Built with Claude Code following Anthropic's best practices for Skills development.
npx skills add ancoleman/implementing-api-patterns下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer