What is an “API”? Simply Explained!

If you are in the software industry this may not be an uncommon word at all! But for the beginners who are stepping into the technical arena, this may be a bit hard term to get from his/her first go. Without further due, will clarify the so-called term “API”.

What are these APIs? Exactly? And why were they created? Let me explain the problem with a simple non-technical example.

Client asks for what they want and waiter do the rest
Client asks for what they want and waiter do the rest
Waiter-Client Interaction(Real-world example for API usage)

When you go to a restaurant and order some food, you interact with the waiter, you can order food and drinks, ask questions about the menu, request and pay the bill and much more. In this example, the waiter is shielding you from all the complicated stuff that happens behind the scenes. You don’t have to worry about stoves, ovens, dishes, managing stock or pouring drinks. He’s the interface between you and all of the services that a restaurant offers, giving you a way to interact with the restaurant while still shielding you from all the complexity behind the scenes. You understand the Client-Waiter interaction right? If the answer is YES, you are good to go. Which means the waiter can be seen as the API of the restaurant. And through this example, you intuitively understand why they are useful.

Let's get into some techie stuff…

The term API stands for Application Programmable Interface, and it’s a way for different programs to work together in various ways. There are many types of APIs and reasons why they are used. I’ll highlight four of them in the blog so that you will get all that they are capable of. Simply, APIs can be used to get access to data from third parties.

In the restaurant example, the waiter can give you information on the status of your order without you having to go to the kitchen yourself.

Another example would be a weather app on your phone. Google or Apple have not gone out and put temperature sensors all over the world. Instead, these apps use the API of a third party to retrieve weather predictions. Apple, for instance, is using the API of the Weather Channel. APIs allow different apps and services to exchange information. These days, it’s hard to find a service that doesn’t have an API. There are APIs to look up recipes, lyrics, information on barcodes, zip codes, available parking spaces, public holidays, and so on and so forth. But aside from just accessing data APIs can also be used to hide complexity and perform tasks.

In the restaurant example, you don’t need to know how to prepare a perfect roll of sushi, you just order one.

Another example would be the operating systems on our computers and phones. App developers don’t have to worry about setting up a Wi-Fi connection, drawing shapes onto the screen to make a beautiful user interface, or how to talk to the various sensors like the accelerometer or GPS. No. Instead, the operating system gives developers a bunch of APIs that simplify all of this. If an app wants to show a button on the screen, it just asks the system to render one, the app doesn’t have to worry about what device it is running on what hardware it has screen resolution or anything like that. It makes developers more efficient because they can focus on what matters to them.

A high-level overview of how APIs work

But aside from accessing data, and abstracting complexity, APIs can also be used to extend functionality. For instance, iOS applications can show a widget in the Notification Center. And to do that the app notifies the system through an API that it has a widget available. If the user now adds this widget to their Notification Center, the system will contact the app and ask how would you display the widget.

Another example is Siri, google assistant or Alexa. These personal assistants are quite clever. But external developers can use the assistance API to extend the functionalities even further. My Google Home, for instance, didn’t know how to turn my smart outlets on or off. But that changed when the vendor integrated with the Google Assistant through its API. Suddenly, Google became aware of the new hardware, its capabilities and how to interact with it. You might not realize it, but APIs are all around us.

You’ve probably seen messages like these, “your phone asking for permission to use your location or microphone”. Did you noticed this with respect to the term API?.

This brings us to the final use case. APIs can be used as gatekeepers. For instance, on mobile platforms, the system only has a handful of APIs that can be used to get your location. And because it’s centralized in the system, it’s really easy for iOS or Android to notify you when an app is using your location. So it’s not the app that is being nice and asked your permission first. No, it’s the system that does it for them. There’s no way around it. What’s more, the system also gives the ability to revoke this permission and At a later time, should you change your mind. So every time your phone asks for your permission, you know that an app is using an API of the system, and one that is privacy-sensitive. And while this is great, there is an issue with this!!!. Usually, permission is only asked once, you might have used your Google or Facebook account to log into another website or app. It’s easy, fast and convenient. But by doing that, we also give the website or app the permission to access some of our data, like our name or email address. This is great because it puts us in control of our personal data. If you don’t want to share it, you just deny it. However, the problem here is that sometimes these permissions are long-lasting. And after a while, we forget what apps or websites we gave permission to access our data. This is what allowed Cambridge analytical to collect massive amounts of data through the Facebook API, they created a personality quiz that asked for permission to get some of your personal data. However, if you gave it permission, the app could silently access your data for months, even if you didn’t use it anymore. Instead, you had to revoke the permission through the Facebook website. So in short, APIs can act as gatekeepers protecting our personal data and only giving it out to the apps that we choose. But we should be aware of how long these permissions last and revoke them when we no longer use an app!!!.

So time to Sum all things up, APIs are all around us. There used to get access to data so that multiple apps or services can work together. They can also hide complexity for developers, allowing them not to waste time on figuring out how GPS works and etc. For instance, APIs can also be used to extend the functionality of existing systems. And finally, they can act as gatekeepers to protect our personal data. I hope my first very first blog brought some clarity to a topic that is mostly discussed among developers.

Tech Writer | Software Developer | Undergraduate — University of Moratuwa, Faculty of Information Technology.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store