api-documentation-writer

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

API Documentation Writer Skill

API文档编写技能

Overview

概述

This skill helps you create clear, comprehensive API documentation that developers love. Covers OpenAPI/Swagger specifications, endpoint references, authentication guides, code examples in multiple languages, and developer experience best practices.
本技能可帮助你创建清晰全面、深受开发者喜爱的API文档。内容涵盖OpenAPI/Swagger规范、端点参考、多语言代码示例,以及提升开发者体验的最佳实践。

Documentation Philosophy

文档编写理念

The Three C's

三大核心原则

  1. Clear: Unambiguous, jargon-free explanations
  2. Complete: All parameters, responses, and edge cases documented
  3. Current: Always in sync with the actual API behavior
  1. 清晰(Clear):解释明确,无歧义,避免行话
  2. 完整(Complete):记录所有参数、响应和边缘情况
  3. 及时更新(Current):始终与API实际行为保持同步

What to Document

需要记录的内容

  • DO: Document every public endpoint
  • DO: Include request/response examples for all scenarios
  • DO: Document error codes with remediation steps
  • DO: Provide code examples in popular languages
  • DON'T: Document internal/private endpoints
  • DON'T: Assume readers know your domain
  • DON'T: Let documentation drift from implementation
  • 务必:记录所有公开端点
  • 务必:包含所有场景的请求/响应示例
  • 务必:记录错误代码及修复步骤
  • 务必:提供主流编程语言的代码示例
  • 请勿:记录内部/私有端点
  • 请勿:假设读者了解你的业务领域
  • 请勿:让文档与实现脱节

OpenAPI Specification

OpenAPI规范

Basic Structure

基础结构

yaml
undefined
yaml
undefined

openapi.yaml

openapi.yaml

