What is Rest API

Jul 17, 2023

image

Either you’re a frontend developer or a backend developer, you need to know about Rest API(s). They is a way to make communication between the frontend and the backend of the applications.
This guide will help you to get a basic idea of the working of the Rest API.


Restaurant Example

Let’s understand it with the restaurant example. If you visit a place for food, you interact with the waiter to order your food.
The key persons are you (Frontend), waiter(Rest API), and the restaurant (Backend). You give your food order to the waiter, wait for your order and it’s delivered to you.

image


Courier Example

An example is the courier service. In this case, the sender send something and that something is delivered at the doorstep of the reciever end and the sender gets a message of successful deliver.
In this case the sender is Frontend, reciever being the backend and the courier service being used is the Rest API.

image


Real Example

If you make a visit to the following link:

https://api.github.com/users/SimoneVB

You’ll see a JSON format data


{
"login": "SimoneVB",
"id": 1105181,
"node_id": "MDQ6VXNlcjExMDUxODE=",
"avatar_url": "https://avatars.githubusercontent.com/u/1105181?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/SimoneVB",
"html_url": "https://github.com/SimoneVB",
"followers_url": "https://api.github.com/users/SimoneVB/followers",
"following_url": "https://api.github.com/users/SimoneVB/following{/other_user}",
"gists_url": "https://api.github.com/users/SimoneVB/gists{/gist_id}",
"starred_url": "https://api.github.com/users/SimoneVB/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/SimoneVB/subscriptions",
"organizations_url": "https://api.github.com/users/SimoneVB/orgs",
"repos_url": "https://api.github.com/users/SimoneVB/repos",
"events_url": "https://api.github.com/users/SimoneVB/events{/privacy}",
"received_events_url": "https://api.github.com/users/SimoneVB/received_events",
"type": "User",
"site_admin": false,
"name": "SimoneVB",
"company": null,
"blog": "",
"location": "Italy",
"email": null,
"hireable": null,
"bio": null,
"twitter_username": null,
"public_repos": 2,
"public_gists": 0,
"followers": 1,
"following": 0,
"created_at": "2011-10-05T15:39:12Z",
"updated_at": "2023-05-05T15:05:43Z"
}


Step by Step

Here’s what happened:

  • You type the URL

  • The Frontend makes a reques

  • The Backed parses the request based on the data recieved from Fronten

  • The Backend returns the JSON data


We’re done for today!

I hope this article is useful for you.
If you have any questions or suggestions, please feel free to contact me.
Finally, if you liked this article, a "coffee" will be appreciated ;-)

If you like it, take a look at my website https://www.simonescigliuzzi.it

Подобається цей допис?

Купити для Simone Scigliuzzi каву

Більше від Simone Scigliuzzi