What is an API and why should you care?

Kevin Berrio
5 min readJun 1, 2022

--

Imagine this scenario: Your employer calls you and tells you that because you have been such an incredible and outstanding performer, they want to reward you with two weeks of vacation, all expenses paid.

Photo by Anete Lūsiņa on Unsplash

But here is the catch: You have to do it the following Monday.

Would you do it?

The chances are that you might, and the odds are that as soon as you hear the great news, the first thing you will do is go to your internet browser and search for the best hotels, flights, food, and weather for next week.

You quickly find yourself on Google Flights, or perhaps Expedia, searching for a prime destination based on the weather you searched for next week, including flights, hotels, transportation, etc.

You get email and SMS confirmations once you book your flights, hotel, and transportation. You have the assurance that if there is anything wrong with any of your bookings, you expect an email or SMS alerting you of any unexpected changes to your itinerary.

Monday arrives, and you take off to enjoy a fantastic two weeks off. Sounds nice.

Did you, at any given moment, stop to think: How is Google Flights, Expedia, or any other online travel portal aware of every possible airline, flight, time, schedule, price, available hotel, car, and weather?

If you didn’t, that’s okay! But I hope that after reading this article, you will take a few seconds next time to think about what goes behind these incredible applications.

API or Application Programming Interface is simply a fancy term to describe a script or program that communicates information from a Server (big word for supercomputer) to an Application — the best way to explain how APIs work is through the following analogy.

Photo by Fraser Cottrell on Unsplash

Think of the interaction you have at a restaurant:

  1. You enter the restaurant and take a moment to observe the menu.
  2. You notice a couple of dishes that seem appealing to you.
  3. You request the waiter to get you the food you want.
  4. The waiter goes to the kitchen and lets the chef know your request.
  5. The kitchen prepares your food and delivers it to you through the waiter.
  6. If the kitchen can’t cook a dish for you, whether that is for lack of ingredients or because they can’t, the kitchen will let the waiter know to communicate that information back to you.
  7. As long as you are in the restaurant consuming the food, the waiter will periodically check on you to ensure you have everything you need.

Sounds pretty familiar, right?

Well, if that made sense to you, congratulations! You are halfway through understanding how APIs truly work.

To compare the restaurant analogy to an API, we can look at the following terms:

  • The customer is the Developer or Application.
  • The menu is the API documentation.
  • The waiter is the API.
  • The kitchen is the System or Server.
  • The food is the response.

Got it? Great! Let’s rewrite the analogy but in the API terms:

Photo by Ilya Pavlov on Unsplash
  1. You enter the API’s website and take a moment to observe the documentation.
  2. You notice a couple of endpoints that seem appealing to you.
  3. You request the API for the data you want.
  4. The API asks the Server/System whether the endpoints you requested exist and if they can be given to you.
  5. The Server/System prepares the endpoints and gives the API a successful response.
  6. If the endpoint does not exist or lacks access, the Server/System will let the API know to communicate that information back to you.
  7. As long as you request the API things that exist and have access to, the API will always respond to you with the information you need.

What is an endpoint? Endpoints are crucial components in your application’s interface with the API. For the most part, an endpoint will be a URL (for example, https:// MySuperApplication.com/news), which you may use to gain access to certain features or functionalities, which in this example, you may be getting the news from the MySuperApplication.com website.

As a developer, you can write a small script that will allow the API to communicate back to their system and fetch you the information, data, and processes you need without having to reinvent their entire ecosystem just for the data you initially requested.

The developer writes an application. The application requests stuff through the API. The API responds back with information. The information is used to fuel the application.

Allow me to use another example:

You want to save as much money as you can by flying from Los Angeles to London. If you go to Google Flights and search for a flight from Los Angeles to London, you will get a list of the best possible flights based on price, stops, and total flight time. You can have certainty that Google Flights will show you the best possible flights to your destination.

If APIs were not a thing, you would have to go to each airline’s website and search for the same flight multiple times and then compare which one would be best.

Each one of these airlines has created an API for other people (developers) or applications to consume. Instead of building an entire application around flights, I can request only the data that I need using their API.

Google Flights and many other online travel companies use these APIs to create beautiful and easy-to-use applications that ultimately allow the end-user to have a more dynamic experience while booking a flight.

But flights, hotels, and transportation are not the only things developers use APIs for. We need some critical and almost dependent APIs to run the world.

Here are the some of the most renowned APIs out there (and what they do):

  1. Google Maps — Plotting locations, such as local search results, as markers on a map is a simple use case.
  2. IBM Watson — IBM Watson’s technology is referred to as natural language processing (NLP), and it allows developers to access years of study through simple API requests.
  3. Twilio — Twilio provides a straightforward, well-documented API for voice and text. Send and receive phone calls, SMS text messages, MMS photos, and other types of communications.
  4. SendGrid — SendGrid was the first to introduce developers to transactional email. Its capabilities have now grown to incorporate real-time email data, prompted replies, and even certain marketing elements and email delivery.

APIs give you the power and flexibility to use someone else’s resources without worrying about having to build a brand new application.

Hopefully, next time you are booking your next vacation, send a message to your ride-share driver or get a weather alert; you remember that those things are possible thanks to the true power of APIs.

--

--

Kevin Berrio
Kevin Berrio

Written by Kevin Berrio

Technical Account Manager currently based in Florida, working remotely for Twilio.