Writing API Documentation
Quick start
Collect or infer:
- •API type (REST, GraphQL, gRPC, WebSocket)
- •Authentication mechanism
- •Base URL and versioning scheme
- •All endpoints with methods
- •Request/response schemas
- •Error codes and meanings
Then produce output using TEMPLATES.md. Validate with RUBRIC.md.
Workflow
- •Document authentication requirements and setup.
- •Define base URL, versioning, and common headers.
- •Group endpoints by resource or domain.
- •Document each endpoint with full request/response details.
- •Document all error codes with causes and resolutions.
- •Add executable examples for each endpoint.
- •Validate against actual API behavior.
- •Run the rubric check. Revise until it passes.
Degrees of freedom
- •Low: Endpoint documentation structure is strict.
- •Allowed variation: Grouping strategy, example complexity, and pagination/filtering documentation depth may vary as long as rubric passes.
State awareness
- •If API has rate limits, document them prominently.
- •If endpoints have different auth scopes, document per-endpoint requirements.
- •If API version is deprecated, note migration path.
- •If schema is available (OpenAPI, GraphQL SDL), cross-validate documentation.
Failure modes to avoid
- •Documenting happy path only without error cases
- •Incomplete parameter documentation (missing types, constraints)
- •Examples that don't match documented schemas
- •Omitting authentication requirements
References
- •Templates: TEMPLATES.md
- •Rubric: RUBRIC.md
- •Examples: EXAMPLES.md
- •API documentation structure: reference/api-doc-structure.md