DEV Community

Cover image for A Beginner Guide to Learn API đŸŸ
AsibulRafi
AsibulRafi

Posted on

A Beginner Guide to Learn API đŸŸ

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.

whatisapi
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

how it 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.

Follow Me on ✔
Instagram LinkedIn

Top comments (0)