liveBook · Manning

Uniform interface

As explained in The Design of Web APIs, Second Edition

The uniform interface constraint is a REST constraint requiring a consistent and standardized interface for interacting with resources.

A uniform interface is a REST constraint: clients interact with resources through representations of their state, standard methods, and metadata that helps interpret representations and discover resource capabilities. For an API, this means expressing business capabilities as resources and HTTP methods rather than inventing a different interaction pattern for each operation. section 4.8.1 section 4.8.2

Keep transactions identifiable

Suppose GET /transactions?accountId=12345 returns a list, while GET /transactions?transactionId=2501 returns one transaction. The same path and method now identify different kinds of results depending on a query parameter. Separating resource identification from search modifiers makes the interface easier to understand and predict. section 9.4.1

Choose request locations that preserve the meaning of HTTP:

  • Use a path parameter to identify an account and query parameters to modify a transaction search. section 9.4.1
  • Put the input for creating a money transfer in the request body. section 9.4.1
  • Avoid putting significant business input only in headers: it becomes less visible in logs and API clients. Avoid forcing every operation through a body and POST: resources and predictable HTTP methods disappear. section 9.4.1

Look for resources that represent business concepts, even less obvious ones such as money transfer destinations. These can be less prone to breaking changes than narrowly tailored operations. Content negotiation also allows new representations, such as CSV or PDF, to be added without replacing the resource-oriented interface. section 15.6.1

How The Design of Web APIs, Second Edition covers it

How deep it goes
Defines the REST constraint and applies it to request design and change resistance, without detailing protocol internals.
Examples
Contrasts two transaction GET requests, then uses account transaction searches and money transfer creation to clarify input placement.
What it assumes
Assumes basic familiarity with HTTP requests while explaining how resources, methods, and input locations work together in API design.
What you can do after
Practice/perform it by identifying business resources and choosing HTTP-compliant request locations that consumers can predict.
How it connects
Connects resource identification, HTTP methods, request parameters, content negotiation, interoperability, and backward-compatible API evolution.

Also explained in

Compare how 2 books explain uniform interface →

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.