đŸ§© Why Do We Need APIs Anyways?

Written by mohitmamoria | Published 2020/02/07
Tech Story Tags: api | rest-api | technology-trends | learning | management | wtf | hackernoon-top-story | wht-do-we-need-apis

TLDR An API - Application Programming Interface - is the way computer programs talk to services (other computer programs) An API allows other computer programs to interact with a service. API is used in so many different contexts that it’s easy to lose the track of the conversation and left hanging in there, wondering, “Why the heck we need APIs?” An API is a User Interface, or simply called UI - a screen (on desktop, laptop, or mobile) through which a ‘user interacts with a. service’via the TL;DR App

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,
  • if you’re a manager, you can engage in better conversations with the engineers,
  • if you’re a geek, you can send your managers and non-technical friends to this article for them to get a grip on the basics.
By the way, I am the editor of KnowyKnowy, where I teach difficult subjects like this one in simple language. Support me there?

What is an API?

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.

Why does the world need APIs?

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.

Written by mohitmamoria | I teach difficult subjects in simple language.
Published by HackerNoon on 2020/02/07