Wednesday, February 25, 2015

What is REST?

Official Definition of REST
REST is an architecture style (concepts / theory) built on certain principle of web. REST is a PROTOCOL design on HTTP. REST is an architecture for how to send messages back and forth from a client to server using HTTP.

Define Protocol: 
Set of rules for requesting information from server using special technique.

Representational state transfer is using WEB feature in simple and effective way. It take advantage of 40 years old matured HTTP protocol features/methods and apply its own PRINCIPLES. 


HTTP features like 

  • GET/PUT/POST/Delete methods on resources, 
  • http protocol is stateless.
  • URI - locate anything on web.

REST Principles:

  1. RESOURCES - Everything is RESOURCE from REST point of view e.g. images / files / videos etc. So think everything as RESOURCE.
  2. IDENTIFIER - REST always GET the resource by UNIQUE identifies. e.g. http://www.google.com/Customers/Chintan OR http://www.google.com/Customers/items(111)
  3. INTERFACE - Keep your interface simple and uniform to achieve CRUD operations like it uses HTTP METHODS GET / PUT / DELETE / POST to do the operations rather than allowing user to create their own methods and spread confusion. Hence, REST will use HTTP methods to work with resource to maintain uniformity.
  4. REPRESENTATION - All communication happen between client and server and vice-versa is called as  REPRESENTATION. The server might respond it in XML or JSON format depending on what developer has specify on their application.
  5. STATELESS - Every request is stateless. Every request which you send is independent of earlier request. Server need not have to remember the state of every request. e.g. if client try to access server for the first time, server ask for authentication. Once successfully authenticated, if client make 2nd request, then server along with request, client also send SUCCESS authentication message so server need not ask for authentication.
Why REST?
It take advantage of HTTP and allow to boost application performance and scalibility.

No comments:

Post a Comment