Rest VS Restful Api
2 min readSep 15, 2022
Rest is an architectural style that follows some set of rules to achieve its goal. It is a commonly used API standard mostly used by mobile and web application to communicate between two systems through HTTP request and in response gives JSON/XML/YML(data serialization language) data.
Restful api is an api which follows the Rest architecture and its six guiding principles or rules. These are:
Uniform Interface
– this is the fundamental principle of the RESTful system. It simplifies and decouples the architecture of the system, allows us to independently scale the components, and improve the interactions between components and other systems. The four architectural constraints that RESTful system should follow in order to a uniform interface are:
# resource identification
# manipulation of resources through representations
# self-descriptive messages
# hypermedia as the engine of application state (HATEOS)
Client–Server
– the main principle behind this is the separation of concerns, i.e, separating the user interface concern from the data storage concerns. By following this principle, we can improve the:
# portability of the user interface across platforms
# scalability by simplifying the server component
Stateless
– each request from the client must be sent to the server with all the necessary information to understand the request and the request cannot take advantage of any stored context on the server. The session state is therefore maintained entirely on the client.Cacheable
– cache constraints require that the data within a response to a request be implicitly or explicitly denoted as cacheable or non-cacheable to prevent clients from giving stale information. If a response is cacheable, then a client cache is given the right to reuse that response data for later, equivalent requests. This allows us to minimize the network calls made to the server.Layered System
– the layered system style allows an architecture to be divided into a number of hierarchical layers or tiers by constraining each of the layer’s behavior such that each layer cannot access beyond the immediate layer with which they are interacting with. This allows us to independently scale the layers.Code on-demand
– this principle is an optional one. REST allows client functionality to be extended by downloading executable scripts that can be executed on client-side like Java applets or Javascript.