openapi: 3.1.0 info: title: My API version: 1.0.0 description: | Welcome to the My API documentation.
## Getting Started
1. Sign up for an API key at [dashboard.example.com](https://dashboard.example.com)
2. Include your key in the `Authorization` header
3. Start making requests!

## Rate Limits
- Free tier: 100 requests/minute
- Pro tier: 1000 requests/minute
contact: name: API Support email: api@example.com url: https://support.example.com license: name: MIT url: https://opensource.org/licenses/MIT
servers:
tags:
  • name: Users description: User management operations
  • name: Items description: Item CRUD operations
undefined
openapi: 3.1.0 info: title: My API version: 1.0.0 description: | Welcome to the My API documentation.
## Getting Started
1. Sign up for an API key at [dashboard.example.com](https://dashboard.example.com)
2. Include your key in the `Authorization` header
3. Start making requests!

## Rate Limits
- Free tier: 100 requests/minute
- Pro tier: 1000 requests/minute
contact: name: API Support email: api@example.com url: https://support.example.com license: name: MIT url: https://opensource.org/licenses/MIT
servers:
tags:
  • name: Users description: User management operations
  • name: Items description: Item CRUD operations
undefined

Endpoint Documentation

端点文档

yaml
paths:
  /users:
    get:
      tags:
        - Users
      summary: List all users
      description: |
        Retrieves a paginated list of users. Results are sorted by creation date (newest first).

        **Permissions required:** `users:read`
      operationId: listUsers
      parameters:
        - name: page
          in: query
          description: Page number (1-indexed)
          required: false
          schema:
            type: integer
            minimum: 1
            default: 1
          example: 1
        - name: limit
          in: query
          description: Number of results per page (max 100)
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 20
          example: 20
        - name: status
          in: query
          description: Filter by user status
          required: false
          schema:
            type: string
            enum: [active, inactive, pending]
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserList'
              example:
                data:
                  - id: "usr_123"
                    email: "john@example.com"
                    name: "John Doe"
                    status: "active"
                    created_at: "2024-01-15T10:30:00Z"
                meta:
                  page: 1
                  limit: 20
                  total: 150
                  total_pages: 8
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/RateLimited'

    post:
      tags:
        - Users
      summary: Create a new user
      description: |
        Creates a new user account. An email verification will be sent to the provided address.

        **Permissions required:** `users:write`
      operationId: createUser
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateUserRequest'
            examples:
              basic:
                summary: Basic user creation
                value:
                  email: "jane@example.com"
                  name: "Jane Doe"
              with_metadata:
                summary: User with metadata
                value:
                  email: "jane@example.com"
                  name: "Jane Doe"
                  metadata:
                    department: "Engineering"
                    role: "Developer"
      responses:
        '201':
          description: User created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        '400':
          $ref: '#/components/responses/BadRequest'
        '409':
          description: User with this email already exists
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: "USER_EXISTS"
                  message: "A user with this email already exists"
yaml
paths:
  /users:
    get:
      tags:
        - Users
      summary: List all users
      description: |
        Retrieves a paginated list of users. Results are sorted by creation date (newest first).

        **Permissions required:** `users:read`
      operationId: listUsers
      parameters:
        - name: page
          in: query
          description: Page number (1-indexed)
          required: false
          schema:
            type: integer
            minimum: 1
            default: 1
          example: 1
        - name: limit
          in: query
          description: Number of results per page (max 100)
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 20
          example: 20
        - name: status
          in: query
          description: Filter by user status
          required: false
          schema:
            type: string
            enum: [active, inactive, pending]
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserList'
              example:
                data:
                  - id: "usr_123"
                    email: "john@example.com"
                    name: "John Doe"
                    status: "active"
                    created_at: "2024-01-15T10:30:00Z"
                meta:
                  page: 1
                  limit: 20
                  total: 150
                  total_pages: 8
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/RateLimited'

    post:
      tags:
        - Users
      summary: Create a new user
      description: |
        Creates a new user account. An email verification will be sent to the provided address.

        **Permissions required:** `users:write`
      operationId: createUser
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateUserRequest'
            examples:
              basic:
                summary: Basic user creation
                value:
                  email: "jane@example.com"
                  name: "Jane Doe"
              with_metadata:
                summary: User with metadata
                value:
                  email: "jane@example.com"
                  name: "Jane Doe"
                  metadata:
                    department: "Engineering"
                    role: "Developer"
      responses:
        '201':
          description: User created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        '400':
          $ref: '#/components/responses/BadRequest'
        '409':
          description: User with this email already exists
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: "USER_EXISTS"
                  message: "A user with this email already exists"

Schema Definitions

模式定义

yaml
components:
  schemas:
    User:
      type: object
      description: Represents a user in the system
      required:
        - id
        - email
        - status
        - created_at
      properties:
        id:
          type: string
          description: Unique identifier (prefixed with `usr_`)
          pattern: '^usr_[a-zA-Z0-9]+$'
          example: "usr_123abc"
        email:
          type: string
          format: email
          description: User's email address (unique)
          example: "user@example.com"
        name:
          type: string
          description: User's display name
          maxLength: 100
          example: "John Doe"
        status:
          type: string
          enum: [active, inactive, pending]
          description: |
            Account status:
            - `active`: User can sign in and use the service
            - `inactive`: Account has been deactivated
            - `pending`: Awaiting email verification
          example: "active"
        metadata:
          type: object
          additionalProperties: true
          description: Custom key-value pairs for storing additional data
          example:
            department: "Engineering"
        created_at:
          type: string
          format: date-time
          description: ISO 8601 timestamp of account creation
          example: "2024-01-15T10:30:00Z"
        updated_at:
          type: string
          format: date-time
          description: ISO 8601 timestamp of last update
          example: "2024-01-16T14:45:00Z"

    CreateUserRequest:
      type: object
      required:
        - email
      properties:
        email:
          type: string
          format: email
          description: Email address for the new user (must be unique)
        name:
          type: string
          description: User's display name
          maxLength: 100
        metadata:
          type: object
          additionalProperties: true

    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              description: Machine-readable error code
            message:
              type: string
              description: Human-readable error description
            details:
              type: array
              description: Additional error details for validation errors
              items:
                type: object
                properties:
                  field:
                    type: string
                  message:
                    type: string
yaml
components:
  schemas:
    User:
      type: object
      description: Represents a user in the system
      required:
        - id
        - email
        - status
        - created_at
      properties:
        id:
          type: string
          description: Unique identifier (prefixed with `usr_`)
          pattern: '^usr_[a-zA-Z0-9]+$'
          example: "usr_123abc"
        email:
          type: string
          format: email
          description: User's email address (unique)
          example: "user@example.com"
        name:
          type: string
          description: User's display name
          maxLength: 100
          example: "John Doe"
        status:
          type: string
          enum: [active, inactive, pending]
          description: |
            Account status:
            - `active`: User can sign in and use the service
            - `inactive`: Account has been deactivated
            - `pending`: Awaiting email verification
          example: "active"
        metadata:
          type: object
          additionalProperties: true
          description: Custom key-value pairs for storing additional data
          example:
            department: "Engineering"
        created_at:
          type: string
          format: date-time
          description: ISO 8601 timestamp of account creation
          example: "2024-01-15T10:30:00Z"
        updated_at:
          type: string
          format: date-time
          description: ISO 8601 timestamp of last update
          example: "2024-01-16T14:45:00Z"

    CreateUserRequest:
      type: object
      required:
        - email
      properties:
        email:
          type: string
          format: email
          description: Email address for the new user (must be unique)
        name:
          type: string
          description: User's display name
          maxLength: 100
        metadata:
          type: object
          additionalProperties: true

    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              description: Machine-readable error code
            message:
              type: string
              description: Human-readable error description
            details:
              type: array
              description: Additional error details for validation errors
              items:
                type: object
                properties:
                  field:
                    type: string
                  message:
                    type: string

Authentication Documentation

认证文档

yaml
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: |
        JWT token obtained from the `/auth/token` endpoint.

        Include in requests as:
        ```
        Authorization: Bearer <your-token>
        ```

        Tokens expire after 1 hour. Use refresh tokens for long-lived sessions.

    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: |
        API key for server-to-server communication.

        Obtain your key from the [Developer Dashboard](https://dashboard.example.com).

        Include in requests as:
        ```
        X-API-Key: <your-api-key>
        ```

security:
  - BearerAuth: []
  - ApiKeyAuth: []
yaml
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: |
        JWT token obtained from the `/auth/token` endpoint.

        Include in requests as:
        ```
        Authorization: Bearer <your-token>
        ```

        Tokens expire after 1 hour. Use refresh tokens for long-lived sessions.

    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: |
        API key for server-to-server communication.

        Obtain your key from the [Developer Dashboard](https://dashboard.example.com).

        Include in requests as:
        ```
        X-API-Key: <your-api-key>
        ```

security:
  - BearerAuth: []
  - ApiKeyAuth: []

Reusable Responses

可复用响应

yaml
components:
  responses:
    BadRequest:
      description: Invalid request parameters
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            validation_error:
              summary: Validation error
              value:
                error:
                  code: "VALIDATION_ERROR"
                  message: "Request validation failed"
                  details:
                    - field: "email"
                      message: "Must be a valid email address"
            missing_field:
              summary: Missing required field
              value:
                error:
                  code: "MISSING_FIELD"
                  message: "Required field 'email' is missing"

    Unauthorized:
      description: Missing or invalid authentication
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: "UNAUTHORIZED"
              message: "Invalid or expired authentication token"

    Forbidden:
      description: Insufficient permissions
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: "FORBIDDEN"
              message: "You don't have permission to access this resource"

    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: "NOT_FOUND"
              message: "The requested resource was not found"

    RateLimited:
      description: Rate limit exceeded
      headers:
        X-RateLimit-Limit:
          schema:
            type: integer
          description: Request limit per minute
        X-RateLimit-Remaining:
          schema:
            type: integer
          description: Remaining requests in current window
        X-RateLimit-Reset:
          schema:
            type: integer
          description: Unix timestamp when the rate limit resets
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: "RATE_LIMITED"
              message: "Too many requests. Please retry after 60 seconds"
yaml
components:
  responses:
    BadRequest:
      description: Invalid request parameters
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            validation_error:
              summary: Validation error
              value:
                error:
                  code: "VALIDATION_ERROR"
                  message: "Request validation failed"
                  details:
                    - field: "email"
                      message: "Must be a valid email address"
            missing_field:
              summary: Missing required field
              value:
                error:
                  code: "MISSING_FIELD"
                  message: "Required field 'email' is missing"

    Unauthorized:
      description: Missing or invalid authentication
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: "UNAUTHORIZED"
              message: "Invalid or expired authentication token"

    Forbidden:
      description: Insufficient permissions
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: "FORBIDDEN"
              message: "You don't have permission to access this resource"

    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: "NOT_FOUND"
              message: "The requested resource was not found"

    RateLimited:
      description: Rate limit exceeded
      headers:
        X-RateLimit-Limit:
          schema:
            type: integer
          description: Request limit per minute
        X-RateLimit-Remaining:
          schema:
            type: integer
          description: Remaining requests in current window
        X-RateLimit-Reset:
          schema:
            type: integer
          description: Unix timestamp when the rate limit resets
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: "RATE_LIMITED"
              message: "Too many requests. Please retry after 60 seconds"

Markdown Documentation

Markdown文档

Endpoint Reference Template

端点参考模板

markdown
undefined
markdown
undefined

Create User

Create User

Create a new user account.
Create a new user account.

Endpoint

Endpoint

POST /v1/users
POST /v1/users

Authentication

Authentication

Requires API key with
users:write
permission.
Requires API key with
users:write
permission.

Request Body

Request Body

FieldTypeRequiredDescription
email
stringYesUser's email address (must be unique)
name
stringNoDisplay name (max 100 characters)
metadata
objectNoCustom key-value pairs
FieldTypeRequiredDescription
email
stringYesUser's email address (must be unique)
name
stringNoDisplay name (max 100 characters)
metadata
objectNoCustom key-value pairs

Example Request

Example Request

bash
curl -X POST https://api.example.com/v1/users \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "jane@example.com",
    "name": "Jane Doe"
  }'
bash
curl -X POST https://api.example.com/v1/users \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "jane@example.com",
    "name": "Jane Doe"
  }'

Response

Response

Success (201 Created)

Success (201 Created)

json
{
  "id": "usr_abc123",
  "email": "jane@example.com",
  "name": "Jane Doe",
  "status": "pending",
  "created_at": "2024-01-15T10:30:00Z"
}
json
{
  "id": "usr_abc123",
  "email": "jane@example.com",
  "name": "Jane Doe",
  "status": "pending",
  "created_at": "2024-01-15T10:30:00Z"
}

Errors

Errors

StatusCodeDescription
400
VALIDATION_ERROR
Invalid email format or missing required field
401
UNAUTHORIZED
Invalid or missing authentication
409
USER_EXISTS
User with this email already exists
429
RATE_LIMITED
Too many requests
StatusCodeDescription
400
VALIDATION_ERROR
Invalid email format or missing required field
401
UNAUTHORIZED
Invalid or missing authentication
409
USER_EXISTS
User with this email already exists
429
RATE_LIMITED
Too many requests

Error Example

Error Example

json
{
  "error": {
    "code": "USER_EXISTS",
    "message": "A user with this email already exists"
  }
}
undefined
json
{
  "error": {
    "code": "USER_EXISTS",
    "message": "A user with this email already exists"
  }
}
undefined

Code Examples

代码示例

Multi-Language Examples

多语言示例

markdown
undefined
markdown
undefined

Code Examples

Code Examples

cURL

cURL

bash
curl -X GET "https://api.example.com/v1/users?limit=10" \
  -H "Authorization: Bearer YOUR_TOKEN"
bash
curl -X GET "https://api.example.com/v1/users?limit=10" \
  -H "Authorization: Bearer YOUR_TOKEN"

JavaScript (fetch)

JavaScript (fetch)

javascript
const response = await fetch('https://api.example.com/v1/users?limit=10', {
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN'
  }
});

const data = await response.json();
console.log(data);
javascript
const response = await fetch('https://api.example.com/v1/users?limit=10', {
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN'
  }
});

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

