Rest API : Every programmer should know about.

Rhea RB
2 min readNov 5, 2022

--

Either you are a frontend developer or a backend developer you need to know about Rest API(s).

It is a method of communication between the frontend and backend.

This blog will help you get the basic idea of working of the Rest API.

Rest API is an API that follows a set of rules known as REST.

Courier Example
An example is the courier service. In this case, the sender sends something and that something is delivered at the doorstep of the receiver and the sender gets message of successful delivery.

Here, the sender is the “Frontend”, receiver the “Backend” and the courier service “Rest API”.

CRUD Operations

CRUD stands for create, read, update and delete and that’s often used when talking about Rest API.
Rest API allows you to create , read, update and delete from the database using the backend server.

Real Example.
If you trigger this api,

curl --location --request POST 'https://rhea-bmi.herokuapp.com/v1/calculate/bmi' \--header 'Content-Type: application/json' \--data-raw '[{"Gender": "Male","HeightCm": 171,"WeightKg": 96}]'

You will see the below output,

{"success": true,"message": "Done","data": {"result": [{"Gender": "Male","HeightCm": 171,"WeightKg": 96,"Bmi": 32.8,"Risk": "Medium risk","Cateogory": "Moderately obese"}],"overweightCount": 0}}

Here’s what happened:
1. You type the URL
2. The frontend made a request.
3.The backend parsed the data based in the request made and returned a JSON response.

HTTP Methods
I
n Rest, every operation has a specific HTTP method giving an idea of what to do with the data,

The methods are
1. POST — create
2. GET — read
3. DELETE — delete
4. PUT — update(all data)
5. PATCH — update(specific)

Status Codes
Everytime a response is received, it has a number associated, called as Status Code.
The status code ranges between 100–599 and has a message.

Example :

200 status code stands for success.
400 stands for Bad Request.
500 stands for Internal Server Error.

That is all about REST API. Important and Super easy.

If you liked the post, please do follow me.
Thank you for Reading !!

--

--

Rhea RB
Rhea RB

Written by Rhea RB

Hello ! I am a senior software engineer, passionate about tech and product.

Responses (2)