What is Rest API ?

Getting to Know About “API”, “Rest API” and how to use Rest API effectively for Communication.

Lasitha Hasaranga Muthukumarana
4 min readJan 31, 2024

Introduction

In the modern digital era API plays a crucial role in communication between different software systems. Then having a better knowledge about fundamentals of APIs becomes more important than ever. Therefore in this blog post we are going to discuss “What is API” and “How it works” with a special focus on the most popular “Rest API”.

API

API stands for Application Programming Interface. Simply it’s a communication mechanism and for real life example It’s work as a Waiter in a Hotel.

svsdavv
Author by geeksforgeeks.org

Going through this example it works Customer as Client/User with browser and Chef as Server/Back-end System. However the API gives data access to the user but the user doesn’t know about what is happening in the background and its process. Also the user receives a response according to the user request. On the technical side Client requests data from server and the server reads the request and sends the response to the Client according to the request.

Why API ?

The main reason is that the API has the ability to seamlessly share data and functionalities between diverse software systems. Also API increases development speed because each functionality doesn’t have to be written from the beginning. We can use APIs to use existing code rather than rewrite the code.

Finally we use APIs in our day to day life works. For example when you’re booking a ride-sharing service like “Uber” or “PickMe”, checking the weather on your mobile device, Travel booking, Pay with PayPal, Financial apps, Google maps, and Twitter. These services are based on the APIs.

Rest API

Before going to Rest API let’s talk about What is Rest. Rest is an architectural style and it stands for Representational State Transfer. Also Rest architectural style has 6 constraints(5 are Main and 1 Optional).They are,

Uniform Interface(The way of accessing a resource is same)
Client Server(Capable of implement the Client and Server individually/Have loosely coupled behavior)
Stateless(Server doesn’t maintain any state for Client and Client need to maintain the states)
Cacheable(Frequently using data stored in easily accessible place)
Layered System(Sever works as different layers and to generate response all layers are working together)
Code on Demand(Optional) (Taking executable code as a response)

If any API follows above 5 main Constraints it Called as Rest API or Restful API.

Parts of API

The main parts of the Rest API are “Request” that is sent from Client to the Server, and the “Response”, that is received back from the Server.

However, Request is the main part here. Because the server responded the way we sent requests to the server. The way we “Request”, guide what are the types of things that we should want to do with a Rest API. The Methods of Request is simply Called as “CRUD”. “CRUD” stands like below,

Benefits of Rest API

When talking about benefits, the first one is that it’s simple and standardized. Also Rest APIs are scalable and can be easily modified when a system grows in complexity. It’s Stateless, because we don’t have to worry about what data is in which state and keep track of that client and server. Another benefit is they support Caching, caching helps in keeping high performance when the system gets more complex.

Moreover it has flexibility and independence. When we talk about independence, we can write Rest API using any different programming languages and technologies like Node js, php for server side and React, Vue js, Angular for client side.

Summary

In summary, whether you’re a seasoned developer or someone just starting in the world of software development, this blog post aims to give some basic understanding of the world of APIs, with a focus on the versatile and widely adopted REST API, covering their definition, working principles, constraints, components, methods, and it’s benefits. Also we explored into the world of REST APIs, exploring their architecture, key components, and real-world applications.

--

--

Lasitha Hasaranga Muthukumarana

Undergraduate at University Of Moratuwa Faculty of Information Technology. I am happy to share my knowledge with others. Also learning from my mistakes everyday