Back to list
phrazzld

api-design

by phrazzld

2🍴 1📅 Jan 24, 2026

SKILL.md


name: api-design description: | REST API design principles, versioning, and documentation. Use when:

  • Designing new API endpoints
  • Choosing between REST, GraphQL, or gRPC
  • Implementing API versioning
  • Writing OpenAPI specifications
  • Handling API errors Keywords: REST, API, OpenAPI, Swagger, versioning, HTTP methods, status codes, pagination, error handling

API Design

REST-first, OpenAPI-driven, backward-compatible by default.

REST Principles

Resources as nouns. HTTP methods as verbs:

GET    /users          # List users
GET    /users/123      # Get user
POST   /users          # Create user
PUT    /users/123      # Replace user
PATCH  /users/123      # Update user
DELETE /users/123      # Delete user

# Relationships through URL hierarchy
GET /users/123/orders

Never: /getUser, /createOrder, /api/processPayment

HTTP Status Codes

CodeWhen
200Successful GET, PUT, PATCH
201Successful POST (created)
204Successful DELETE (no body)
400Invalid request format
401Not authenticated
403Not authorized
404Resource not found
409Business logic conflict
422Validation failed
500Server error

Error Format

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid request data",
    "details": [
      {
        "field": "email",
        "message": "Invalid email format",
        "value": "not-an-email"
      }
    ]
  }
}

Pagination

GET /users?page=2&per_page=50&sort=created_at&order=desc

{
  "data": [...],
  "meta": {
    "page": 2,
    "per_page": 50,
    "total": 150,
    "total_pages": 3
  }
}

Versioning

URL versioning for public APIs:

/v1/users
/v2/users

Rules:

  • Major version for breaking changes only
  • 6-month deprecation notice minimum
  • Side-by-side version support during transition
  • Additive changes don't require new version

OpenAPI First

Write spec before code:

openapi: 3.0.0
paths:
  /users/{id}:
    get:
      summary: Get user by ID
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: User found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        '404':
          description: User not found

Anti-Patterns

  • RPC-style endpoints (/api/getUserById)
  • POST for everything
  • Deep nesting (/users/123/orders/456/items/789)
  • Inconsistent error formats
  • Breaking changes without version bump
  • Documentation that doesn't match implementation

Score

Total Score

50/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon