Introduction to APIs π§©
Decoding the Language of Software CommunicationποΈ π‘
Introduction:
API! API! API! What is an API? Everyone is talking about APIs! Everyone says, "If you want to retrieve data, use an API." Many courses are teaching about APIs! But what exactly is an API? You may have gone through several definitions from sources like Wikipedia or GFG.
Wikipedia defines an API is a way for two or more computer programs to communicate with each other. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how to build or use such a connection or interface is called an API specification. A computer system that meets this standard is said to implement or expose an API. The term API may refer either to the specification or to the implementation. Whereas a system's user interface dictates how its end-users interact with the system in question, its API dictates how to write code that takes advantage of that system's capabilities."
Blah blah blah, it's very complicated to understand (like my girlfriend, hehe... just kidding, I don't have a girlfriend). Back on track, guys. Yeah, this definition may sound a bit complicated to a beginner or a non-technical person. You may have also heard about the example of a restaurant and a waiter, but it's quite an old example. Let's understand API in the simplest way possible, in my style (my way or the skyway) β¨.
What's in this Article:
What is API?
What API aims to achieve.
What is its use?
How you can implement it in your work.
Before starting, let's get into focus mode. Put everything aside and focus on the concept (like we focus on our crush...). So, without wasting much of our time, let's start.
To understand what an API is, we have divided this article into two chapters:
How to Communicate π£οΈ
How to Show Laziness π΄
If you understand both of these chapters, you will grasp the concept of APIs very well.
How to Communicate π£οΈ
Scenario 1: How to communicate! So, we are in different colleges. We took admission from different states and came together to study. Some of our friends speak Punjabi, some speak Marathi, and some of our classmates speak Telugu. But when we are at college, we decide on a common language that everyone could understand, mostly Hindi. Hindi is the language that everyone in your class can understand and speak, so we decide Hindi language as a protocol to communicate. Likewise,
The same problem arises in computers. Suppose YouTube's backend is written in Python, and the mobile app is in JavaScript, and many other languages. The problem is, how would all of these communicate with each other? The problem of communication can be solved using two factors: 1. protocol and 2. data. π₯οΈπ‘
Scenario 2: In the market, there are many programming languages. Many programmers use different languages to build a product. Suppose the video player you are watching is built using Java, the comment section is built using Python, and the like button is using JavaScript. Which moment you press the like button, in which moment the comment is given for a particular video. So, communication in computers is not so easy. You may have also thought someday about how different languages communicate with each other, and also how to build a system which is made from different languages but able to communicate using a single thing.
It's entry time, boys! πΆ BGM BGM πΆ Ladies and Gentlemen, here's our hero to save us, to make life easier for communication: INTRODUCING API! π
Back on track, so all the problems of communication in different languages are solved using APIs! APIs give us two things: one is protocol and the other is the data you want to send. If you build any system in Java, then we make APIs. It is nothing but it is data, but how to structure that data, what data type it is, deciding among us, and deciding how to send. The system which you have made through Java, so the coming system, if in Python or JS, will understand this, maybe it's a mobile app, web app, or server. Here our first chapter ends, now getting into the 2nd chapter.
How to Show Laziness?? π΄
(Is this API speaking about me? Awkward silence What do you mean I am lazy? 2 minutes silence π ) Back on track, suppose you are on any random website and trying to login. You see many options like login with Google, log in with Facebook, log in with GitHub, etc. And many times you have learned about building applications from YouTube. If originally you want to build a weather application, you'd require a satellite. Then we would send it to space (launching our first satellite to build our weather app, countdown 10, 9, 8...). Then after launching, you need to collect the weather data. Not everyone can afford launching a satellite for building a simple application. So how is the data coming into our application? Yeah, you guessed it right! You learned it from the 1st chapter - some third party is giving us data in the form of an API so we can communicate with that API to extract that data. ππ
If some website is using login with Google API, which means the system considers the user already has a Google account. So Google can verify the account and give the website required information like email. This is how the website outsources the login work with a simple Google API and saves much of their time building the login system from scratch.
These are the two major works of our API! The first one is communication and the other is solving our data. ππ
Conclusion:
By the way in the whole article, I haven't told you the full form of API! It's the assignment for you. you can comment down the full form of the API I have written his article based on the video uploaded by my favourite teacher, Hitesh Choudhary sir, from the channel "Chai aur Code". To fully understand the concept of API, below is the embedded video. π₯π¨βπ«
#chaicode #ChaiCode