What is an API?

 WHAT IS AN API ? 🤔


API/Server is an intermediate communicator to our  Physical Device(Computer💻/Mobile📱) and Database(Physical Device). In order to get the Data from Database We need to send the request from Device to Server. Then our requested server Fetch the requested Data from Database and send the requested data as a response to our requested device. 


So here, As a API creators we have to decide which data we have to fetch from the database, what data we have to send to the user Device, who can access the data and what is the request format. So We have to decide according to our Requirements. Software engineering is all about Requirements.  Before we start to design APIs we need to clarify above mention things. 


Basic understanding of API working Diagram.



I created above diagram for a Basic understanding of an API mechanism. To understand above situation. just consider this use case. You want to see your Science Exam marks on your University Website. Sometimes university website not only available in website, it  may have a mobile app. In this case just consider website. 






After you visited your University website result page. you need to type your index number and click the enter button to see the results. then this page will show your result. this is the normal use-case. so what is happening in this use-case?🤔


You sent a request to the https://www.youruniversitysite.com/results  page with your index number then your your university server sent a response back as the results. There are some format to send the request XML,JSON mostly used format is JSON. 


What is GET, POST, PATCH, DELETE ?


These are the requested format to the server.


GET - in order to get the response from the server.

POST - in order to post the post something to the server.

PATCH - in order to update something in your server.

DELETE - in order to delete something in your sever.


From above diagram(1) In order to create the Basic API. you no need to connect your server to the database. 

Here I'm going to show an example with Java Script framework NodeJS (with express framework)



This is the sample server setup using express framework. while creating the server express framework. make our code very less. 












 








Comments