Introduction
In this blog, we will discuss REST, which stands for Representational State Transfer. It is an architectural style designed specifically for the Internet. It is the most commonly used mechanism for connecting one web source (i.e., a server) to another web source (i.e., a client). This type of architectural style works for hypermedia systems that are distributed.
Principles of REST
Below are six principles that need to be fulfilled for an interface to be RESTful.
Statelessness
Each client-server request must contain all the necessary information to understand and fulfill the request. There is no such advantage server can take from previously stored data.
Uniformity in Interface
A uniform interface simplifies the overall system and helps the crystal visibility of interactions. The four constraints mandatory for a uniform interface are Unique Resources Identification by the interface; Resources Manipulation of uniform representation per consumer needs; self-descriptive messages on how to process the message; and Hyperlinks as the driving force for interactions.
Client-Server pattern
For either Client or Server, concerns are handled separately, which helps Client and Server components evolve independently. This has led to improvement in portability and flexibility across numerous platforms. But, care has to be taken that this independent evolution does not result in contract or interface break.
Layered System
Architecture is composed of hierarchical layers, and each layer cannot interfere with the other layers.
Cacheability
This constraint mandates that a response should label itself cacheable or non-cacheable. If it is cacheable, there will be given the right to the client application to reuse the data.
Code as per demand
The functionality of downloading and executing code in the form of applets or scripts is provided by REST. This helps to simplify the whole process. The server provides only that code whose features must be delivered to the client.
In this module, we will be focusing on the concept of REST APIs and their advantages, but before jumping into depth, we will first look at some basic terminologies.