Richardson Maturity Model

Richardson Maturity Model with Examples

In this article, I am going to discuss Richardson Maturity Model with Examples. Please read our previous article where we discussed Spring Boot Security with Examples.

What is Richardson Maturity Model (RMM)?

This model grades APIs by their RESTful maturity, based on their adherence and conformity to the model’s 4 levels. It was proposed by Leonard Richardson in 2008.

It is a way to grade web APIs according to the constraints of REST. It is employed to determine how well a Web service architecture adheres to REST principles. It breaks down the principal element of the REST approach into four levels (0 to 3). The four levels are:

  • Level 0: The Swamp of POX
  • Level 1: Resources
  • Level 2: HTTP Verbs
  • Level 3: Hypermedia Control

A level higher is more RESTful compared to one that is at a lower level. When an API reaches level 4, we consider it as a RESTful API. This can be described using the following diagram:

What is Richardson Maturity Model (RMM)?

Level 0: The Swamp of POX

Level 0, also referred to as POX or Plain Old XML, is a stage where HTTP is utilized solely as a transport protocol, and its benefits, such as HTTP methods and cache, are not leveraged. APIs at this level have a single URI and use only the POST HTTP method. Essentially, it presents SOAP (Simple Object Access Protocol) web services in a RESTful manner.

For instance, a company may have multiple customers, but all of them share the same endpoint. The same POST method is used for all CRUD operations.

Level 1: Resources

An API is considered to be at Level 1 when it can differentiate between various resources. Such an API must have multiple URIs, with each URI serving as an entry point to a specific resource. It presents resources with appropriate URIs. In other words, Level 1 reduces complexity by dividing large service endpoints into multiple distinct endpoints. It also exclusively uses the POST HTTP method for both retrieving and creating data.

For example, if we want a list of specific products, we go through the URI http://localhost:8080/products. If we want a specific product, we go through the URI http://localhost:8080/products/mobile.

When building a URI, the following points must be kept in mind:

  • Use domain and subdomain to logically group or partition resources.
  • Use / to indicate a hierarchical relationship.
  • Use , and ; to indicate non-hierarchical relationships.
  • Use – and _ to improve the readability.
  • Use & to separate parameters.
  • Avoid including file extensions.
Level 2: HTTP Verbs

Level 2 requires an API to utilize protocol properties to address scalability and failures. At this level, the appropriate HTTP verbs are used for each request, and the API must use these verbs to be considered truly RESTful. Additionally, the correct HTTP response code is provided for each request.

In essence, the POST method is no longer used for all requests. Instead, the GET method is used to request a resource and the DELETE method is used to delete a resource. The API must also return the appropriate response codes. The following table shows some of the most common HTTP verbs and their usage:

Verbs Usage
GET It is used to retrieve information from the server.
POST It is used to create or update a resource on the server.
DELETE It is used to delete a resource.
PUT It is used to update or replace an existing resource. This may also be used to create a new resource as specified by the client.
HEAD It is used to retrieve the same headers as that of the GET response but without anybody in the response.
OPTIONS It is used to find the list of HTTP methods supported by any resource or to ping the server.
TRACE It is used for debugging, which echo’s back headers that it has received.
Level 3: Hypermedia Controls

Level 3 is the highest level and combines the features of Level 2 with HATEOAS support. It also facilitates self-documentation. For instance, if a GET request is sent for customers, the response will be in JSON format and include self-documenting Hypermedia. The following figure shows the overview of the RMM model:

Richardson Maturity Model with Examples

In the next article, I am going to discuss RESTful Web Services Best Practices. Here, in this article, I try to explain Richardson Maturity Model with Examples. I hope you enjoy this Richardson Maturity Model article.

Leave a Reply

Your email address will not be published. Required fields are marked *