ProDeveloperTutorial.com

Tutorials and Programming Solutions
Menu
  • Shell Scripting
  • System Design
  • Linux System Programming
  • 4g LTE
  • Coding questions
  • C
  • C++
  • DSA
  • GIT
  • 450 DSA Cracker
  • 5G NR
  • O-RAN

System Design Topic 7: REST API

prodevelopertutorial February 16, 2019

This topic we shall study about REST API.

what is an API?

API stands for Application Programming Interface. It is a set of tools for building an application. With the help of API it will be come easy for the programmer to build an application and distribute its services. With the help of API 2 different components can communicate with each other without knowing about each other.

REST API stands for REpresentational State Transfer API. It is based on HTTP. Now a day this is one of the most popular ways to communicate between multiple applications or Microservices because it uses less bandwidth.

As REST is based on HTTP hence it supports HTTP methods i.e. get, put, delete and post.

get() It will get the input from the user in a read only way.
put() It will help in creating new resource.
delete() It will help to delete a resource
post() It is used to update or create a new resource.

A “resource” can be anything with a name and can be stored. For example, in a login page, username and password are both resources.

To run any webserver, you need a server. Generally, we use Tomcat server.

Now coming back to our System Design, how does REST API is used in system design.

As I previously explained, as it uses less bandwidth, it can be used to communicate between multiple Microservices.

Generally the communication between client and database happens as shown below:

client ———-> API ———-> Database
<———-          <———-

So a client will communicate with a DB with the help of API. In API we write the logic to retrieve the data from DB and send it to the client. We send the data to the client using JSON format. Here API used will be REST API.

Usually a REST API will look like below:

https://prodevelopertutorial.com/api/q/question/2

The above API tells that I need question 2 and its answer. The response can be as shown below:

{
“question” : “what is the website name”,
“answer” : “prodevelopertutorial.com”
}

Below are some of the characteristic of REST API:

1. Uniform Interface:
As REST API is used to connect and transfer data between multiple devices, ways of accessing the API should be unique. REST uses Uniform Resource Identifier (URI) to map the resources and communicate between multiple components. The drawback it degrades the performance. But, since the information is transferred in a standard way, instead of specific to application needs, it can be considered as negligible.

2. Client Server:
RESI API is a client server based architecture. Here server does all the computational task and deliver result to the client. Multiple clients can be connected to a central server. This separation of user interface from the data computation will improve scalability and performance.

3. Stateless:
A REST HTTP request will send all the data required for the server to give the response. Once the request is completed, server will not remember the details of the request. Because of this property visibility, reliability and scalability will be increased.

Visibility is increased because, the server will look at the single point and does not have to search the data from other request.

In case of system crash, as we not saving and operating on the previous data, once the system is back up, new request with the latest data can be computed. Hence reliability will be increased.

As we are not saving any resources, server can free the resources once the request has been completed and give the space for other requests. Thus eliminating the need to manage the resource usage.

4. Cacheable
To improve the performance of application, cache is important. Cache is saving the data for later use. Cache constraints can be added to each resource. If the response from the server is cacheable, then the client will save the data for further use.

5. Layered System
Internet is consisting of multiple layers like client cache, server connector, server cache etc. A request can go through multiple layers to get the result. As REST API supports layered system, it is possible to communicate between legacy service to new services. We can encapsulate the legacy system into a layer and make them talk with the new system by simplifying the functionality.

How to create a REST API?

A REST API can be created by using JAVA, Node.js.

How to transfer data using REST API?

The data can be transferred using JSON, XML, plain text.

 

List Of Tutorials available in this website:

C Programming 20+ ChaptersC++ Programming 80+ Chapters
100+ Solved Coding QuestionsData Structures and Algorithms 85+ Chapters
System design 20+ ChaptersShell Scripting 12 Chapters
4g LTE 60+ ChaptersMost Frequently asked Coding questions
5G NR 50+ ChaptersLinux System Programming 20+ chapters
Share
Email
Tweet
Linkedin
Reddit
Stumble
Pinterest
Prev Article
Next Article

About The Author

prodevelopertutorial

Follow this blog to learn more about C, C++, Linux, Competitive Programming concepts, Data Structures.

Leave a Reply Cancel Reply

You must be logged in to post a comment.

ProDeveloperTutorial.com

Tutorials and Programming Solutions
Copyright © 2023 ProDeveloperTutorial.com
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT