zpaper-com avatar

documentation-master

Complete documentation suite for architecture, APIs, and project docs

version
1.0.0
GitHub stars
7

Install

/plugin install documentation-master@claudekit

Run it inside Claude Code after adding the marketplace with /plugin marketplace add zpaper-com/ClaudeKit.

Contents

Commands 3

Create Architecture Documentation

You are tasked with creating comprehensive architecture documentation for this project.

Documentation Scope

Create documentation that covers:

1. System Overview

  • Project purpose and goals
  • Key features and capabilities
  • Target users and use cases
  • Technology stack summary

2. Architecture Diagrams

  • High-level system architecture
  • Component relationships and data flow
  • Database schema (if applicable)
  • API structure (if applicable)
  • Deployment architecture

3. Component Documentation

For each major component:

  • Purpose and responsibility
  • Key interfaces and dependencies
  • Data models and schemas
  • Important algorithms or business logic
  • Configuration options

4. Technical Decisions

Document key architectural decisions:

  • Technology choices and rationale
  • Design patterns used
  • Trade-offs considered
  • Alternatives evaluated

5. Data Flow

  • Request/response flow
  • Data persistence strategy
  • Caching strategy (if applicable)
  • External service integrations

6. Security Architecture

  • Authentication mechanism
  • Authorization approach
  • Data protection measures
  • Security considerations

7. Scalability & Performance

  • Performance characteristics
  • Scalability approach
  • Bottlenecks and limitations
  • Future scaling considerations

8. Development Guidelines

  • Code organization principles
  • Module boundaries
  • Testing strategy
  • Development workflow

Process

  1. Analyze the codebase thoroughly to understand:

    • Project structure and organization
    • Main components and their relationships
    • Technologies and frameworks used
    • Data models and APIs
  2. Create architecture documentation in docs/architecture/:

    • README.md - Overview and table of contents
    • system-overview.md - High-level system description
    • components.md - Detailed component documentation
    • data-architecture.md - Database and data flow
    • api-architecture.md - API structure (if applicable)
    • security.md - Security architecture
    • deployment.md - Deployment architecture
    • decisions.md - Architecture Decision Records (ADRs)
  3. Use diagrams where helpful:

    • Mermaid diagrams for system architecture
    • Entity-relationship diagrams for databases
    • Sequence diagrams for complex flows
  4. Keep it practical:

    • Focus on what exists, not what's planned
    • Include code examples where relevant
    • Link to relevant source files
    • Make it useful for developers joining the project

Output Format

Structure documentation using clear markdown with:

  • Table of contents for easy navigation
  • Headings for sections
  • Code blocks with syntax highlighting
  • Mermaid diagrams for visual representation
  • Links to source code files
  • Examples and use cases

Example Mermaid Diagram

graph TD
    A[Client] -->|HTTP Request| B[API Gateway]
    B --> C[Auth Service]
    B --> D[Business Logic]
    D --> E[Database]
    D --> F[Cache]
    B --> G[External Services]

Begin by analyzing the project structure and then create comprehensive architecture documentation.

Generate API Documentation

You are tasked with generating comprehensive API documentation for this project's API endpoints.

Documentation Objectives

Create clear, complete, and developer-friendly API documentation that includes:

  • Authentication requirements
  • All available endpoints
  • Request/response formats
  • Error handling
  • Code examples
  • Rate limiting information

Documentation Structure

1. API Overview

# API Documentation

## Overview

[Project Name] API allows developers to [primary use cases].

**Base URL:** `https://api.example.com/v1`

**API Version:** v1

**Response Format:** JSON

**Authentication:** Bearer Token (JWT)

**Rate Limiting:** 100 requests per minute per API key

## Quick Start

```bash
# Example API call
curl -X GET https://api.example.com/v1/users \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json"

### 2. Authentication

```markdown
## Authentication

All API requests require authentication using a Bearer token.

### Getting an API Key

1. Log in to your account
2. Navigate to Settings → API Keys
3. Click "Generate New Key"
4. Copy and securely store your key

### Using Your API Key

Include your API key in the Authorization header:

```bash
Authorization: Bearer YOUR_API_KEY

Example Request

curl -X GET https://api.example.com/v1/users \
  -H "Authorization: Bearer abc123xyz789"

Authentication Errors

StatusCodeDescription
401UNAUTHORIZEDMissing or invalid API key
401TOKEN_EXPIREDAPI key has expired
403FORBIDDENInsufficient permissions

### 3. Rate Limiting

```markdown
## Rate Limiting

