liveBook · Manning

Granularity

As explained in The Design of Web APIs, Second Edition

Rule granularity is the degree to which a linting rule limits its verification to a narrowly defined aspect of an API.

Rule granularity is the degree to which a linting rule limits verification to one narrowly defined API aspect. Appropriate granularity keeps feedback useful; overly broad rules overwhelm users, enforce unnecessary patterns, or encourage bad APIs. section 18.4

The same principle applies to API data and operations: retain relevant data within scope, separate distinct capabilities, and combine information only when the combined purpose is clear. section 8.7 section 9.9.1

Use granularity to make API guidance easier to understand and apply:

  • Create only rules justified by API design guidelines. section 18.4
  • Split broad needs into small rule-sized checks, then combine them to cover larger topics. section 18.4
  • Give each rule a concise name and description, and use shared OpenAPI components to simplify what it verifies. section 18.4

Account operations

A GET /accounts/{accountId} response that includes transactions forces consumers to filter, sort, and paginate unrelated data. A dedicated transaction-search operation has clearer granularity, while a dashboard operation may intentionally combine summarized accounts with recent transactions. Likewise, update customer address separately from account updates because the account and its holder are distinct concepts. section 9.9.1

Figure 8.8 How to design user-friendly, interoperable data
figure

Use the design sequence to reconsider data relevance and granularity after selecting and organizing the data, then refine names and standards. section 8.3.3

How The Design of Web APIs, Second Edition covers it

How deep it goes
Explains relevance, scope, operation boundaries, and rule decomposition through practical guidance, without detailing linter implementation.
Examples
Uses account reads, transaction search, dashboards, customer-address updates, and decomposed linting needs as examples.
What it assumes
Builds on organized data models and API design guidelines while making relevance, scope, and operation boundaries explicit.
What you can do after
Evaluate API and lint-rule scope, then split broad verification needs into focused checks with clearer consumer feedback.
How it connects
Connects data modeling and request-response design with API linting and OpenAPI components.

Also explained in

Compare how 8 books explain granularity →

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.