JavaScript (axios)

JavaScript (axios)

javascript
import axios from 'axios';

const { data } = await axios.get('https://api.example.com/v1/users', {
  params: { limit: 10 },
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN'
  }
});
javascript
import axios from 'axios';

const { data } = await axios.get('https://api.example.com/v1/users', {
  params: { limit: 10 },
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN'
  }
});

Python

Python

python
import requests

response = requests.get(
    'https://api.example.com/v1/users',
    params={'limit': 10},
    headers={'Authorization': 'Bearer YOUR_TOKEN'}
)

data = response.json()
print(data)
python
import requests

response = requests.get(
    'https://api.example.com/v1/users',
    params={'limit': 10},
    headers={'Authorization': 'Bearer YOUR_TOKEN'}
)

data = response.json()
print(data)

Ruby

Ruby

ruby
require 'net/http'
require 'json'

uri = URI('https://api.example.com/v1/users?limit=10')
request = Net::HTTP::Get.new(uri)
request['Authorization'] = 'Bearer YOUR_TOKEN'

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
  http.request(request)
end

data = JSON.parse(response.body)
puts data
ruby
require 'net/http'
require 'json'

uri = URI('https://api.example.com/v1/users?limit=10')
request = Net::HTTP::Get.new(uri)
request['Authorization'] = 'Bearer YOUR_TOKEN'

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
  http.request(request)