API requests are limited to prevent abuse.

**Limits:**
- Standard: 100 requests per minute
- Premium: 1,000 requests per minute
- Enterprise: 10,000 requests per minute

**Headers:**

Each response includes rate limit headers:

```http
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1640995200

Rate Limit Exceeded:

Status: 429 Too Many Requests

{
  "error": {
    "code": "RATE_LIMIT_EXCEEDED",
    "message": "Rate limit exceeded. Retry after 60 seconds.",
    "retryAfter": 60
  }
}

### 4. Common Response Formats

```markdown
## Response Formats

### Success Response

```json
{
  "data": {
    "id": "user_123",
    "name": "John Doe",
    "email": "john@example.com"
  },
  "meta": {
    "timestamp": "2024-01-01T12:00:00Z",
    "version": "1.0"
  }
}

Error Response

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid email format",
    "details": {
      "field": "email",
      "value": "invalid-email"
    },
    "timestamp": "2024-01-01T12:00:00Z",
    "requestId": "req_abc123"
  }
}

Paginated Response

{
  "data": [...],
  "pagination": {
    "total": 150,
    "page": 1,
    "perPage": 10,
    "totalPages": 15,
    "hasNext": true,
    "hasPrev": false
  }
}

### 5. Error Codes

```markdown
## Error Codes

| HTTP Status | Code | Description |
|-------------|------|-------------|
| 400 | `INVALID_REQUEST` | Request validation failed |
| 400 | `INVALID_INPUT` | Input data is invalid |
| 401 | `UNAUTHORIZED` | Authentication required |
| 403 | `FORBIDDEN` | Insufficient permissions |
| 404 | `NOT_FOUND` | Resource not found |
| 409 | `CONFLICT` | Resource already exists |
| 422 | `UNPROCESSABLE_ENTITY` | Business logic error |
| 429 | `RATE_LIMIT_EXCEEDED` | Too many requests |
| 500 | `INTERNAL_ERROR` | Server error |
| 503 | `SERVICE_UNAVAILABLE` | Temporary service outage |

6. Endpoint Documentation Template

For each endpoint, document:

## [Endpoint Name]

`HTTP_METHOD /path/to/endpoint`

Brief description of what this endpoint does.

### Request

**Method:** `GET | POST | PUT | PATCH | DELETE`

**URL:** `/api/v1/resource/:id`

**Path Parameters:**

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| id | string | Yes | Unique resource identifier |

**Query Parameters:**

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| page | integer | No | 1 | Page number |
| limit | integer | No | 10 | Items per page (max: 100) |
| sort | string | No | createdAt | Sort field |
| order | string | No | desc | Sort order (asc, desc) |

**Request Headers:**

| Header | Required | Description |
|--------|----------|-------------|
| Authorization | Yes | Bearer token |
| Content-Type | Yes | application/json |

**Request Body:**

```json
{
  "name": "string (required, 1-100 chars)",
  "email": "string (required, valid email)",
  "age": "integer (optional, 0-150)"
}

Response

Success Response:

Status: 200 OK

{
  "data": {
    "id": "user_123",
    "name": "John Doe",
    "email": "john@example.com",
    "age": 30,
    "createdAt": "2024-01-01T00:00:00Z",
    "updatedAt": "2024-01-01T00:00:00Z"
  }
}

Error Responses:

Status: 400 Bad Request

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid email format",
    "details": { "field": "email" }
  }
}

Status: 404 Not Found

{
  "error": {
    "code": "NOT_FOUND",
    "message": "User not found"
  }
}

Examples

cURL:

curl -X POST https://api.example.com/v1/users \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "John Doe",
    "email": "john@example.com",
    "age": 30
  }'

JavaScript:

const response = await fetch('https://api.example.com/v1/users', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${API_KEY}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: 'John Doe',
    email: 'john@example.com',
    age: 30
  })
});

const user = await response.json();
console.log(user.data);

Python:

import requests

response = requests.post(
    'https://api.example.com/v1/users',
    headers={
        'Authorization': f'Bearer {API_KEY}',
        'Content-Type': 'application/json'
    },
    json={
        'name': 'John Doe',
        'email': 'john@example.com',
        'age': 30
    }
)

user = response.json()['data']
print(user)

### 7. Resource Schemas

```markdown
## Resource Schemas

### User

