REST

Representational State Transfer is an architectural style for distributed hypermedia systems.

Properties

RESTful systems have the following properties:

  • Client-Server: Server provides an independent service to clients.
  • Stateless: No state should be saved by either the server nor the client between requests.
  • Cacheable: Responses should be cached.
  • Uniform Interface: The interface should be uniform.
  • Layered System: The system should be layered (the user should only have one interface).
  • Code on Demand (optional): The server can provide executable code to the client.

Richardson Maturity Model

The Richardson Maturity Model (RMM) is a model for classifying RESTful systems.

Level 0: Swamp of POX

Level 0 is the lowest level of the RMM. It is characterized by the use of HTTP as a transport protocol for remote procedure calls (RPC).

Level 1: Resources

Level 1 is characterized by the use of resources. Resources are identified by URIs.

Level 2: HTTP Verbs

Level 2 is characterized by the use of HTTP verbs. HTTP verbs are used to specify the action that should be performed on a resource. HTTP status codes are used to indicate the result of the action.

Level 3: Hypermedia Controls

Level 3 is characterized by the use of hypermedia controls. Hypermedia controls are links that are embedded in the response. They allow the client to navigate the API.

RESTful APIs

RESTful APIs can be implemented with Spring Boot.

Example

The following example shows a simple RESTful API that allows users to create, read, update and delete (CRUD) notes.