API Documentation
API documentation describes how developers interact with an API: its endpoints, parameters, authentication, error codes, and usage patterns. Good documentation reduces integration time and support load by making the contract discoverable and self-explanatory.
itTechnical communication and collaboration | OpenSkills.info
Intro
API Documentation
API documentation is the working interface between an API and the people who use it. The API defines behavior. The documentation helps a reader discover that behavior, understand it, and apply it correctly.
A generated endpoint list is only one part of the job. Readers also need an entry point, a successful first request, task guidance, explanations, and accurate reference material. Each part answers a different question.
Start with the reader's situation
Before you write, identify the reader and the job they need to complete. A new evaluator asks what the API does and whether it fits. A new consumer asks how to authenticate and make a first request. An active consumer looks for one operation, field, error, or limit. A maintainer asks what changed.
Do not force every reader through one long page. Give each situation a clear route:
- A tutorial creates a safe learning experience.
- A how-to guide helps a competent reader complete a task.
- Reference material describes the API accurately and consistently.
- Explanation provides context, reasons, and relationships.
These content types support each other. They should link to each other without merging into one undifferentiated document.
Build a useful entry point
The overview states the API's purpose, intended consumers, major capabilities, and limits. It also identifies the protocol, production and test environments, version policy, support route, and terms of use when those details apply.
The getting-started path should lead to one small success. State prerequisites first. Show how to obtain credentials without exposing real credentials. Then provide a complete request, a representative response, and a short explanation of the result.
Use reserved example values and obvious placeholders. Keep secrets out of repositories, screenshots, logs, URLs, and copied examples. A reader should know exactly which values to replace and where to obtain them.
Make reference pages predictable
Reference material follows the API's structure. For an HTTP API, a useful operation page commonly includes:
- Method and path
- Purpose and required permissions
- Path, query, header, and cookie parameters
- Request headers and body schema
- Response status codes, headers, and body schemas
- Error conditions and correction guidance
- Pagination, rate-limit, retry, and idempotency behavior when relevant
- Deprecation and version information
- Tested request and response examples
Define every public element that affects a consumer. Explain types, formats, constraints, defaults, null behavior, and whether a field is required. A name such as status does not explain its allowed values or state transitions.
Keep repeated behavior in one canonical topic. Link to it from affected operations. Copying authentication or pagination rules across many pages makes inconsistent updates likely.
Document authentication without leaking credentials
Authentication documentation must connect the mechanism to a complete request. State how a reader obtains a credential, where the request carries it, which permissions it needs, and what common failures look like.
Use placeholders such as YOUR_TOKEN. Never publish a working token. Explain secure storage and least-privilege choices in the relevant task guidance. Separate authentication from authorization. A valid credential does not imply permission for every operation.
Show requests, responses, and failures together
A request example needs enough context to run. Include the target environment, method, URL, relevant headers, and body. Explain placeholders near the example. If setup is substantial, link to a focused setup procedure.
Pair the request with a realistic response. Show the status code, important headers, and body. Label sample output as representative when values can change.
Document failures as part of normal use. For each important error, state the triggering condition, observable status and body, and corrective action. Preserve HTTP meaning. For example, 401 Unauthorized concerns missing or invalid authentication credentials. 403 Forbidden means the server refuses the action.
Collection operations also need a complete traversal story. Document page-size controls, continuation links or tokens, ordering, and termination. Do not make the reader infer pagination from one truncated response.
Treat examples as executable assets
Examples teach the contract faster than prose, but stale examples teach the wrong contract. Prefer small examples that demonstrate one task. Include required imports, dependencies, and setup when the sample needs them.
Test requests, responses, and code samples against the same API version the page describes. Validate example payloads against their schemas. Redact secrets and personal data. Use comments to mark omitted code, so a reader can distinguish an excerpt from a runnable sample.
Use a machine-readable description with human guidance
OpenAPI provides a language-independent description format for HTTP APIs. It can describe paths, operations, parameters, request bodies, responses, schemas, examples, and security requirements. Tools can use that description to generate reference pages, validate traffic, create tests, or generate client code.
The description is a source, not the whole documentation experience. It does not decide the reader's goal, explain domain concepts, create a safe tutorial, or verify that an example works. Add human-authored guidance around the generated reference.
Keep generated reference content and implementation behavior tied to the same source of truth. Review descriptions as part of API changes. A build can check syntax and links, but a reviewer still needs to check meaning, completeness, and usability.
Design for access and navigation
API documentation is web content. Use descriptive headings, meaningful link text, text alternatives for informative images, and a programmatically understandable reading order. Do not encode meaning through color or layout alone.
Provide search terms that match the API's public names. Use stable anchors for operations and fields. Add links between concepts, tasks, and reference pages so readers can change modes without losing context.
Maintain the documentation as part of the API
Assign ownership for each source and generated artifact. Update documentation in the same change that updates public behavior. Review renamed fields, new permissions, revised limits, changed examples, and deprecations before release.
Track freshness signals such as version labels, last-verified dates, failed sample tests, broken links, support questions, and search terms with poor results. These signals reveal different problems. A passing build does not prove that a reader can complete a task.
Limits
Documentation cannot repair an incoherent or unstable API. It can expose ambiguity, but design and implementation owners must resolve the contract.
A schema cannot capture every operational fact. Rate limits, authorization rules, side effects, eventual consistency, and recovery steps may need explicit prose and examples.
Generated reference reduces repetitive work. It does not replace audience research, task design, explanation, editorial review, accessibility testing, or sample verification.
Route to competence
Start by mapping readers and their tasks. Write one successful getting-started path next. Then complete the reference for the operations that path uses. Add focused how-to guides for common work and explanations for the concepts that cause mistakes.
After the core set works, automate schema validation, sample tests, link checks, and publication. Study real support and search behavior. Use that evidence to improve navigation, coverage, and accuracy.
Where this skill leads
Relevant careers
See how this topic contributes to broader role-level skill maps.
Sources
- https://diataxis.fr/start-here/
Supports
- Tutorials, how-to guides, reference, and explanation as four documentation types with distinct purposes
- Tutorials and explanation for study, with how-to guides and reference for work
- Reference structure reflecting the structure of the documented system
- https://diataxis.fr/tutorials/
Supports
- Tutorials as practical learning experiences with managed steps and a successful conclusion
- https://google.aip.dev/192
Supports
- Clear, complete, and unambiguous public API descriptions
- CommonMark formatting, cross-references, external links, and deprecation guidance for API comments
- Public comments for API components in the protocol buffer context covered by the standard
- https://developers.google.com/style/api-reference-comments
Supports
- Complete reference coverage for public types, members, methods, parameters, return values, and exceptions
- Concise purpose statements, usage guidance, prerequisites, pitfalls, and related APIs
- Short code samples near reference descriptions as a general recommendation
- https://developers.google.com/style/procedures
Supports
- Numbered, imperative, ordered steps for multi-step procedures
- Explicit context, goals, results, justifications, and optional-step labeling
- Referencing repeated procedures instead of duplicating them
- https://developers.google.com/style/code-samples
Supports
- Code sample formatting and introductory statements
- Language comments to indicate omitted code
- Language-specific style guidance and readable line length
- https://spec.openapis.org/oas/v3.2.0.html
Supports
- OpenAPI 3.2.0 as a language-independent description format for HTTP APIs
- Metadata, servers, paths, operations, parameters, request bodies, responses, schemas, examples, and security requirements
- External documentation links and tooling uses such as documentation generation, testing, routing, and client generation
- Specification text as authoritative when an informational schema disagrees or misses a violation
- https://spec.openapis.org/oas/
Supports
- Published OpenAPI specification versions and current schema revision guidance
- https://www.rfc-editor.org/rfc/rfc9110.html
Supports
- HTTP method, status code, representation, authentication challenge, validator, and conditional request semantics
- Meanings of 200, 201, 202, 204, 400, 401, 403, 404, and 409 status codes
- https://www.rfc-editor.org/rfc/rfc6585.html
Supports
- 429 Too Many Requests semantics and optional Retry-After guidance
- https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api
Supports
- A maintained first-use path connecting authentication, headers, requests, responses, and follow-on tasks
- Complete request examples with token placeholders and API version headers
- https://docs.github.com/en/rest/authentication/authenticating-to-the-rest-api
Supports
- Token acquisition choices, Authorization header placement, endpoint permissions, and authentication failures
- Explicit token placeholders in request examples
- https://docs.github.com/en/rest/authentication
Supports
- A canonical authentication collection linking credential use, credential security, and permission references
- https://docs.github.com/en/rest/authentication/keeping-your-api-credentials-secure
Supports
- Appropriate credential selection, limited permissions, secure storage, and remediation planning
- https://docs.github.com/en/rest/using-the-rest-api/using-pagination-in-the-rest-api
Supports
- Paginated result subsets, Link response headers, page-size controls, and traversal examples
- Endpoint-specific pagination query forms and link-driven navigation
- https://docs.github.com/en/rest/using-the-rest-api
Supports
- A real documentation collection connecting getting started, authentication, rate limits, pagination, best practices, and troubleshooting
- https://www.w3.org/TR/WCAG22/
Supports
- WCAG 2.2 as testable, technology-independent accessibility criteria for web content
- Text alternatives, programmatic structure, meaningful sequence, descriptive headings and labels, link purpose, keyboard access, and language identification