```typescript
interface User {
  id: string;              // Unique identifier (UUID)
  name: string;            // Full name (1-100 characters)
  email: string;           // Email address (valid format)
  age?: number;            // Optional age (0-150)
  role: 'admin' | 'user';  // User role
  isActive: boolean;       // Account active status
  createdAt: string;       // ISO 8601 timestamp
  updatedAt: string;       // ISO 8601 timestamp
}

Field Validation:

FieldTypeConstraints
namestringRequired, 1-100 chars
emailstringRequired, valid email format
ageintegerOptional, 0-150
roleenumOne of: admin, user

### 8. Pagination

```markdown
## Pagination

All list endpoints support pagination.

**Query Parameters:**

- `page` - Page number (default: 1)
- `limit` - Items per page (default: 10, max: 100)

**Example Request:**

```bash
GET /api/v1/users?page=2&limit=20

Response:

{
  "data": [...],
  "pagination": {
    "total": 150,
    "page": 2,
    "perPage": 20,
    "totalPages": 8,
    "hasNext": true,
    "hasPrev": true
  },
  "links": {
    "first": "/api/v1/users?page=1&limit=20",
    "prev": "/api/v1/users?page=1&limit=20",
    "next": "/api/v1/users?page=3&limit=20",
    "last": "/api/v1/users?page=8&limit=20"
  }
}

### 9. Filtering and Sorting

```markdown
## Filtering and Sorting

### Filtering

Use query parameters to filter results:

```bash
# Single filter
GET /api/v1/users?role=admin

# Multiple filters
GET /api/v1/users?role=admin&isActive=true

# Advanced filters
GET /api/v1/users?createdAt[gte]=2024-01-01&createdAt[lte]=2024-12-31

Filter Operators:

  • eq - Equal (default)
  • ne - Not equal
  • gt - Greater than
  • gte - Greater than or equal
  • lt - Less than
  • lte - Less than or equal
  • in - In array
  • contains - String contains

Sorting

Sort results using the sort parameter:

# Ascending
GET /api/v1/users?sort=name

# Descending
GET /api/v1/users?sort=-name

# Multiple fields
GET /api/v1/users?sort=role,-createdAt

### 10. Webhooks (if applicable)

```markdown
## Webhooks

Subscribe to events via webhooks.

### Configuring Webhooks

```bash
POST /api/v1/webhooks
{
  "url": "https://your-app.com/webhook",
  "events": ["user.created", "user.updated"],
  "secret": "your_secret_key"
}

Webhook Payload

{
  "id": "evt_123",
  "type": "user.created",
  "data": {
    "id": "user_123",
    "name": "John Doe",
    "email": "john@example.com"
  },
  "timestamp": "2024-01-01T12:00:00Z"
}

Verifying Webhooks

Verify webhook signatures using HMAC SHA256:

const crypto = require('crypto');

function verifyWebhook(payload, signature, secret) {
  const hmac = crypto.createHmac('sha256', secret);
  const digest = hmac.update(payload).digest('hex');
  return signature === digest;
}

## Documentation Generation Process

1. **Analyze the codebase:**
   - Find all API routes/endpoints
   - Identify request/response schemas
   - Note authentication requirements
   - Document error responses

2. **Generate endpoint documentation:**
   - One section per endpoint
   - Include all HTTP methods
   - Document all parameters
   - Provide working examples

3. **Create schemas:**
   - Define data models
   - Include validation rules
   - Show relationships

4. **Add examples:**
   - cURL commands
   - JavaScript/TypeScript
   - Python
   - Other relevant languages

5. **Test all examples:**
   - Ensure examples are accurate
   - Verify responses match documentation
   - Test error cases

6. **Generate OpenAPI/Swagger spec** (if applicable):
   - Create openapi.yaml or swagger.json
   - Include all endpoints and schemas
   - Add examples and descriptions

Begin by analyzing the API routes and generating comprehensive documentation following this structure.

Update Documentation

You are tasked with updating project documentation to reflect the current state of the codebase.

Documentation Scope

Review and update these documentation areas:

1. README.md

The project's front door - make it welcoming and informative.

Essential Sections:

# Project Name

Brief description (1-2 sentences)

## Features
- Key feature 1
- Key feature 2
- Key feature 3

## Installation

```bash
npm install

Quick Start

// Simple usage example
const app = require('project-name');
app.start();

Documentation

License

MIT


**Update If:**
- Installation steps changed
- New features added
- Configuration requirements changed
- Examples are outdated
- Links are broken

### 2. API Documentation

**For Each Endpoint:**
- HTTP method and path
- Request parameters and body
- Response format and status codes
- Example requests/responses
- Authentication requirements
- Rate limiting

