What is REST

What is Rest? A very common question that comes in the minds of every developer who starts working on REST

REST stands for REpresentational State Transfer

Representational state transfer is a software architectural style that defines a set of constraints to be used for creating Web services. 
Web services that conform to the REST architectural style are called RESTful Web services. 


An API to be RESTFul, would require to adhere to the below 6 constraints:

  • Uniform interface
  • Client — server separation
  • Stateless
  • Layered system
  • Cacheable
  • Code-on-demand

It is very important that we understand each constraint in depth.

Uniform interface

This constraint has 4 parts:

  • The request to the server must include a resource identifier.

Example : GET ../users/12.
Here 12 is the id of the user, whose details you want to fetch.

  • The response of the server should return enough information so the client can modify the resource. 

Example: GET ../users/12 returns the below json structure:

	"id": "12",
	"firstName": "Stupid",
	"lastName": "Monk"

In the above json structure, if the server doesn’t return the ID of the user in the response, as a client I won’t be aware of the address field and will not be able to modify it if required.

  • Each request to the API contains all the information the server needs to perform the request, and each response the server returns contains all the information the client needs in order to understand the response.
  • Hypermedia as the engine of application state.

By application we mean the web application that the server is running. By hypermedia we refer to the hyperlinks, or simply links, that the server can include in the response. 
The whole sentence means that the server can inform the client, in the response, of the ways to change the state of the web application. 
If the client asked for a specific user, the server can provide not only the state of that user but also information about how to change the state of the user, for example how to update the user’s name or how to delete the user. 
Finally, the result of the uniform interface is that requests from different clients should look the same, whether the client is a browser, any linux server, a script, an app or anything else.

Client — Server separation

  • Client and server are independent and act on their own.
  • Interaction amongst them is via request.
  • Requests are initiated by the client.
  • Servers sends the ask of the requests.


The server does not store any information about the client or the user who consumes the API. The server does not remember, if the request is for the first time or nth time.
However every request should contain all the information, required by the server to perform the request and return a response.

Layered System

Between the client (who requests a resource’s state), and the server (who sends the response back), there might be a number of servers in the middle. 
These servers might provide a security layer, a caching layer, a load-balancing layer, gateway or other functionality. Those layers should not affect the request or the response. 
The client is not aware as to how many layers, if any, there are between the client and the actual server responding to the request.

Continued in the next page…

photo about rest restful apis
Previous Post

No more post

photo about rest restful apis
Next Post

No more post

Leave a Reply