liveBook · Manning

Label

As explained in The Design of Web APIs, Second Edition

A label is human-facing text that expresses the meaning of a coded value or business concept.

A label is human-facing text that explains a coded value or business concept. Prefer plain words such as "checking" and "savings" over cryptic codes when possible. section 8.5.2

Preserve the code, add the label

When shared systems require account code 7, return {"type": 7, "typeLabel": "savings"} or {"type": {"code": 7, "label": "savings"}}. Labels help developers interpret data and can be displayed to users. section 8.5.2

Choose the delivery pattern according to consumer needs:

  • Inline labels make responses immediately usable but repeat the same value across many records. section 13.5.4
  • Dedicated operations such as GET /codes/transaction-category/values centralize labels and can be cached, while requiring an extra call. section 13.5.4
  • Use Accept-Language to translate labels for end users; keep property names and machine-readable codes stable. section 9.7.2
Figure 8.12 Contrasting non-human-readable and human-readable bank account type codes
figure

Compare cryptic and human-readable bank account type codes. section 8.5.2

How The Design of Web APIs, Second Edition covers it

How deep it goes
Explains inline labels, code-label objects, centralized lookup operations, caching, and locale translation.
Examples
Uses bank account types, transaction categories, code lookup endpoints, and translated travel-agency labels.
What it assumes
Assumes coded API values and teaches why consumers need accompanying human-readable meanings.
What you can do after
Apply it via HTTP content negotiation and code lookup operations to make API values interpretable.
How it connects
Connects labels with codes, enumerations, caching, content negotiation, and localization.

Also explained in

Compare how 3 books explain label →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Design of Web APIs, Second Edition. The section links point to the parts of the book it draws on.