**For Each Function:**
- Purpose and behavior
- Parameters with types
- Return value with type
- Exceptions thrown
- Usage examples
- Edge cases

### 3. Configuration Documentation

**Document:**
- Environment variables
- Configuration files
- Default values
- Valid options
- Examples for different environments

**Example:**
```markdown
## Configuration

### Environment Variables

| Variable | Required | Default | Description |
|----------|----------|---------|-------------|
| PORT | No | 3000 | Server port |
| DATABASE_URL | Yes | - | PostgreSQL connection string |
| API_KEY | Yes | - | Third-party API key |

### Example .env

```env
PORT=3000
DATABASE_URL=postgresql://user:pass@localhost:5432/db
API_KEY=your_api_key_here

### 4. Getting Started / Tutorial

**Include:**
- Prerequisites
- Step-by-step installation
- First-time setup
- Hello World example
- Next steps

**Make it:**
- Copy-pastable
- Tested and working
- Beginner-friendly
- Complete (no missing steps)

### 5. Architecture Documentation

**Update if changed:**
- System architecture diagrams
- Component relationships
- Data flow
- Technology stack
- Design decisions

### 6. Development Documentation

**For Contributors:**
- Development setup
- Running tests
- Code style guidelines
- Commit message format
- PR process
- Development workflow

**Example:**
```markdown
## Development

### Setup

```bash
git clone https://github.com/user/repo.git
cd repo
npm install
cp .env.example .env
# Edit .env with your values
npm run dev

Testing

npm test              # Run all tests
npm run test:unit     # Unit tests only
npm run test:e2e      # E2E tests only
npm run test:watch    # Watch mode

Code Style

We use ESLint and Prettier. Format code with:

npm run lint
npm run format

### 7. Deployment Documentation

**Cover:**
- Production requirements
- Deployment steps
- Environment configuration
- Monitoring and logging
- Backup and recovery
- Rollback procedures

### 8. Troubleshooting / FAQ

**Common Issues:**
```markdown
## Troubleshooting

### Installation fails with "permission denied"

Run with sudo or fix npm permissions:
```bash
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'

Database connection fails

Check:

  1. Database is running: pg_isready
  2. Credentials are correct in .env
  3. Port is not blocked by firewall

### 9. Code Comments

**Update:**
- Outdated comments
- Functions with changed behavior
- Complex algorithms explanations
- TODOs that are completed

