{"id":1633,"date":"2022-07-12T09:29:12","date_gmt":"2022-07-12T09:29:12","guid":{"rendered":"https:\/\/blog.amt.in\/?p=1633"},"modified":"2022-07-12T09:29:12","modified_gmt":"2022-07-12T09:29:12","slug":"introduction-to-representational-state-transfer","status":"publish","type":"post","link":"https:\/\/blog.amt.in\/index.php\/2022\/07\/12\/introduction-to-representational-state-transfer\/","title":{"rendered":"Introduction to Representational State Transfer"},"content":{"rendered":"<p>Representational state transfer\u00c2\u00a0(REST) is a\u00c2\u00a0software architectural\u00c2\u00a0style that defines a set of constraints to be used for creating\u00c2\u00a0Web services. Web services that conform to the REST architectural style, called\u00c2\u00a0RESTful\u00c2\u00a0Web services, provide interoperability between computer systems on the\u00c2\u00a0Internet. RESTful Web services allow the requesting systems to access and manipulate textual representations of\u00c2\u00a0Web resources\u00c2\u00a0by using a uniform and predefined set of\u00c2\u00a0stateless\u00c2\u00a0operations. Other kinds of Web services, such as\u00c2\u00a0SOAP\u00c2\u00a0Web services, expose their own arbitrary sets of operations.<\/p>\n<p>&#8220;Web resources&#8221; were first defined on the\u00c2\u00a0World Wide Web\u00c2\u00a0as documents or files identified by their\u00c2\u00a0URLs. However, today they have a much more generic and abstract definition that encompasses every thing or entity that can be identified, named, addressed, or handled, in any way whatsoever, on the Web. In a RESTful Web service, requests made to a resource&#8217;s\u00c2\u00a0URI\u00c2\u00a0will elicit a response with a\u00c2\u00a0payload\u00c2\u00a0formatted in\u00c2\u00a0HTML,\u00c2\u00a0XML,\u00c2\u00a0JSON, or some other format. The response can confirm that some alteration has been made to the stored resource, and the response can provide\u00c2\u00a0hypertext\u00c2\u00a0links to other related resources or collections of resources. When\u00c2\u00a0HTTP\u00c2\u00a0is used, as is most common, the operations (HTTP methods) available are GET, HEAD, POST, PUT, PATCH, DELETE, CONNECT, OPTIONS and TRACE.<\/p>\n<p>By using a stateless protocol and standard operations, RESTful systems aim for fast performance, reliability, and the ability to grow by reusing components that can be managed and updated without affecting the system as a whole, even while it is running.<\/p>\n<p>The term\u00c2\u00a0representational state transfer\u00c2\u00a0was introduced and defined in 2000 by\u00c2\u00a0Roy Fielding\u00c2\u00a0in his doctoral dissertation.\u00c2\u00a0Fielding&#8217;s dissertation explained the REST principles that were known as the &#8220;HTTP object model&#8221; beginning in 1994, and were used in designing the\u00c2\u00a0HTTP\u00c2\u00a01.1 and\u00c2\u00a0Uniform Resource Identifiers\u00c2\u00a0(URI) standards.\u00c2\u00a0The term is intended to evoke an image of how a well-designed Web application behaves: it is a network of Web resources (a virtual state-machine) where the user progresses through the application by selecting resource identifiers such as http:\/\/www.example.com\/articles\/21 and resource operations such as GET or POST (application state transitions), resulting in the next resource&#8217;s representation (the next application state) being transferred to the end user for their use.<\/p>\n<p>The constraints of the REST architectural style affect the following architectural properties:<\/p>\n<ul>\n<li>performance in component interactions, which can be the dominant factor in user-perceived performance and network efficiency;<\/li>\n<li>scalability\u00c2\u00a0allowing the support of large numbers of components and interactions among components. Roy Fielding describes REST&#8217;s effect on scalability as follows:<\/li>\n<\/ul>\n<p>REST&#8217;s client-server\u00c2\u00a0separation of concerns\u00c2\u00a0simplifies component implementation, reduces the complexity of connector semantics, improves the effectiveness of performance tuning, and increases the scalability of pure server components. Layered system constraints allow intermediaries\u00e2\u20ac\u201dproxies,\u00c2\u00a0gateways, and\u00c2\u00a0firewalls\u00e2\u20ac\u201dto be introduced at various points in the communication without changing the interfaces between components, thus allowing them to assist in communication translation or improve performance via large-scale, shared caching. REST enables intermediate processing by constraining messages to be self-descriptive: interaction is stateless between requests, standard methods and media types are used to indicate semantics and exchange information, and responses explicitly indicate\u00c2\u00a0cacheability.<\/p>\n<ul>\n<li>simplicity of a uniform interface;<\/li>\n<li>modifiability of components to meet changing needs (even while the application is running);<\/li>\n<li>visibility of communication between components by service agents;<\/li>\n<li>portability of components by moving program code with the data;<\/li>\n<li>reliability in the resistance to failure at the system level in the presence of failures within components, connectors, or data.<\/li>\n<\/ul>\n<p>The uniform interface constraint is fundamental to the design of any RESTful system.\u00c2\u00a0It simplifies and decouples the architecture, which enables each part to evolve independently. The four constraints for this uniform interface are:<\/p>\n<dl>\n<dt>Resource identification in requests<\/dt>\n<dd>Individual resources are identified in requests, for example using\u00c2\u00a0URIs\u00c2\u00a0in RESTful Web services. The resources themselves are conceptually separate from the representations that are returned to the client. For example, the server could send data from its database as\u00c2\u00a0HTML,\u00c2\u00a0XML\u00c2\u00a0or as\u00c2\u00a0JSON\u00e2\u20ac\u201dnone of which are the server&#8217;s internal representation.<\/dd>\n<\/dl>\n<dl>\n<dt>Resource manipulation through representations<\/dt>\n<dd>When a client holds a representation of a resource, including any\u00c2\u00a0metadata\u00c2\u00a0attached, it has enough information to modify or delete the resource.<\/dd>\n<\/dl>\n<dl>\n<dt>Self-descriptive messages<\/dt>\n<dd>Each message includes enough information to describe how to process the message. For example, which parser to invoke can be specified by a\u00c2\u00a0media type.<\/dd>\n<\/dl>\n<dl>\n<dt>Hypermedia as the engine of application state (HATEOAS)<\/dt>\n<dd>Having accessed an initial URI for the REST application\u00e2\u20ac\u201danalogous to a human Web user accessing the\u00c2\u00a0home page\u00c2\u00a0of a website\u00e2\u20ac\u201da REST client should then be able to use server-provided links dynamically to discover all the available actions and resources it needs. As access proceeds, the server responds with text that includes\u00c2\u00a0hyperlinks\u00c2\u00a0to other actions that are currently available. There is no need for the client to be hard-coded with information regarding the structure or dynamics of the application.<\/dd>\n<dd>The above is\u00c2\u00a0 brief about\u00c2\u00a0Representational State Transfer. Watch this space for updates on the latest trends in Technology.<\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>Representational state transfer\u00c2\u00a0(REST) is a\u00c2\u00a0software<\/p>\n","protected":false},"author":1,"featured_media":1635,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[585,586,7],"tags":[588,587,18],"class_list":["post-1633","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-representational-state-transfer","category-software-architectural-style","category-techtrends","tag-representational-state-transfer","tag-software-architectural-style","tag-technology"],"_links":{"self":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts\/1633","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/comments?post=1633"}],"version-history":[{"count":1,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts\/1633\/revisions"}],"predecessor-version":[{"id":1634,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts\/1633\/revisions\/1634"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/media\/1635"}],"wp:attachment":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/media?parent=1633"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/categories?post=1633"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/tags?post=1633"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}