Signup/Sign In

How RESTful is your API - Richardson Maturity Model

Since REST is just a specification or we can say a way of implementing web services, with no hard coded documentation. So how we know the API which we have developed is fully RESTful. For this, there is Richardson Maturity Model, which is usually referred to analyse how RESTful the API is.

The Richardson Model is a way to grade your API according to the constraints of the REST. The more the API follows these constraints the more RESTful the API is.

The Richardson Maturity Model has 4 levels numbered from 0 to 3. Level 0 is not RESTful while Level 4 means your API is fully RESTful.


Level 0

This will use only one URI to expose the whole API and generally uses only one HTTP method. If we take example of our registration API we see that that every resource has its own URI. The student resource has a different URI, the course resource has a different URI and the registration resource has a different URI.

SOAP based web services are the example of this level. This level of API doesn't leverage the full concepts of the HTTP specification. For example: Every request will be POST request, so if someone wants to delete a student record they will have send the action also in the request.


Level 1

In this level every resource has its own URI. This level uses multiple URI where every URI is an entry point to a specific resource. Still this level uses only POST method for operation.


Level 2

This level says that your API should use protocol properties as much as possible. You must not use single POST method for all the operations, but make use of GET when you are requesting a resource, use a DELETE method when you want to delete a resource.

The use of proper response codes is also essential. Use 201 Created response code when a post request comes and resource is created. Use 200 Ok response for the get request and so on.


Level 3

This level suggests to use the concept of HATEOAS. The response should contain the logical links of all the resources which the current resource is related to.

For Example: In case of when the client request for the student information with the roll number 1, then in the response along with the response of the student, a link of all the URI of all the courses which that student has registered should also be sent.

If an API is at the level 3 this will be known as fully RESTful. This Richardson Model should be used while designing the REST API to make sure the web services are fully RESTful.