REST (Representational State Transfer) is not a protocol or a format — it is an architectural style defined by Roy Fielding in his 2000 dissertation. An interface earns the label “RESTful” only by satisfying a set of constraints. This reference lists all six with Fielding’s definition and the trade-off each imposes.
How it works
REST is defined by six constraints, applied on top of a network of components. Five are required; one (code on demand) is optional:
- Client–Server — separate UI from data storage.
- Stateless — each request is self-contained; no server-side session.
- Cacheable — responses declare their cacheability.
- Uniform Interface — URIs, representations, self-descriptive messages, HATEOAS.
- Layered System — components only see the adjacent layer.
- Code on Demand (optional) — server may send executable code to clients.
Each constraint buys a property — scalability, visibility, simplicity — usually at some cost in efficiency or latency.
Example
The stateless constraint is why a REST API authenticates every request with a token rather than a server-held session. Because no instance needs to remember the caller, a load balancer can route consecutive requests to different servers freely, and you can add or remove instances without sticky sessions. The trade-off is that the token and context travel on every request.
Notes
- The uniform interface is what most distinguishes REST from RPC; its HATEOAS sub-constraint (hypermedia links driving state) is the part most APIs omit.
- Layered system is what makes transparent caches, gateways and load balancers possible — clients can’t tell whether they’re talking to the origin.
- Satisfying all required constraints yields the scalability and evolvability REST is prized for; violating statelessness or the uniform interface is what quietly turns a “REST” API into something else.