Explaining REST Principles and Architecture

Explaining REST Principles and Architecture

"REST"' or "Representational State Transfer" is an architectural style or set of constraints used in designing web applications. It is usually paired with APIs, or "application programming interface", that helps create these web applications pulling data from a link to display the data in a RESTful manner.

RESTful APIs leverage HTTP methods such as (GET, POST, PATCH, & DELETE). It allows us to Create, Read, Update, and Delete or "CRUD", various data and helps us manipulate elements in software applications, databases, and APIs.

Utilizing these HTTP methods facilitates user communication between the client and server by initiating requests sent to the server. Whenever an action is performed on a website, such as creating a post on Instagram or accessing someone's profile on Facebook, a request is sent to the server to retrieve the desired information.


Image Provided by Joseph Benharosh

Image provided by Joseph Benharosh


REST APIs can be used in any programming language and support a variety of data formats. Although this makes it easier for programmers to use APIs, there are some architectural constraints such as Client-server, Statelessness, Uniform Interface, Cacheability, Layered system architecture, and Code on Demand (optional).

Client-Server
Maintains a separation between the client and server concerns, allowing them to evolve independently.
Statelessness
Each request from a client to the server must contain all the information necessary to understand and process the request.
Uniform Interface
In RESTful APIs, all requests for the same resource should share a consistent structure, using a single URI for each piece of data like a user's name or email.
Cacheability
Server responses must indicate whether they are cacheable or non-cacheable, empowering clients to cache responses. This practice enhances performance and minimizes network load.
Layered System Architecture
In REST APIs, communication passes through layers, so avoid assuming direct connections between client and service apps, Design APIs to hide whether they interact with the end app or an intermediary.
Code on Demand (optional)
Typically, REST APIs transmit static resources, responses may include executable code (like Javascript), to be executed within the client's context. Code on Demand is optional to maintain compatibility with diverse client capabilities and avoid potential security issues associated with executing server-side code on clients.