What is an API? đ€·ââïž
How does two networks connect with a medium?
Motivation
âAn API that isnât comprehensible isnât usable - James Goslingâ
table of contents
- API ???
- How does it work?
- Illustrator
- Comparision and understanding
- Types of API.
- Conclusion
Note : This blog represents my way of understanding of API
1. API ???
What is an API? It is an acronym for Application Programming Interface. API is a medium for communication between client and server. The communication will be happen based upon set of definitions and protocols. In API appilication refers to the software and Interface is refferred to the contract of service between two softwares âdefinition from AWSâ.
2. How does it work?
Illustrator:
Letâs think of an example you went to a movie theatre or a multiplex to book a ticket for a movie.
- You will go to the ticket counter and ask the clerk to book a ticket for âGod Fatherâat âtop rowâ.
- The clerk will check in the booking portol the if the movie you requested is available or not if available they will check the seats are available or not.
- if seats are available they will book a seat.
- After successful completion of booking you will recieve ticket from them if not an appology.
Comparision and understanding:
there are three majaor components in the above example:
- You = client
- Booking portal = server
- Clerk = API
- Client will request the API for information/data with URI (universal resource indicator = movie name).
- The API will check the URI is proper or not .
- If itâs proper then it will communicate with the server and put the request you made.
- After making the request API will bring the response from the server.
There are several response codes present in the protocols indicating what happened. Each response code represents the info from the server which will be carried by API. RESPONSE CODES: 200-299 :- successful requests 300-399 :- Redirections 400-499 :- Client side errors (usually triggers when requests are not proper) 404 :- Not Found 403 :- Forbidden 500-599 :- Server side errors
Types of API
There are many types of APIs like SOAP, REST, WebAPI, RPC , GraphQL, etc⊠And these API are categorised into 4 categories.
- Private API: These APIs is restricted to only particular orgnizations/people.
- Public API: These APIs are accessble to everyone just like opensource available for public.
- Partner API: These APIs are accesible for external developers who are authorized.
- Composite API: This is the combination of any two APIs.
Coming two architecture level SOAP and REST are two API architectures majorly followed in most of the organizations.
Conclusion
An API (Application Programming Interface) is a set of rules that allows software applications to communicate. Itâs like a clerk at a movie ticket counter: you (the client) ask the clerk (the API) to book a ticket, and the clerk communicates your request to the booking system (the server).
APIs use response codes (like 200 for success, 404 for âNot Foundâ) to indicate the serverâs response. They come in different types (like SOAP, REST) and can be private, public, partner-specific, or a combination of APIs. They are crucial for enabling different software systems to interact seamlessly.
Bonus
What happens When you sent an request server (Website Request Lifecycle):
- Request a website.
- check local Cache for IP address.
- Check your recursive DNS server for address.
- Query root server to find authoritative DNS Server.
- Authoritative DNS server advises the IP address for the website.
- Request passes through a web application firewall(WAF).
- Request passes through a Load Balancer.
- Connect to Webserver on port 80 or 443.
- Web server receives the GET request.
- Web Application talks to Database.
- Your browser renders the HTML into a viewable website.
In Next
In the next blog we will be learning REST API
.