REST (Representational State Transfer)
REpresentational State Transfer (REST) describes an API design pattern for HTTP requests (so called RESTful APIs). It was proposed in 2000 by Roy T. Fielding and became very common in the 2010s.
Fielding was contrasting the world wide web with RPC-based network architectures. This was before the prevalence of JSON, and while today's usage of the term often refers to JSON-based APIs over HTTP, one of the original key aspects was that they must be self-describing, i.e. use HTML1.
In practice, this aspect is now neglected and REST as a term mostly refers to using JSON RPC over HTTP.
Aspects
Key aspects:
- Stateless: Neither sender nor receiver has to remember their history
- HTTP Methods: Only uses GET, POST, PUT, DELETE for standard operations
- Cacheable: Responses must label themselves as cacheable or not
- Status Codes: Standardized response codes (200, 404, 500, etc.)
- Resource-Based: Everything modeled as a resource with unique URIs
- Idempotence: Multiple identical requests have same effect as single request
Neglected aspect:
- HATEOAS (Uniform Interface): API responses are self-describing
Richardson Maturity Model (RMM)
The RMM breaks down the elements of a REST API into three levels. These introduce resources, http verbs, and hypermedia controls.
- L0 RPC: Swamp of Plain-Old-XML, i.e. using HTTP as a tunneling mechanism
- L1 Resources: The API can now target individual resources
- L2 HTTP Verbs: Correct use of GET, POST, PUT, PATCH, DELETE
- L3 HATEOAS: Introduction of Hypermedia Controls