1.

What are the RESTful Services?

Answer»

REST stands for Representational State Transfer. This term was coined by Roy Fielding in 2000. RESTful is an Architectural style for creating loosely coupled applications over HTTP. In order to make API to be RESTful, it must adhere to the around 6 constraints that are mentioned below: 

  • Client and Server Separation: Server and Clients are clearly isolated in the RESTful services. 

This constraint specifies that a Client sends a request to the server and the server sends a response back to the client. This separation of concerns SUPPORTS the independent development of both client-side and server-side logic. That means client application and server application should be developed separately without any dependency on each other. A client should only know resource URIs and that’s all. Severs and clients may also be replaced and developed independently as long as the interface between them is not altered.  

  • Stateless: REST ARCHITECTURE is based on the HTTP Protocol and the server response can be cached by the clients, but no client context would be stored on the server. 

The stateless constraint specifies that the communication between the client and the server must be stateless between requests. This means that we should not be storing anything on the server related to the client. The request from the client should contain all the necessary information for the server to process that request. This ensures that each request can be treated independently by the server.  

  • Uniform Interface: Allows a limited set of operations defined using the HTTP Verbs. For eg: GET, PUT, POST, Delete etc. 

The uniform interface constraint defines an interface between the client and the server. To understand the uniform interface constraint, we need to understand what a resource is and the HTTP verbs – GET, PUT, POST and DELETE. In the context of a REST API, resources typically represent data entities. The product, Employee, Customer, etc. are all resources. The HTTP verbs (GET, PUT, POST, and DELETE) that are sent with each request tell the API what to do with the resource. Each resource is identified by a specific URI (Uniform Resource Identifier).  

  • Cacheable: RESTful architecture allows the response to be cached or not. Caching improves performance and scalability. 

Some data provided by the server like the list of products, or list of departments in a company does not change that often. This constraint lets the client know how long this data holds good, so that the client does not have to come back to the server for that data over and over again.  

  • Code-On-Demand:is any technology that sends executable software code from a server to a client UPON request from the client. The program code lies inactive on a web server until a client requests a web page that contains a link to the code using the client's web browser. Upon this request, the web page and the program are transported to the user's machine using HTTP. When the page is displayed, the code is started in the browser and executes locally, inside the user's computer until it is stopped (e.g., by the user leaving the web page). 
  • Layered System:REST allows us to use a layered system architecture where we DEPLOY the APIs in server A, and store data on server B and authenticate requests in server C. For example, a client cannot ordinarily tell whether it is connected directly to the server or to an intermediary along the way.  


Discussion

No Comment Found