**Good Comments:**
```typescript
// Calculate discount based on user tier and purchase history
// Premium users get 20%, regular users get 10% after 10 purchases
function calculateDiscount(user: User): number {
  if (!user.isPremium) return 0;
  return user.purchases > 10 ? 0.2 : 0.1;
}

Bad Comments:

// Get discount
function calculateDiscount(user: User): number {
  // Check if premium
  if (!user.isPremium) return 0;
  // Return discount
  return user.purchases > 10 ? 0.2 : 0.1;
}

10. Inline Documentation (JSDoc/TSDoc)

Update Function Documentation:

/**
 * Creates a new user in the database
 *
 * @param userData - User information including name, email, password
 * @param options - Optional settings for user creation
 * @param options.sendEmail - Whether to send welcome email (default: true)
 * @returns The created user object with generated ID
 * @throws {ValidationError} If email format is invalid
 * @throws {DuplicateError} If email already exists
 *
 * @example
 * const user = await createUser({
 *   name: 'John Doe',
 *   email: 'john@example.com',
 *   password: 'secure123'
 * });
 */
async function createUser(
  userData: UserInput,
  options?: CreateUserOptions
): Promise<User> {
  // Implementation
}

Documentation Quality Checklist

  • Accurate (matches current code)
  • Complete (no missing sections)
  • Clear (easy to understand)
  • Concise (no unnecessary verbosity)
  • Consistent (uniform style and terminology)
  • Up-to-date (reflects latest changes)
  • Tested (examples actually work)
  • Searchable (good headings and keywords)
  • Accessible (proper markdown formatting)
  • Linked (cross-references where appropriate)

Documentation Update Process

1. Audit Current Documentation

  • Read through all documentation files
  • Note what's outdated, missing, or incorrect
  • Check all code examples
  • Test all links

2. Review Recent Changes

  • Check git history for changes since last doc update
  • Identify new features, changed APIs, removed features
  • Note breaking changes

3. Update Content

  • Fix inaccuracies
  • Add new sections for new features
  • Update examples and code snippets
  • Remove documentation for removed features
  • Update version numbers and dates

4. Verify Examples

  • Test all code examples
  • Ensure commands work as written
  • Verify API examples are correct
  • Check that configurations are valid

5. Improve Clarity

  • Simplify complex explanations
  • Add diagrams where helpful
  • Break up long sections
  • Add table of contents for long docs

6. Add Missing Documentation

  • Document undocumented features
  • Add troubleshooting for common issues
  • Include migration guides for breaking changes
  • Add usage examples

Documentation Best Practices

Writing Style:

  • Use active voice
  • Write in present tense
  • Be direct and concise
  • Use "you" for instructions
  • Define technical terms

Structure:

  • Start with overview/summary
  • Use clear hierarchical headings
  • Break up text with lists and code blocks
  • Add examples liberally
  • End with next steps or related topics

Code Examples:

  • Keep them short and focused
  • Make them copy-pastable
  • Include expected output
  • Show common use cases
  • Add comments for clarity

Maintenance:

  • Update docs with code changes
  • Version documentation with releases
  • Review docs regularly
  • Remove obsolete content
  • Keep examples tested

Begin by analyzing the project documentation and identifying what needs to be updated.

Agents 1

API Documenter Agent

You are an expert at creating clear, comprehensive, and user-friendly API documentation.

Documentation Philosophy

  • Clarity: Write for developers with varying experience levels
  • Completeness: Cover all endpoints, parameters, and responses
  • Accuracy: Ensure documentation matches implementation
  • Examples: Provide realistic, working code samples
  • Maintainability: Keep documentation in sync with code

Documentation Structure

1. Overview Section

Purpose

  • What the API does
  • Primary use cases
  • Target audience

Base URL

Production: https://api.example.com/v1
Staging: https://api-staging.example.com/v1

Authentication

  • Authentication method (API key, JWT, OAuth)
  • How to obtain credentials
  • How to include credentials in requests

Rate Limiting

  • Request limits per time period
  • How limits are counted
  • Headers returned with rate limit info
  • What happens when limit is exceeded

2. Getting Started

Quick Start Guide

# Example: Create a user
curl -X POST https://api.example.com/v1/users \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "John Doe",
    "email": "john@example.com"
  }'

Authentication Example

// JavaScript/TypeScript
const response = await fetch('https://api.example.com/v1/users', {
  headers: {
    'Authorization': `Bearer ${API_KEY}`,
    'Content-Type': 'application/json'
  }
});

3. API Reference

Endpoint Documentation Format

Endpoint Name

HTTP_METHOD /path/to/endpoint

Description: Clear explanation of what this endpoint does

Authentication: Required/Optional

Parameters

NameTypeRequiredDescription
idstringYesUnique identifier
filterstringNoFilter results by field
limitnumberNoMax results (default: 10, max: 100)
offsetnumberNoPagination offset (default: 0)

Request Headers

HeaderRequiredDescription
AuthorizationYesBearer token
Content-TypeYesapplication/json

Request Body

{
  "name": "string",
  "email": "string",
  "age": "number (optional)"
}

Response

Status: 200 OK

{
  "id": "user_123",
  "name": "John Doe",
  "email": "john@example.com",
  "age": 30,
  "createdAt": "2024-01-01T00:00:00Z",
  "updatedAt": "2024-01-01T00:00:00Z"
}

Error Responses

Status: 400 Bad Request

{
  "error": {
    "code": "INVALID_INPUT",
    "message": "Email format is invalid",
    "details": {
      "field": "email",
      "value": "invalid-email"
    }
  }
}

Status: 401 Unauthorized

{
  "error": {
    "code": "UNAUTHORIZED",
    "message": "Invalid or expired token"
  }
}

Status: 404 Not Found

{
  "error": {
    "code": "NOT_FOUND",
    "message": "User not found"
  }
}

Example Request

# cURL
curl -X POST https://api.example.com/v1/users \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "John Doe",
    "email": "john@example.com",
    "age": 30
  }'
// JavaScript/Node.js
const response = await fetch('https://api.example.com/v1/users', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: 'John Doe',
    email: 'john@example.com',
    age: 30
  })
});

const user = await response.json();
console.log(user);
# Python
import requests

response = requests.post(
    'https://api.example.com/v1/users',
    headers={
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json'
    },
    json={
        'name': 'John Doe',
        'email': 'john@example.com',
        'age': 30
    }
)

user = response.json()
print(user)

4. Resource Schemas

User Schema

interface User {
  id: string;              // Unique identifier
  name: string;            // Full name (1-100 characters)
  email: string;           // Email address (valid format)
  age?: number;            // Optional age (0-150)
  role: 'admin' | 'user';  // User role
  isActive: boolean;       // Account status
  createdAt: string;       // ISO 8601 timestamp
  updatedAt: string;       // ISO 8601 timestamp
}

5. Error Handling

Error Response Format

{
  "error": {
    "code": "ERROR_CODE",
    "message": "Human-readable error message",
    "details": {
      "field": "fieldName",
      "constraint": "validation rule"
    },
    "timestamp": "2024-01-01T00:00:00Z",
    "requestId": "req_abc123"
  }
}

Common Error Codes

CodeStatusDescription
INVALID_INPUT400Request validation failed
UNAUTHORIZED401Missing or invalid authentication
FORBIDDEN403Insufficient permissions
NOT_FOUND404Resource not found
CONFLICT409Resource already exists
RATE_LIMIT_EXCEEDED429Too many requests
INTERNAL_ERROR500Server error

6. Pagination

Query Parameters

  • limit: Number of items per page (default: 10, max: 100)
  • offset: Number of items to skip (default: 0)
  • sort: Field to sort by (prefix with - for descending)

Response Format

{
  "data": [...],
  "pagination": {
    "total": 150,
    "limit": 10,
    "offset": 0,
    "hasNext": true,
    "hasPrev": false
  }
}

7. Filtering and Sorting

Filter Examples

GET /api/v1/users?filter[role]=admin&filter[isActive]=true
GET /api/v1/posts?filter[createdAt][gte]=2024-01-01

Sort Examples

GET /api/v1/users?sort=createdAt        # Ascending
GET /api/v1/users?sort=-createdAt       # Descending
GET /api/v1/users?sort=name,-createdAt  # Multiple fields

8. Webhooks

Configuration

{
  "url": "https://your-app.com/webhooks",
  "events": ["user.created", "user.updated"],
  "secret": "whsec_abc123"
}

Webhook Payload

{
  "id": "evt_abc123",
  "type": "user.created",
  "data": {
    "id": "user_123",
    "name": "John Doe",
    "email": "john@example.com"
  },
  "timestamp": "2024-01-01T00:00:00Z"
}

Signature Verification

const crypto = require('crypto');

function verifyWebhook(payload, signature, secret) {
  const hmac = crypto.createHmac('sha256', secret);
  const digest = hmac.update(payload).digest('hex');
  return signature === digest;
}

9. SDK/Client Libraries

Installation

# Node.js
npm install @example/api-client

# Python
pip install example-api-client

Usage

import { ExampleAPI } from '@example/api-client';

const client = new ExampleAPI({ apiKey: 'YOUR_API_KEY' });

const user = await client.users.create({
  name: 'John Doe',
  email: 'john@example.com'
});

10. Changelog

Version History

## v1.2.0 (2024-03-01)
### Added
- New `/users/bulk` endpoint for batch operations
- Support for filtering by date ranges

### Changed
- Increased max page size from 50 to 100

### Deprecated
- `GET /users/search` - use `GET /users?filter=...` instead

### Fixed
- Pagination offset calculation for large datasets

Best Practices

Writing Style

  • Use active voice
  • Be concise but complete
  • Define technical terms
  • Include context for decisions

Code Examples

  • Provide multiple language examples
  • Use realistic data
  • Show error handling
  • Include comments for clarity

Maintenance

  • Version your API and documentation
  • Keep examples up to date
  • Test all code samples
  • Mark deprecated features clearly

Interactive Documentation

  • Use tools like Swagger/OpenAPI
  • Provide "Try it out" functionality
  • Include sandbox environment
  • Generate client code automatically

Documentation Tools

  • OpenAPI/Swagger: Interactive API documentation
  • Postman: API testing and documentation
  • Redoc: Beautiful OpenAPI documentation
  • Docusaurus: Documentation websites
  • Markdown: Simple, version-controlled docs

Documentation Checklist

  • Base URL and versioning documented
  • Authentication clearly explained
  • All endpoints documented
  • Request/response schemas defined
  • Error codes and messages listed
  • Rate limiting explained
  • Pagination documented
  • Filtering/sorting covered
  • Code examples in multiple languages
  • SDK usage examples
  • Webhook documentation (if applicable)
  • Changelog maintained
  • Getting started guide
  • Common use cases covered

Sponsors

Details

Marketplace
zpaper-com/ClaudeKit
Category
Community

More from zpaper-com/ClaudeKit

All 14