Harnessing the Full Potential of HTTP Protocol with REST

Why and When to Use Representational State Transfer

Jyothi Jaganath

Jyothi Jaganath

Senior Programmer Analyst
Jyothi Jaganath

Latest posts by Jyothi Jaganath

Today’s digital world requires automatic interaction within websites, between websites and client application and between websites and databases since there is a huge amount of information flowing in from diverse sources. The source could be such as vast amount of data generated from day to day transactions, marketing campaigns, social networks, etc. This automatic interaction could be facilitated seamlessly using Representational State Transfer, or REST.

Just like 3 tire and Service Oriented Architecture (SOA), REST is also an architectural style. It allows the user to use the current features of the web in a simplified and effective way. REST outlines how the components, namely servers, clients, proxies, etc., of a distributed system should interact with each other and how the resources are requested and passed from server to client.

In REST everything is seen in terms of resource. A resource can be anything such as an image, video file, web page or any object in object-oriented programming (OOP). A web application can be a collection of resources as in an online shop. These resources are accessed through URLs. Server returns a representation of the actual resource. Representation of a resource means the format in which we access the resource. The different representations could be JSON or XML.

The below tables illustrate an example in JSON and XML representations. For example, “Employee” is a resource. URL to access it is “http://somesite.in/Employee”  

REST harnesses the fullest potential of HTTP protocol. Some of the features of HTTP that REST uses are:

  • Verbs, namely GET, PUT, POST, and DELETE, etc.
  • URIs
  • Request and Response headers
  • Stateless. I.e., after completion of every interaction between client and server, current state is not remembered by either client or server

Verbs in use:

Important Status Codes

Success:

Errors:

When to use REST
  • When server is being accessed by many different clients
  • When user wants to update the server without having to update client software. Web browsers are an example of REST client.
  • When there is a need for loose coupling between client and server components. Example: Web browser can download jQuery library from Google’s Content Delivery Network (CDN) to improve performance.
Example of REST in Practice

Web browser can be referred to as a REST client because:

  • There is no need to update the web browser when HTML changes are made to a website or when new pages are added to a website
  • If in a browser, URL “http://somesite.in/images/nature” is entered, it will return an image whereas if a URL like “http://somesite.in/description/nature” is entered, the return result will be either a text or HTML
  • The web browser can be used to visit sites that did not exist when the browser was released
  • The same content is displayed when the URL is shared among multiple users
Advantages of REST
  • Simpler than SOAP
  • More lightweight than SOAP and XML
  • Load balancing made simpler
  • Easily maintainable
  • Scalable
  • Supports limited bandwidth
References & Resources

Having introduced to REST and how it harnesses the potential of HTTP protocol, now you can take some time to explore a little further. Here are few references that would help you in detailed understanding and also get started with REST implementation:

https://www.kennethlange.com/books/The-Little-Book-on-REST-Services.pdf

https://smartbear.com/smartbear/media/ebooks/rest-101.pdf

https://pepa.holla.cz/wp-content/uploads/2016/01/REST-API-Design-Rulebook.pdf

https://dzone.com/articles/step-by-step-aspnet-core-restful-web-service-devel

https://medium.freecodecamp.org/an-awesome-guide-on-how-to-build-restful-apis-with-asp-net-core-87b818123e28

I hope this article proves useful in deciding whether or not to use REST in your next project.

Share This Article


Jyothi Jaganath

Jyothi Jaganath

Senior Programmer Analyst
Jyothi Jaganath

Latest posts by Jyothi Jaganath

2 Comments
  • SANJAY Gupta
    Posted at 18:48h, 20 May Reply

    Good job Jyothi. Nice to see your post!!!

    • Jyothi Jaganath
      Jyothi Jaganath
      Posted at 03:34h, 21 May Reply

      Thank you Sanjay

Post A Comment