end

data = JSON.parse(response.body)
puts data

Go

Go

go
package main

import (
    "encoding/json"
    "fmt"
    "net/http"
)

func main() {
    req, _ := http.NewRequest("GET", "https://api.example.com/v1/users?limit=10", nil)
    req.Header.Set("Authorization", "Bearer YOUR_TOKEN")

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()

    var data map[string]interface{}
    json.NewDecoder(resp.Body).Decode(&data)
    fmt.Println(data)
}
undefined
go
package main

import (
    "encoding/json"
    "fmt"
    "net/http"
)

func main() {
    req, _ := http.NewRequest("GET", "https://api.example.com/v1/users?limit=10", nil)
    req.Header.Set("Authorization", "Bearer YOUR_TOKEN")

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()

    var data map[string]interface{}
    json.NewDecoder(resp.Body).Decode(&data)
    fmt.Println(data)
}
undefined

Error Documentation

错误文档

Error Code Reference

错误代码参考

markdown
undefined
markdown
undefined

Error Codes

Error Codes

All API errors follow a consistent format:
json
{
  "error": {
    "code": "ERROR_CODE",
    "message": "Human-readable description",
    "details": []  // Optional additional information
  }
}
All API errors follow a consistent format:
json
{
  "error": {
    "code": "ERROR_CODE",
    "message": "Human-readable description",
    "details": []  // Optional additional information
  }
}

