{"id":229,"date":"2017-12-14T00:12:00","date_gmt":"2017-12-13T23:12:00","guid":{"rendered":"https:\/\/kindsonthegenius.com\/blog\/2017\/12\/14\/richardsons-maturity-model-for-restful-apis\/"},"modified":"2020-08-22T14:47:55","modified_gmt":"2020-08-22T12:47:55","slug":"richardsons-maturity-model-for-restful-apis","status":"publish","type":"post","link":"https:\/\/kindsonthegenius.com\/blog\/richardsons-maturity-model-for-restful-apis\/","title":{"rendered":"Richardson&#8217;s Maturity Model for REST APIs"},"content":{"rendered":"<p>Today, you will learn the concept of Richardson&#8217;s Maturity Model(RMM), the key concept behind REST APIs.<\/p>\n<p>So, how do you measure if a web service is REST web service or not?<\/p>\n<p>This can be done using a model developed by a Computer Scientist called Roy Fielding. This model is called <i>Richardson&#8217;s Maturity Model <\/i>and is use to determine how much the API conforms the certain architectural styles.<\/p>\n<p>It is used to answer the question: <em><strong>How RESTful is the API?<\/strong><\/em> Based on certain criteria, a REST API can can score from 0 &#8211; 3 ranging from Not-RESTful (level 0) to Fully-RESTful(level 3)<\/p>\n<p>&nbsp;<\/p>\n<p><b>Content<\/b><br \/>\n<a href=\"https:\/\/www.kindsonthegenius.com\/blog\/richardsons-maturity-model-for-restful-apis#t0\">Level 0: Non RESTful<\/a><br \/>\n<a href=\"https:\/\/www.kindsonthegenius.com\/blog\/richardsons-maturity-model-for-restful-apis#t1\">Level 1: Resource-based URIs<\/a><br \/>\n<a href=\"https:\/\/www.kindsonthegenius.com\/blog\/richardsons-maturity-model-for-restful-apis#t2\">Level 2: Use of HTTP Methods<\/a><br \/>\n<a href=\"https:\/\/www.kindsonthegenius.com\/blog\/richardsons-maturity-model-for-restful-apis#t3\">Level 3: HATEAOS-Compliance<\/a><br \/>\n<a href=\"https:\/\/www.kindsonthegenius.com\/blog\/richardsons-maturity-model-for-restful-apis#t4\">Final Notes.<\/a><\/p>\n<p>&nbsp;<\/p>\n<h4 id=\"t0\"><strong>Level 0: Not RESTful<\/strong><\/h4>\n<hr \/>\n<p>At level 0 a REST API is described as not RESTful. This means that the API is made up just XML and therefore known as &#8216;Swamp of POX&#8217;, plain old xml. At level 0, the request and response uses just on entry point URI and just one method HTTP POST method. Level 0 is equivalent to SOAP(Simple Object Access Protocol) web service<\/p>\n<p>&nbsp;<\/p>\n<h4 id=\"t1\"><strong>Level 1: Resource-based URIs<\/strong><\/h4>\n<hr \/>\n<p>Level 1 has to do with Resource and Resource-based URIs. This means that there are different URIs for different resources in the API. URI stands for Universal Resource Identifier. It is similar to a URL. The difference is that a URI is a URL that maps to a particular resource.<br \/>\nResources are endpoints in the API which could represent an object, collections of objects, operations on objects etc.<\/p>\n<p>Take example of URL from a messaging application:<\/p>\n<p><span style=\"color: #351c75;\"><span style=\"font-family: 'courier new' , 'courier' , monospace;\">http:\/\/kindsonthegenius.com\/messages<\/span><\/span><br \/>\n<span style=\"color: #351c75;\"><span style=\"font-family: 'courier new' , 'courier' , monospace;\">http:\/\/kindsonthegenius.com\/messages\/1<\/span><\/span><br \/>\n<span style=\"color: #351c75;\"><span style=\"font-family: 'courier new' , 'courier' , monospace;\">http:\/\/kindsonthegenius.com\/messages\/2\/delete<\/span><\/span><\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>The first line is a URI that maps to a collection of messages and a returns a list of messages to the client.<\/li>\n<li>The second line maps to a single message with ID of 1 and sends back the message with the id of 1 to the client.<\/li>\n<li>The third URI maps to the delete operation for message with ID of 2 and allows the user to delete the message<\/li>\n<\/ul>\n<p>So if your REST API has the URIs designed this way, then that API have attained to REST level 1.<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t2\">Level 2: HTTP Methods (or Verbs)<\/strong><\/h4>\n<hr \/>\n<p>If a REST API implements resource-based URIs and also uses the appropriate HTTP verb to perform operations, then the API have attained REST level 2.<br \/>\nThe HTTP verbs corresponds to the four CRUD operations that can be performed on a resource. The verbs are:<\/p>\n<ul>\n<li>GET: used to retrieve resource(s) from the server<\/li>\n<li>POST: used to create new resource<\/li>\n<li>PUT: used to modify existing resource<\/li>\n<li>DELETE: used to delete a resource from the server<\/li>\n<\/ul>\n<p>So if a client makes a request to retrieve a resource from the server, the it should use the REST the GET method.<br \/>\nThe fact is that without the use of HTTP verbs, the API would still work but would not be fully RESTful.<\/p>\n<p><ins style=\"display: block; text-align: center;\" data-ad-client=\"ca-pub-7041870931346451\" data-ad-format=\"fluid\" data-ad-layout=\"in-article\" data-ad-slot=\"4209786523\"><\/ins><br \/>\n<b><\/b><\/p>\n<h4><strong id=\"t3\">Level 3: HATEOAS Compliant<\/strong><\/h4>\n<hr \/>\n<p>To attain level 3 after attaining level 2, then the API must be HATEOAS compliant. HATEOAS stands for Hypermedia as the Engine Of Application State. Of course you know what Hypermedia is. Typical example is hyperlinks. So this level requires that the API must provide in addition to the response, links to other resources or operations that the client may need.<br \/>\nSo if a client request for a resource, say a user profile, then the API should provide the user with links to Edit, Delete and Save as well as link to get list of users.<\/p>\n<p>This level is what makes is possible to browse a website without much help because the hyperlinks and images provide the user with hints on how to move to a different part of the application(changing the application state)<\/p>\n<p>&nbsp;<\/p>\n<h4 id=\"t4\"><strong>Final Notes<\/strong><\/h4>\n<hr \/>\n<p>So a REST API at level 3 is described as fully RESTful. I hope this explanation is clear. Please leave a comment if you would like to.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today, you will learn the concept of Richardson&#8217;s Maturity Model(RMM), the key concept behind REST APIs. So, how do you measure if a web service &hellip; <\/p>\n","protected":false},"author":2,"featured_media":776,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[289],"tags":[],"_links":{"self":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/229"}],"collection":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/comments?post=229"}],"version-history":[{"count":9,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/229\/revisions"}],"predecessor-version":[{"id":1261,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/229\/revisions\/1261"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/media\/776"}],"wp:attachment":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/media?parent=229"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/categories?post=229"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/tags?post=229"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}