API reference docs
Reference docs answer "how do I call this exactly": every endpoint,
parameter, response, and error. The winning approach blends generation
(complete, never drifts) with curation (examples and guidance a
generator cannot produce), because pure generation is complete but
useless and pure hand-writing is helpful but stale.
Method
- Generate the skeleton from the source of truth. From
the OpenAPI/GraphQL schema, proto, or code annotations
(see openapi-contracts, graphql-schema-design):
endpoints, parameters, types, and required/optional
status stay complete and in sync with the actual API
because they come from it. Hand-maintained parameter
lists drift the first time someone adds a field.
- Curate what generation cannot express. Every endpoint
needs a realistic example (request and response, with
real-looking values), a one-line "when to use this", and
the non-obvious behavior (side effects, rate limits,
pagination: see api-pagination-design, rate-limiting).
The generated schema says a field is a string; the
curated note says what string and why.
- Document every error, not just the happy path. What
errors each endpoint returns, what causes them, and how
to fix them (see api-error-responses): error docs are
what turn a support ticket into a self-service fix.
Reference docs that only describe success leave the
consumer stranded exactly when they need help.
- Show authentication and the first real call. How to
authenticate (see authn-design, oauth-flows), then a
complete working example from zero to a successful
response: the reference doubles as the quickstart's
detailed backing (see readme-writing's quickstart, which
links here). A reference nobody can make their first
call from has failed at its one job.
- Keep examples tested and current. Runnable, verified
examples (see docs-as-code: run them in CI so a breaking
change fails the docs build too): a copy-pasted example
that errors is worse than none, because it destroys
trust in the whole reference. This is the discipline
that keeps generated-plus-curated honest.
- Version the reference with the API. Consumers on
different versions need the docs for their version
(see api-versioning); a single reference that silently
describes the latest version misleads everyone not on
it. Deprecations marked clearly with migration paths
(see api-deprecation).
Boundaries
- Reference docs answer "how", not "why" or "what should I
build": conceptual guides and tutorials (see
tutorial-writing) serve those, and a reference alone
leaves beginners lost (see docs-information-architecture's
four-quadrant split).
- Generation quality depends on source annotation quality;
garbage descriptions in the schema produce garbage docs
(see structured-output's field-description rule, applied
to your own API).
- Interactive reference (try-it consoles, request builders)
raises the value but adds infrastructure; worthwhile for
public APIs, over-investment for a small internal one.
1---2name: api-reference-docs3description: Produce API reference docs that blend generation with curation, an example per endpoint, and documented errors. Use when documenting an API or SDK for external or internal consumers.4---56# API reference docs78Reference docs answer "how do I call this exactly": every endpoint,9parameter, response, and error. The winning approach blends generation10(complete, never drifts) with curation (examples and guidance a11generator cannot produce), because pure generation is complete but12useless and pure hand-writing is helpful but stale.1314## Method15161. **Generate the skeleton from the source of truth.** From17 the OpenAPI/GraphQL schema, proto, or code annotations18 (see openapi-contracts, graphql-schema-design):19 endpoints, parameters, types, and required/optional20 status stay complete and in sync with the actual API21 because they come from it. Hand-maintained parameter22 lists drift the first time someone adds a field.232. **Curate what generation cannot express.** Every endpoint24 needs a realistic example (request and response, with25 real-looking values), a one-line "when to use this", and26 the non-obvious behavior (side effects, rate limits,27 pagination: see api-pagination-design, rate-limiting).28 The generated schema says a field is a string; the29 curated note says what string and why.303. **Document every error, not just the happy path.** What31 errors each endpoint returns, what causes them, and how32 to fix them (see api-error-responses): error docs are33 what turn a support ticket into a self-service fix.34 Reference docs that only describe success leave the35 consumer stranded exactly when they need help.364. **Show authentication and the first real call.** How to37 authenticate (see authn-design, oauth-flows), then a38 complete working example from zero to a successful39 response: the reference doubles as the quickstart's40 detailed backing (see readme-writing's quickstart, which41 links here). A reference nobody can make their first42 call from has failed at its one job.435. **Keep examples tested and current.** Runnable, verified44 examples (see docs-as-code: run them in CI so a breaking45 change fails the docs build too): a copy-pasted example46 that errors is worse than none, because it destroys47 trust in the whole reference. This is the discipline48 that keeps generated-plus-curated honest.496. **Version the reference with the API.** Consumers on50 different versions need the docs for *their* version51 (see api-versioning); a single reference that silently52 describes the latest version misleads everyone not on53 it. Deprecations marked clearly with migration paths54 (see api-deprecation).5556## Boundaries5758- Reference docs answer "how", not "why" or "what should I59 build": conceptual guides and tutorials (see60 tutorial-writing) serve those, and a reference alone61 leaves beginners lost (see docs-information-architecture's62 four-quadrant split).63- Generation quality depends on source annotation quality;64 garbage descriptions in the schema produce garbage docs65 (see structured-output's field-description rule, applied66 to your own API).67- Interactive reference (try-it consoles, request builders)68 raises the value but adds infrastructure; worthwhile for69 public APIs, over-investment for a small internal one.