What is REST?
Simply put, REST is an architectural style for developing applications that can be accessed over the network.
REST is an acronym that stands for:
It has a stateless client-server architecture where web services are resources and can be identified by their URIs. Clients and servers exchange representations of resources by using a standardized interface and protocol, which is typically HTTP. Every time the request is made by the client to the server, it needs to provide all that is necessary to carry out the request and cannot rely on the information provided by the previously made request. All of the transaction between the client and the server are done in a stateless manner.
What does it mean to be Stateless?
· Each client request to the server requires its state to be fully represented. The server must be able to completely understand the client request without using any knowledge on the state of the client. It follows that all state must be kept on the client
· The state does not get managed by the server
· The state remains with the client and every request the client makes supply the necessary data to the server
· The server only has to fulfill the request and does not have to worry about the state of the client (separation of concerns)
Just by knowing what REST is doesn’t paint a clear picture as to why this is beneficial. Users won’t fully appreciate the capabilities of REST without knowing its former approach, SOAP.
SOAP is a protocol that is tightly coupled to the server. The contract between the client and the server is very rigid and the whole process breaks if either side changes anything, which means that you need to update any changes constantly. In order to even begin the transaction in SOAP, the client needs previous knowledge on everything it will be using.
Compared to SOAP, REST is loosely coupled and can deal with changes more easily. It simplifies the server design since there’s no need to save any previous transaction history. And if a client session dies in mid-transaction, the state of the server does not get affected.