Loading...
Loading...
Design production-grade REST, GraphQL, gRPC, and Python library APIs with correct schemas, error contracts, auth, and versioning. Use when the user asks to design an API, define endpoints, create an OpenAPI/Swagger spec, design a GraphQL schema, build a gRPC service, model request/response with Pydantic, add pagination, or review API contracts. NOT for building MCP server tools (use mcp-server). NOT for Node.js/Express API routes or backend patterns (use backend-patterns or typescript-development).
npx skill4agent add viktorbezdek/skillstack api-design/api/v1/users/api/v1/organizations/{org_id}/teams/getUsers/user_profilesGETPOSTPUTPATCHDELETE200 OK201 Created204 No Content400 Bad Request401 Unauthorized403 Forbidden404 Not Found409 Conflict422 Unprocessable Entity429 Too Many Requests500 Internal Server Error503 Service Unavailable{
"error": {
"code": "VALIDATION_ERROR",
"message": "Request validation failed",
"details": [
{ "field": "email", "message": "Invalid email format" }
],
"requestId": "req_abc123",
"timestamp": "2025-10-25T10:30:00Z"
}
}type User {
id: ID!
email: String!
profile: Profile
posts(first: Int, after: String): PostConnection!
createdAt: DateTime!
}
type PostConnection {
edges: [PostEdge!]!
pageInfo: PageInfo!
totalCount: Int!
}
type Query {
user(id: ID!): User
users(first: Int, after: String): UserConnection!
me: User
}
type Mutation {
createUser(input: CreateUserInput!): CreateUserPayload!
updateUser(id: ID!, input: UpdateUserInput!): UpdateUserPayload!
}from fastapi import APIRouter, Depends, HTTPException, status
router = APIRouter(prefix="/api/v1/users", tags=["users"])
@router.post("", response_model=UserRead, status_code=status.HTTP_201_CREATED)
async def create_user(
user_data: UserCreate,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user),
) -> UserRead:
"""Create a new user in the current tenant."""
repository = UserRepository(db, tenant_id=current_user.tenant_id)
user = await repository.create(user_data)
return userfrom pydantic import BaseModel, EmailStr, Field, ConfigDict
class UserCreate(BaseModel):
"""Schema for creating a new user."""
email: EmailStr
full_name: str = Field(..., min_length=1, max_length=255)
password: str = Field(..., min_length=8)
class UserRead(BaseModel):
"""Schema for reading user data (public fields only)."""
id: str
tenant_id: str
email: EmailStr
full_name: str
created_at: datetime
model_config = ConfigDict(from_attributes=True)GET /posts?limit=20&cursor=eyJpZCI6MTIzfQ
Response:
{
"data": [...],
"pagination": {
"nextCursor": "eyJpZCI6MTQzfQ",
"hasMore": true
}
}GET /posts?limit=20&offset=40
Response:
{
"data": [...],
"pagination": {
"total": 500,
"limit": 20,
"offset": 40
}
}Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...X-API-Key: sk_live_abc123def456X-RateLimit-Limit: 100
X-RateLimit-Remaining: 75
X-RateLimit-Reset: 1698340800
Retry-After: 60| File | Description |
|---|---|
| Comprehensive REST API patterns and status codes |
| OAuth 2.0, JWT, API keys, MFA patterns |
| API versioning and deprecation |
| Health checks, webhooks, batch operations |
| GraphQL schema design patterns |
| Apollo Federation architecture |
| GraphQL performance, DataLoader, caching |
| Python library SOLID principles |
| Python PEP quick reference |
| FastAPI main app configuration |
| OpenAPI customization |
| FastAPI exception handlers |
| CORS and rate limiting setup |
| Complete OpenAPI 3.1 example |
| GraphQL with Relay connections |
| Protocol Buffer definitions |
| Tier-based rate limit config |
| Auth, CORS, security headers |
| File | Description |
|---|---|
| Complete CRUD router template |
| Request/response schema template |
| Repository with tenant isolation |
| Upstash Redis rate limiter |
| FastAPI exception handlers |
| TanStack Start server functions |
| File | Description |
|---|---|
| CRUD endpoints with repository |
| Validation schema examples |
| Pagination implementation |
| API testing patterns |
| TanStack Start examples |
| Blog API OpenAPI specification |
| Full GraphQL schema with subscriptions |
| File | Description |
|---|---|
| Analyze GraphQL schemas for quality |
| Generate TypeScript resolvers |
| Scaffold Apollo Federation subgraphs |
| OpenAPI validation and docs generation |
| Validate API specifications |
| File | Description |
|---|---|
| Production-ready pyproject.toml |
| Library README template |
| Contribution guide |
| Recommended package layout |
| Test organization |
| Exception hierarchy pattern |
| Configuration pattern |
| File | Description |
|---|---|
| API design review checklist |
| Security review checklist |
# Scaffold subgraphs
python scripts/federation_scaffolder.py users-service --entities User,Profile
python scripts/federation_scaffolder.py posts-service --entities Post --references User
# Configure gateway
python scripts/federation_scaffolder.py gateway --subgraphs users:4001,posts:4002# Validate OpenAPI spec
python scripts/api_helper.py validate --spec openapi.yaml
# Analyze GraphQL schema
python scripts/schema_analyzer.py schema.graphql --validate
# Generate documentation
python scripts/api_helper.py docs --spec openapi.yaml --output docs//users/getUsersIdempotency-Key[ ] All endpoints use nouns, not verbs
[ ] Consistent response envelope structure
[ ] Error responses include codes and actionable messages
[ ] Pagination on all list endpoints
[ ] Authentication/authorization documented
[ ] Rate limit headers defined
[ ] Versioning strategy documented
[ ] CORS configured for known origins
[ ] Idempotency keys for mutating operations
[ ] OpenAPI spec validates without errors
[ ] SDK generation tested
[ ] Examples for all request/response typesapi-design