api-reference-documentation

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

API Reference Documentation

API参考文档

Create comprehensive API documentation for developer integration.
为开发者集成创建全面的API文档。

OpenAPI 3.0 Specification

OpenAPI 3.0 规范

yaml
openapi: 3.0.3
info:
  title: E-Commerce API
  version: 1.0.0
  description: API for managing products and orders
  contact:
    email: api@example.com

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

security:
  - bearerAuth: []

paths:
  /products:
    get:
      summary: List products
      tags: [Products]
      parameters:
        - name: limit
          in: query
          schema: { type: integer, default: 20 }
        - name: category
          in: query
          schema: { type: string }
      responses:
        '200':
          description: Product list
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProductList'

components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

  schemas:
    Product:
      type: object
      required: [id, name, price]
      properties:
        id: { type: string, format: uuid }
        name: { type: string, maxLength: 200 }
        price: { type: number, minimum: 0 }
        description: { type: string }
yaml
openapi: 3.0.3
info:
  title: E-Commerce API
  version: 1.0.0
  description: API for managing products and orders
  contact:
    email: api@example.com

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

security:
  - bearerAuth: []

paths:
  /products:
    get:
      summary: List products
      tags: [Products]
      parameters:
        - name: limit
          in: query
          schema: { type: integer, default: 20 }
        - name: category
          in: query
          schema: { type: string }
      responses:
        '200':
          description: Product list
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProductList'

components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

  schemas:
    Product:
      type: object
      required: [id, name, price]
      properties:
        id: { type: string, format: uuid }
        name: { type: string, maxLength: 200 }
        price: { type: number, minimum: 0 }
        description: { type: string }

Documentation Checklist

文档检查清单

  • All endpoints documented with examples
  • Authentication methods explained
  • Error responses specified
  • Rate limits documented
  • Pagination explained
  • Webhooks documented (if applicable)
  • SDK examples in multiple languages
  • 所有端点均附带示例文档
  • 已说明认证方法
  • 已指定错误响应
  • 已记录速率限制
  • 已说明分页机制
  • 已记录Webhook(如适用)
  • 提供多语言SDK示例

Best Practices

最佳实践

  • Use OpenAPI 3.0+ specification
  • Include request/response examples
  • Document all parameters and headers
  • Provide authentication examples
  • Enable interactive API exploration
  • Maintain version documentation
  • Include migration guides for breaking changes
  • 使用OpenAPI 3.0+规范
  • 包含请求/响应示例
  • 记录所有参数和请求头
  • 提供认证示例
  • 支持交互式API探索
  • 维护版本文档
  • 包含破坏性变更的迁移指南

Tools

工具

  • Swagger Editor / Swagger UI
  • Redoc
  • Postman Documentation
  • Stoplight
  • Swagger Editor / Swagger UI
  • Redoc
  • Postman Documentation
  • Stoplight