Authentication Errors

Authentication Errors

CodeHTTP StatusDescriptionResolution
UNAUTHORIZED
401Missing or invalid tokenInclude a valid
Authorization
header
TOKEN_EXPIRED
401Token has expiredObtain a new token via
/auth/token
INVALID_API_KEY
401API key not recognizedCheck your API key in the dashboard
FORBIDDEN
403Insufficient permissionsRequest appropriate scopes for your token
CodeHTTP StatusDescriptionResolution
UNAUTHORIZED
401Missing or invalid tokenInclude a valid
Authorization
header
TOKEN_EXPIRED
401Token has expiredObtain a new token via
/auth/token
INVALID_API_KEY
401API key not recognizedCheck your API key in the dashboard
FORBIDDEN
403Insufficient permissionsRequest appropriate scopes for your token

Validation Errors

Validation Errors

CodeHTTP StatusDescriptionResolution
VALIDATION_ERROR
400Request body validation failedCheck the
details
array for specific fields
MISSING_FIELD
400Required field not providedInclude all required fields
INVALID_FORMAT
400Field format is incorrectMatch the expected format (see schema)
CodeHTTP StatusDescriptionResolution
VALIDATION_ERROR
400Request body validation failedCheck the
details
array for specific fields
MISSING_FIELD
400Required field not providedInclude all required fields
INVALID_FORMAT
400Field format is incorrectMatch the expected format (see schema)

