When I first started at Leverege, I heard the development team say “API” all the time and realized that I should probably know what that meant. So what is an API? Perhaps like you, learning that API stood for Application Program Interface didn’t help me at all, and many of the results from Google remained unclear to a non-technical person like me.
But even if you’re not a programmer and don’t consider yourself the technical type, you should know what an API is. After all, APIs play an essential role in many of the products and services that we value today because APIs allow different programs to interact with one another.
So today, I’m sharing with you an analogy that I’ve found helpful in understanding what APIs are and why they’re so important to everything.
You’re home, you’re hungry, you’re lazy. Time to order some food.
You decide to order from Jack’s Burgers, so you look through their menu to see the options, then request a specific dish by placing an order. The order is received at Jack’s Burgers, passed along to the kitchen, and a series of steps are performed to create the dish. That dish is delivered to you and is quickly devoured.
Ok, you’re still hungry. But you don’t want another burger. You decide to go with Jill’s Pizza this time.
When you call Jill’s Pizza to place your order, what do you think would happen if you tried to order off the menu for Jack’s Burgers? You’d probably be met with confusion. You certainly wouldn’t get the dish you tried to order.
So What is an API? It’s like a Menu
In the above analogy, you’re a program and the restaurants are programs that you want to interact with. To receive what you want (food) from the other program (restaurant), you need to make a request (place an order) in a specific way (defined by the menu). If you try to request in the wrong way, you won’t get what you want.
APIs are like menus. Menus define a list of dishes and, when someone orders one of those dishes, the restaurant does a bunch of stuff and then sends the requested dish back. APIs define a list of commands and, when a program uses one of those commands, the other program does a bunch of stuff and then sends back what was requested by that command (usually some kind of data).
It’s important to note that the ordering food analogy isn’t perfect. When you order food, there are many variations you could use to get the same result. But programs aren’t as smart and flexible as humans. When making a request to another program, the request has to be formatted in a very specific way.
If restaurants were like programs, saying “House Burger, medium-rare, no pickles, replace the fries with coleslaw” would get you your food but saying “may I please have the House Burger cooked medium-rare with coleslaw instead of fries and no pickles on the burger” would not. The restaurant wouldn’t understand what you’re asking because the request isn’t formatted correctly.
So APIs define a list of commands as well as the necessary format of those commands. When a company releases an API for their software, it means that they’ve basically told everyone: here is what you can get from our program and here is exactly how you have to ask to get it.
Now You Know What an API is… so What?
APIs make it possible for programs to interact with each other. This is especially important for programs because they can be written in different languages, so APIs provide a means for different programs to overcome the “language barrier”.
Also, APIs mean that users of your program don’t need to leave your program to use someone else’s program. For example, by using weather.com’s API, you can request current weather data and display it on your site for visitors. That way visitors can get weather information without having to leave your website and go to weather.com.
Going back to the food analogy, APIs mean you can stay at home ordering different things from different restaurants without needing to go out to them.
Also, APIs reduce complexity. When you order food from a restaurant, many complex steps are strung together to complete your order. Chopping ingredients, precise heating, boxing the food, etc.. How annoying would it be if you needed to describe every step in the process when ordering to get your dish? Instead, you say the menu item and all the rest is taken care of automatically.
Similarly, when using an API to request something from a program, many complex processes may occur behind the scenes that you don’t have to worry about. You just get whatever it is that you requested in return.
A great example of this is the Alexa Voice Service API. Individual developers can’t build Natural Language Processing like Alexa, but instead, they can use Alexa’s API to make tools based on it. So rather than needing to figure out how to take speech and understand the meaning (which is really hard), developers can focus on cool new applications that involve voice control.
This is why APIs are hugely important to the Internet of Things. APIs allow companies to focus on their own expertise, plugging in the tools and programs of other companies as needed to create an IoT product/service that’s greater than the sum of its parts.