API, or Application Programming Interface, is one of the many acronyms thrown around in the programming world. It took me months to grasp the concept, not least because APIs can look very different from each other, depending on what they are trying to accomplish.
The best, high-level conceptualization I've come up with that encapsulates them all is that APIs are a simplified way to interact with complex information. That still sounds kind of vague. Let's look at some examples.
The picture in the header of this article shows an old radio. We can actually think of this radio, with its three dials, as an API for transforming radio waves into sound and having some control over them.
We don't have a way to directly access radio waves without a radio. Nor would we probably want to, that's a lot of complex information to handle. So, someone devised this simple interface that gives us the ability to switch between different frequencies, control the volume, and turn the radio off and on.
There is a lot more you could do with radio waves that has nothing to do with listening to music, but we don't need to be bogged down with all that stuff. The radio API just gives us what we need.
Similarly, in the programming world, we frequently want to easily incorporate data from other complex sources to make our projects more dynamic and useful.
Let's say I'm making a weather app. How do I get the weather data to display on my home screen? Do I have to collect and maintain it all myself?
Lucky for me, someone else has already done that and created an API that allows me to access and use that data. It doesn't have physical dials but there are instructions on how to use it and it only gives me what I need, not the hoards of information that come with monitoring the weather, just like the radio.
This is great news! Not only do I not have to collect my own data, I also don't have to spend an inordinate amount of time sifting through someone else's data. This saves me a lot of time.
It also allows the creator of the API to let other people use some of their data while keeping some private.
This might be like how Pinterest provides an API for your website to use its icon to save something to a board without having to give you all of its user or proprietary information. You get to give your users the ability to harness the power of Pinterest and Pinterest gets to reach more people. It's a win-win for everyone!
The wonderful world of APIs