Resource Errors

Resource Errors

CodeHTTP StatusDescriptionResolution
NOT_FOUND
404Resource doesn't existVerify the resource ID is correct
ALREADY_EXISTS
409Resource already existsUse a different identifier or update existing
CONFLICT
409State conflictRefresh and retry the operation
CodeHTTP StatusDescriptionResolution
NOT_FOUND
404Resource doesn't existVerify the resource ID is correct
ALREADY_EXISTS
409Resource already existsUse a different identifier or update existing
CONFLICT
409State conflictRefresh and retry the operation

Rate Limiting

Rate Limiting

CodeHTTP StatusDescriptionResolution
RATE_LIMITED
429Too many requestsWait and retry (see
Retry-After
header)
undefined
CodeHTTP StatusDescriptionResolution
RATE_LIMITED
429Too many requestsWait and retry (see
Retry-After
header)
undefined

Changelog Documentation

变更日志文档

API Changelog Format

API变更日志格式

markdown
undefined
markdown
undefined

API Changelog

API Changelog

2024-01-15 - v1.2.0

2024-01-15 - v1.2.0

Added

Added

  • GET /users/{id}/activity
    - Retrieve user activity history
  • metadata
    field on User object for custom data storage
  • GET /users/{id}/activity
    - Retrieve user activity history
  • metadata
    field on User object for custom data storage

Changed

Changed

  • Pagination now 1-indexed (previously 0-indexed)
  • Rate limits increased: Free tier 100 → 200 req/min
  • Pagination now 1-indexed (previously 0-indexed)
  • Rate limits increased: Free tier 100 → 200 req/min

Deprecated

Deprecated

  • GET /users/search
    - Use
    GET /users
    with query parameters instead
    • Will be removed in v2.0.0
  • GET /users/search
    - Use
    GET /users
    with query parameters instead
    • Will be removed in v2.0.0

Fixed

Fixed

  • created_at
    now correctly returns UTC timezone

  • created_at
    now correctly returns UTC timezone

2024-01-01 - v1.1.0

2024-01-01 - v1.1.0

Added

Added

  • Webhook support for user events
  • status
    filter on
    GET /users
  • Webhook support for user events
  • status
    filter on
    GET /users

Security

Security

  • API keys now support IP allowlisting
undefined
  • API keys now support IP allowlisting
undefined

Interactive Documentation

交互式文档

Swagger UI Configuration

Swagger UI配置

javascript
// swagger-config.js
const swaggerUiOptions = {
  customCss: '.swagger-ui .topbar { display: none }',
  customSiteTitle: 'API Documentation',
  customfavIcon: '/favicon.ico',
  swaggerOptions: {
    persistAuthorization: true,
    displayRequestDuration: true,
    filter: true,
    tryItOutEnabled: true,
  },
};
javascript
// swagger-config.js
const swaggerUiOptions = {
  customCss: '.swagger-ui .topbar { display: none }',
  customSiteTitle: 'API Documentation',
  customfavIcon: '/favicon.ico',
  swaggerOptions: {
    persistAuthorization: true,
    displayRequestDuration: true,
    filter: true,
    tryItOutEnabled: true,
  },
};

