If you are Web Developer youâve probably heard the terms API and If you donât you are gonna know about API in this Blog.
Even I also get tired of reading long Blog So I am gonna keep it as
simple , straight-forward as possible.
First. What is API ?
No API Doesnât stand for Apple Pie. An API is
âApplication Programming Interfaceâ
which allows users to access data and interact with servers, external software components . It allows application to talk to each other.
Each time you use an app that constantly receive or sends data. The Application connects to the internet and sends the data to the server. The server retrieves the data and performs necessary action and sends back the data to application.
If That Doesnât ring you any bell đ
Wait Let Me Explain this to an 6 Year Old.
Suppose youâre sitting in a restaurant. Thereâs Plenty of food item in the restaurant. You want a steak . So you call an waiter to order a steak. The Waiter take the order and give to the kitchen where your steak getâs ready. The chefâs do his magic like Salt Bae đ€đ»đđ» .When the steak getâs ready the waiter bring the food to your table and You enjoy the steak.
So Here you are the user and the kitchen/Restaurant is the server. Thatâs where the waiter or API comes in. That takeâs your request/order and tells the kitchen which is the system. And the waiter/API deliver's the response in this case it is the Food.
So Is it like I can request/Get anything from the Server ?
Letâs Talk about the securityđ
Youâre Accessing all web application using any kind of device. Letâs say youâre using your phone to get to a specific application. Because of that Youâre Phone doesnât expose all the data to the server and the server also doesnât fully exposed to your phone. Instead Each communicate by sending small data packets
sharing only necessary
Right now API are become more secure because of HTTPS / REST standards .
RE - Representational
S - State
T - Transfer
It is a standard that web application use simplify the communication with each other.
Now you might be wondering what is REST API ?
First of all the main characteristic of API is the separation between the client & the server.
So in the REST Structure the implementation of Client and the implementation of the server can be done independently without each knowing about other.
This means the code on Client and Server side can be changed without effecting each other.
So by using the REST API different clients or Computers hit the same REST endpoints perform the same actions and receive the same responses.
Systems that are follow REST principles are Stateless. The Server Doesnât know what state the client is and vice versa.
How API WORKS
The REST architecture clients send requests to Get or Modify resources and servers send responses to those requests.
An API request has to have an endpoint meaning the URL that we are requesting for.
For Example ,
Like In web browser, Whenever youâre going on a specific URL youâre basically just making a GET request to get that specific website.
Also API requires a Method which defines the type of you're Request.
Such as GET,POST,PUT & DELETE.
Which is done by CRUD which
C- Create
R- Read
U- Update
D- Delete
Headers are the Additional information for the client or the server which contain some information about body.
And Finally the body itself is the information sent to the server. Like Get a Specific website content or Create a user in some website.
Error 404 ???
Whenever you make one of the HTTPs request youâll be greeted with an HTTP status code.
There are 5 Major categories in Status Code.
1xx information response :
Everything that starts with 100s the request was received, something needs to continue. That is a informational Request.2xx Successful.
Everything that starts with 200s that means the request was successfully received, understood and accepted.3xx Redirects.
4xx Client-side Errors.
5xx Server-side Errors.
_
_
_
_
_
_
Thank you for reading.
I hope now you get a clear view about API.
If you want to learn more about API Click here.
Top comments (0)