When beginning in the field of web programming, one is bombarded by a series of acronyms and new terms that can catch us off-guard and send us into a tizzy. One such term that all new initiates into the field of web programming is the term ‘REST API’. In this article, I will attempt to decipher this concept in simple terms to make it accessible for all.
Before delving into the concept of REST API, let us first understand what an API is. The acronym API stands for Application Programming Interface, which is a way to communicate between different software services. Different types of APIs are used in programming hardware and software, including operating system APIs, remote APIs and web APIs. Now that we understand what API is, let us gain a better understanding of what REST means.
REST stands for Representational State Transfer. REST is an architectural style employed for providing standards for computer systems communicating with each other over the web. REST emphasizes the scalability of interactions between various components, uniform interfaces, independent deployment of components, and the creation of a layered system to facilitate separation of concerns between client and server systems. REST architecture has some rules that implement its architectural pattern and principles
- Separation of Client and Server
In the REST architectural style, the implementation of both the client and server are done independently and can be updated independently of each other. So long as each side is aware of the format in which the messages are to be relayed to each other, they can be kept as modular and separate. By separating the UI concerns from the data storage and management concerns, we improve the flexibility of the interface and also improve scalability by simplifying the server components.
An important feature of the REST architecture is the principle of statelessness, which basically means that the server does not need to know anything about what state the client is in and vice versa. In this way, both the server and the client can understand any message received, even without seeing previous messages.This principle of statelessness is enforced by the usage of resources and not commands. Resources are any object, document, or thing that you may need to store or send to other services. These constraints help RESTful applications achieve reliability, quick performance, and scalability.
- Communication between Client and Sever
In REST Architectural style, clients send requests to retrieve or modify resources, and servers send responses to these requests. A request generally consists of an HTTP verb (which defines what kind of operation to perform), a header (which allows the client to pass along information about the request), a path to a resource and an optional message body to contain any data. One can send multiple content types encoded in the request to the server from the client such as image, audio, video, pdf, json etc. Based on the request, the server generates a response along with the respective status code to alert the client to information about the success of the operation.
Thus, an API that follows the principles outlined above in the REST Architectural style is considered to be a REST API. They are an important part of the modern web programming process and knowledge of this concept is a prerequisite for building web applications in the current day and age.
DISCLAIMER: The author is solely responsible for the views expressed in this article. The author carries the responsibility for citing and/or licensing of images utilized within the text.