Redoc Configuration

Redoc配置

yaml
undefined
yaml
undefined

redoc.yaml

redoc.yaml

x-tagGroups:
  • name: Getting Started tags:
    • Authentication
  • name: Core Resources tags:
    • Users
    • Items
  • name: Utilities tags:
    • Webhooks
    • Health
x-logo: url: 'https://example.com/logo.png' altText: 'API Logo'
undefined
x-tagGroups:
  • name: Getting Started tags:
    • Authentication
  • name: Core Resources tags:
    • Users
    • Items
  • name: Utilities tags:
    • Webhooks
    • Health
x-logo: url: 'https://example.com/logo.png' altText: 'API Logo'
undefined

Documentation Checklist

文档检查清单

Per Endpoint

单端点检查项

  • Summary (one line)
  • Description (detailed explanation)
  • All parameters documented with types and examples
  • All response codes with examples
  • Error codes with remediation steps
  • Code examples in at least 2 languages
  • Authentication requirements stated
  • 摘要(一行描述)
  • 详细说明
  • 所有参数均记录类型和示例
  • 所有响应码均附带示例
  • 错误码及修复步骤
  • 至少2种语言的代码示例
  • 明确认证要求

Overall API

整体API检查项

  • Getting started guide
  • Authentication guide with examples
  • Rate limiting documentation
  • Pagination patterns
  • Error handling guide
  • Changelog maintained
  • Versioning strategy documented
  • SDK/library links
  • 快速入门指南
  • 带示例的认证指南
  • 限流规则文档
  • 分页模式说明
  • 错误处理指南
  • 维护变更日志
  • 版本策略文档
  • SDK/库链接

Developer Experience

开发者体验检查项

  • Interactive "Try It" functionality
  • Copy-paste ready examples
  • Consistent terminology
  • Search functionality
  • Mobile-friendly rendering
  • 交互式"试用"功能
  • 可直接复制粘贴的示例
  • 术语一致
  • 搜索功能
  • 移动端适配

Tools Integration

工具集成

Generate from Code

从代码生成文档

bash
undefined
bash
undefined

From Express/Node.js routes

From Express/Node.js routes

npx swagger-jsdoc -d swaggerDef.js -o openapi.yaml
npx swagger-jsdoc -d swaggerDef.js -o openapi.yaml

From TypeScript types

From TypeScript types

npx openapi-typescript-codegen --input openapi.yaml --output ./sdk
undefined
npx openapi-typescript-codegen --input openapi.yaml --output ./sdk
undefined

Validate OpenAPI

验证OpenAPI规范

bash
undefined
bash
undefined

Validate spec

Validate spec

npx @redocly/cli lint openapi.yaml
npx @redocly/cli lint openapi.yaml

Preview documentation

Preview documentation

npx @redocly/cli preview-docs openapi.yaml
undefined
npx @redocly/cli preview-docs openapi.yaml
undefined

When to Use This Skill

何时使用本技能

Invoke this skill when:
  • Creating new API documentation from scratch
  • Adding documentation for new endpoints
  • Writing OpenAPI/Swagger specifications
  • Creating code examples for multiple languages
  • Documenting authentication flows
  • Building developer portals
  • Improving existing API documentation
  • Setting up interactive documentation (Swagger UI, Redoc)
在以下场景调用本技能:
  • 从零开始创建新的API文档
  • 为新增端点添加文档
  • 编写OpenAPI/Swagger规范
  • 创建多语言代码示例
  • 记录认证流程
  • 搭建开发者门户
  • 优化现有API文档
  • 设置交互式文档(Swagger UI、Redoc)