liveBook · Manning

Interval

As explained in The Design of Web APIs, Second Edition

A numeric range is a set of permitted numerical values bounded by lower and upper constraints that may be open-ended.

An interval defines permitted numerical values between lower and upper constraints. Bounds can be inclusive, exclusive, or open-ended, making intervals useful for API filters and data validation. section 9.6.2 section 19.3.1

Filtering transactions by amount

A request such as amount.gte=100&amount.lt=400 selects amounts satisfying 100 ≤ amount < 400. Equivalent designs can use from/to or min/max names, but those names should document whether bounds are strict. section 9.6.2

Use intervals deliberately when designing APIs:

  • Represent fixed validation limits with JSON Schema: minimum, exclusiveMinimum, maximum, or exclusiveMaximum. section 19.3.1
  • Describe business- or configuration-dependent limits textually, or expose an operation that returns current range values. section 19.3.1
Figure 19.7 JSON Schema allows us to define numerical ranges and array and string lengths. These ranges can be open-ended.
figure

Use the figure to compare inclusive, exclusive, and open-ended numeric intervals alongside array and string size limits. section 19.3.1

How The Design of Web APIs, Second Edition covers it

How deep it goes
Defines inclusive, exclusive, and open-ended bounds, then stops short of dynamic business-rule implementation.
Examples
Uses amount queries, owner ages, wire-transfer amounts, pagination sizes, and string or array lengths.
What you can do after
Apply intervals through query parameters or JSON Schema validation keywords.
How it connects
Connects intervals with API filters, JSON Schema, OpenAPI data models, and consumer error prevention.

Also explained in

Compare how 7 books explain interval →

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.