Marketplace

writing-api-docs

Patterns and structure for writing API reference documentation including endpoint descriptions, request/response schemas, and error documentation.

$ Installer

git clone https://github.com/LerianStudio/ring /tmp/ring && cp -r /tmp/ring/tw-team/skills/writing-api-docs ~/.claude/skills/ring

// tip: Run this command in your terminal to install the skill


name: writing-api-docs description: | Patterns and structure for writing API reference documentation including endpoint descriptions, request/response schemas, and error documentation.

trigger: |

  • Documenting REST API endpoints
  • Writing request/response examples
  • Documenting error codes
  • Creating API field descriptions

skip_when: |

  • Writing conceptual guides → use writing-functional-docs
  • Reviewing documentation → use documentation-review
  • Writing code → use dev-team agents

sequence: before: [documentation-review]

related: similar: [writing-functional-docs] complementary: [api-field-descriptions, documentation-structure]

Writing API Reference Documentation

API reference documentation describes what each endpoint does, its parameters, request/response formats, and error conditions. It focuses on the "what" rather than the "why."

API Reference Principles

  • RESTful and Predictable: Standard HTTP methods, consistent URL patterns, document idempotency
  • Consistent Formats: JSON requests/responses, clear typing, standard error format
  • Explicit Versioning: Version in URL path, backward compatibility notes, deprecated fields marked

Endpoint Documentation Structure

SectionContent
TitleEndpoint name
DescriptionBrief description of what the endpoint does
HTTP Method + PathPOST /v1/organizations/{orgId}/ledgers/{ledgerId}/accounts
Path ParametersTable: Parameter, Type, Required, Description
Query ParametersTable: Parameter, Type, Default, Description
Request BodyJSON example + fields table
Success ResponseStatus code + JSON example + fields table
ErrorsTable: Status Code, Error Code, Description

Field Description Patterns

TypePattern
Basicname: string — The name of the Account
With constraintscode: string — The asset code (max 10 chars, uppercase)
With exampleemail: string — Email address (e.g., "user@example.com")
DeprecatedchartOfAccountsGroupName: string — **[Deprecated]** Use \route` instead`

Data Types Reference

TypeDescriptionExample
uuidUUID v4 identifier3172933b-50d2-4b17-96aa-9b378d6a6eac
stringText value"Customer Account"
integerWhole number42
booleanTrue/falsetrue
timestamptzISO 8601 (UTC)2024-01-15T10:30:00Z
jsonbJSON object{"key": "value"}
arrayList of values["item1", "item2"]
enumPredefined valuescurrency, crypto

Request/Response Examples

Rules:

  • Show realistic, working examples (not "foo", "bar")
  • Show all fields that would be returned
  • Use actual UUIDs, timestamps, realistic data

Error Documentation

Standard error format:

{
  "code": "ACCOUNT_NOT_FOUND",
  "message": "The specified account does not exist",
  "details": { "accountId": "invalid-uuid" }
}

Error table:

StatusCodeDescriptionResolution
400INVALID_REQUESTValidation failedCheck request format
401UNAUTHORIZEDMissing/invalid authProvide valid API key
403FORBIDDENInsufficient permissionsContact admin
404NOT_FOUNDResource doesn't existVerify resource ID
409CONFLICTResource already existsUse different identifier
422UNPROCESSABLE_ENTITYBusiness rule violationCheck constraints
429TOO_MANY_REQUESTSRate limit exceededRetry after delay
500INTERNAL_ERRORServer errorRetry or contact support

HTTP Status Codes

Success: 200 (GET/PUT/PATCH), 201 (POST creates), 204 (DELETE)

Client errors: 400 (malformed), 401 (no auth), 403 (no permission), 404 (not found), 409 (conflict), 422 (invalid semantics), 429 (rate limit)

Server errors: 500 (internal)


Pagination Documentation

For paginated endpoints, document query parameters:

ParameterTypeDefaultDescription
limitinteger10Results per page (max 100)
pageinteger1Page number

Response includes: items, page, limit, totalItems, totalPages


Versioning Notes

Note: You're viewing documentation for the current version (v3).

For deprecated: > **Deprecated:** This endpoint will be removed in v4. Use [/v3/accounts](link) instead.


Quality Checklist

  • HTTP method and path correct
  • All path parameters documented
  • All query parameters documented
  • All request body fields documented with types
  • All response fields documented with types
  • Required vs optional clear
  • Realistic request/response examples included
  • All error codes documented
  • Deprecated fields marked
  • Links to related endpoints included