What is REST API or RESTful API (Representational State Transfer) ?

REST API or RESTful API

To understand REST API, Lets first understand what is API?

API stands for Application Programming Interface basically means a gateway of information transfer. Let us assume that you are an Android Developer and wants to build an app that helps people to get railway ticket information. So how will you start your project? to do this Indian Railways or any other organisation would provide an API or gateway to connect your application.

REST or RESTful API design (Representational State Transfer) is designed to take advantage of existing protocols. It basically uses HTTP to request and receive information over the internet. You already know that developers do not need to gather information about the Railways. Information is updated and managed by other organisation, as a developer, you are using that API or HTTP request to get the information ( Usually in XML, JSON response ) and representing as per your design pattern.

Understanding REST API Design

While most APIs claim to be RESTful, they fall short of the requirements and constraints asserted by Dr Fielding. There are six key Features to REST API design that means this constraint should be in your API. 

Client-Server

The client-server constraint works on the concept that the client and the server should be separate from each other and allowed to evolve individually and independently. Why is it so? Because you should be able to update you application or the organisation also able to upgrade/change their data structure or database. This creates a separation of concerns, letting each application grow and scale independently of the other and allowing your organization to grow quickly and efficiently.

Stateless

REST APIs are stateless, meaning that request can be made independently of one another, and each request contains all of the data necessary to complete itself successfully. Each request or call has the necessary data in itself, such as the API key, access token, user ID, etc. By these information, you are telling the server what actions should be taken while processing the current request or call.

Cache

what is Cache? The cache is something usually data that is stored in the system for a short period of time.  A REST API should be designed to encourage the storage of cacheable data. This constraint helps the server to function efficiently and effectively. Always keep in mind that caching is done on the client-side.

Image Source-API Academy

Uniform Interface

The key to the decoupling client from the server is having a uniform interface that allows independent evolution of the application without having the application’s services, models, or actions tightly coupled to the API layer itself. The uniform interface lets the client talk to the server in a single language, independent of the architectural backend of either. This interface should provide an unchanging, standardized means of communicating between the client and the server, such as using HTTP with URI resources, CRUD (Create, Read, Update, Delete), and JSON.

Layered System

As the name implies, a layered system is a system comprised of layers, with each layer having a specific functionality and responsibility. If we think of a Model View Controller framework, each layer has its own responsibilities, with the models comprising how the data should be formed, the controller focusing on the incoming actions and the view focusing on the output. Each layer is separate but also interacts with the other. In REST API design, the same principle holds true, with different layers of the architecture working together to build a hierarchy that helps create a more scalable and modular application.

Code on Demand

Perhaps the least known of the six constraints, and the only optional constraint, Code on Demand allows for code or applets to be transmitted via the API for use within the application. In essence, it creates a smart application that is no longer solely dependent on its own code structure. However, perhaps because it’s ahead of its time, Code on Demand has struggled for adoption as Web APIs are consumed across multiple languages and the transmission of code raises security questions and concerns. (For example, the directory would have to be writeable, and the firewall would have to let what may normally be restricted content through.)

 

 

 

Popular posts


Mr Jack

Jack is a Data Scientist, ML & DL Engineer, Educator, Social activist. He plays a vital role in Ai next mission of Youth Empowerment.

Comments & Questions (1 conversations)

Mohit Vyas · 4 years ago

This is theoretical part of REST API. I found it very helpful. Can you tell me more about Implementations REST API.

64x64

sabir ansari @ Mohit Vyas · 4 years ago

yes, you are right mohit. I'll surely write on API implementation in real world applications. Thanks for reading and commenting.


Leave a comment

See Posting Guidelines Login to reply