REST API Architecture | Common Misconceptions About Everything
REST is the architectural style of the API. It is an abbreviation of REpresentational State Transfer.
Here, the term, API you might be aware of. API is an application programmable interface. Here I will explain to you how REST API is different from the general API.
The following are the characteristics that define the architecture of the REST API. These characteristics are like constraints to REST architecture to follow the standard guidelines.
Characteristics of REST API Architecture
1. Client-Server Architectures
REST follows the client-server architectures. It has adhered to stateless communication. So it does not store any client data on the server. Every request from the client is considered as unique. It runs independently from other requests from the same client.
Response from the server to the client contains data. These data packets can be cacheable or non-cacheable. If the data packets are cacheable, the previous data packet can be used by the client. It avoids requesting the same data from the server frequently.
3. Layered Systems
REST architecture follows Layered system constraints. So it distributes the knowledge of the system to multiple layers rather than a single layer. It hides complexity from one layer to another. Any layer is only visible to the just immediate layer.
It is true that it has a disadvantage as well. It imposes more latency and extra overhead of processing data at each layer.
4. Uniform Interfaces
REST architecture follows a uniform interface. The following are the points that describe how REST has a uniform interface.
To make things easy, let’s take resources as a Smartphone as almost everyone is fascinated by smartphones.
4.1 Identification of the Resources
Every resource is identified using unique identifiers. These identifiers are also called as REST URI.
ex. smartphone/apple/iOS/iPhoneS6 smartphone/google/Android/MotoG4
4.2 Manipulations of the Resources
The Manipulation of the resources is purely based on characteristic owned by the resources rather than actual resources.
Consider the same resource as a Smartphone. There are multiple representations available for the resources. The XML or pdf data format contents all the characteristics, pictures of the smartphone. The client can get all the information about the resources with available characteristics formats such as XML, pdf or picture. Even, they can modify the resources using the same data representation format. It is possible by sending HTML or XML or PDF data to the server.
5. Self-descriptive Messages
Each message transferred between the client and server is self-descriptive. Every message has information that describes how to process the message itself.
6. Hypermedia as the Engine of Application State (HATEOAS)
For all resources, representations have links to explore in detail. Simply you can correlate with web browsing. You can find the links inside other web pages link. You don’t need to know URI of the resources. But gradually you can find from its top-level resources.
Simply you can correlate with web browsing. You can find the links inside other web pages link. You don’t need to know URI of the resources. But gradually you can find from its top-level resources.
Take this simple instance. You may don’t have direct URI for iPhone S6. You can discover it by searching in Smartphone URI. Then narrow it to Apple URI and then iOS URI. Then you can choose iPhoneS6 URI. This exploration is also referred to as dynamic URI discovering.
For your further knowledge, I have answered 14 questions about REST API web services. If you are preparing for a job, going through these interview questions will definitely help you.
What are the Misconceptions about REST API?
Does REST API use only HTTP protocol over it?
You may have seen many times REST communicate over the HTTP protocol. But REST is not coupled with HTTP. In other words, we can simply say, it is not restricted to HTTP only. You can use REST over FTP as well.
What is RESRFul API?
Let’s, direct it. When do we call API as RESTFul API?
If the API is abiding with all the constraints imposed by REST architecture then that APIs are called as RESTFul APIs.
The system that constraint with all the REST characteristics then that system is called as RESTFul System.
Is SOAP API alternative to the REST API?
Another misconception I am coming across, most of us are thinking, REST API is the alternative to the SOAP API.
It is kind of different topic as we are comparing two kinds of APIs. So I have covered a separate post. You can read the difference between SOAP and REST Web Services. It gives you a better understanding of how REST API is far different from the SOAP API.
What are the major consumers of RESTful API?
Today every small or big farm that providing services is moving to RESTFul APIs. Here are some of the biggest projects under the belt of REST APIs.
- Facebook uses RESTFul APIs. Recently they have deprecated most of the old facebook developer APIs and now only supporting RESTFul APIs.
- Redfish is another big project for server management. It uses RESTFul APIs.
As a point of career opportunity, it is great to work on it. Personally, I am working on one of the projects. It uses the REST API for managing servers.
I tried to cover most of the topics from REST API that usually many find doubtful. Hope this article has helped you to understand in a better way.
If you have any questions or queries or just want to put some message, use the comment section below.