If youâve been anywhere close to a computer engineer, youâd have definitely noticed them drop the term - API. A software engineer would use the term for so many varied purposes that itâs easy to lose the track of the conversation and left hanging in there, wondering, âWhy the heck we need APIs?â
In my decade long career of working with engineers and managers, thereâd rarely be anything else more confusing than API - simply because the term is used in so many different contexts. So, let me break it down in simple English, so that,
By the way, I am the editor of KnowyKnowy, where I teach difficult subjects like this one in simple language. Support me there?
Because youâre here, Iâm assuming that the definition that Wikipedia provides didnât really come in handy. Letâs start with the full-form of API - Application Programming Interface.
Wow! Thatâs quite a mouthful of jargon thrown in together. Donât worry, weâll break it down one by one.
First, from the full-form, we know itâs some sort of an interface. But whatâs an interface? Can we think of some other interfaces that we might have used? Well, thereâs one - User Interface, or simply called UI.
Note: If you donât understand whatâs even a User Interface, ping me on Twitter here and Iâll get you sorted.
In our context, a User Interface is a screen (on desktop, laptop, or mobile) through which a âuser interacts with a serviceâ. The service could be a social networking website, a flight booking mobile app, or simply a blog like this one. Through this interface, users (human beings) get to use the service, as these services are optimized for our senses - eyesight, hearing, touching.
However, a computer program doesnât have any of these senses.
While they have a hard time understanding the visual design, they are superior at understanding written text. An interface thatâs made so that a computer program can interact with it, is called Application Programming Interface (âapplication programâ can be used interchangeably with âcomputer programâ in this context).
In short, an API allows other computer programs to interact with a service. But why do we need computer programs to talk to each other? Letâs see why.
Now that we know that the APIs are the way how computer programs talk to services (other computer programs), the question arises, why do we need them at all.
For us to realize the value of APIs, letâs consider an example.
A world without APIs
One sunny morning, you announce it to the world that youâre starting a business of helping people search and book flight tickets. You get yourself an office, a table, a chair, and a laptop. Youâve got the website of all the airline carriers opened in different tabs of your web browser. Youâre ready for business!
A few minutes later, your best friend calls you and asks, âHello friend, can you help me book the best flight from New York to Los Angeles?â
You say,
âCertainly, my friend. When do you want to go?â
âFebruary 14, please,â your friend replies.
âMorning or evening?â
âI plan to surprise my long-distance boyfriend, so, morning please.â
âOkay, can you hold on for a minute, please? Iâll search for the best flights for you.â You put the call on hold and start frantically searching for the best flight. You have zeroed down on a few options. You start telling your friend, âOkay, I have got a few options for youâŠâ
While youâre narrating the options, your friend interrupts you and says,
âWell, I think, itâd be best if I travel a day before on February 13 instead. Can you please search for the best flights for a day before, please?â
Being the kind businessman that youâre are, you hide your disappointment behind your enthusiastic voice, and respond,
âNot a problem at all, my friend. Give me a moment please.â
After an hour of to-and-fro, finally, youâre able to find the best flight for your best friend. You ask your friend to send $139 to your account right away, so that, you can book a flight on their behalf.
Your friend fiddles with their phone and after spending some time, they make an online transaction of $139 to your account. Once you receive the amount, you start to book the said flight, and thatâs when you realize that the fare has increased by $35.
Slightly embarrassed, you pass the news to your friend, and they take a few more minutes to send you an additional $35.
After a long phone call, searching frantically across various airline carriers, making multiple bank transactions, your best friend can finally surprise their boyfriend.
As soon as you hang up the call, your neighbor calls and tells you, âI want to travel to Iceland this summer with my family. Can you help me book  a flight, please?â
You sulk realizing this phone call would be the same adventure all over again. Regardless, you proceed to help your neighbor.
A few more calls later, the day ends, and with it, you decide to shut the shop. It isn't worth it!
Thatâs the problem when human beings work as âglueâ trying to make multiple pieces move together - taking instructions from customers, searching for the same thing across many airline carriers, comparing the options manually in the head, verifying the received payment, book the flight, etc.
Human beings arenât efficient in being the glue. Computers are.
An API powered world.
Now, letâs look at the world that is powered by APIs.
You announce it to the world that youâre in the flight booking business, and anyone can search and book the best flights "on your website".
Your website takes the input from your customers, then talks to all the airline carriers via their API, gather all the results, compare and find the best flight, and shows to your customers, within seconds.
Once the customer selects the flight, your website talks to their bank via APIs and accepts the payment.
As soon as the payment is confirmed, your website books the flight on behalf of the customer with the selected airline carrier via APIs.
Your website does it all by itself, while you sit in your corner office and count the cash.
The ability of computer programs talking to each other, via APIs, makes it possible to automate almost everything one can think of.
That's why we need APIs, so that, computers can talk to each other, without requiring any human being.
Have feedback? Say hello on Twitter. đââïž If you want to learn more about API and other such topics, join me on KnowyKnowy.