With 107K monthly searches for ‘what is an api’ across the globe (Ahrefs), it is clear that many people are struggling to understand the concept. Instead of going into lots of technical detail, Steven Waterman, Senior Software Engineer at TalkJS, helps you understand the basics by using 3 metaphors.
- An API is a common language: it helps different softwares to talk to each other
- An API is a menu: it lists all the data you can order
- An API is the door to your data: it will help you access data that may not be available to everyone
In short, an Application Programming Interface (API) is a way for two pieces of software to talk to each other. Using an API can speed up the development process. They allow developers to use and fine-tune functions from existing software, instead of having to build components from scratch each time.
To help you understand the basics, Waterman explains APIs in 3 metaphors, with each metaphor helping you understand a different aspect.
#1 An API is a common language
“The first metaphor imagines an API as a common language in a world filled with different languages—a bit like how English functions as a global language today. This metaphor helps you understand that APIs are used by two pieces of software to talk to each other, and without it they wouldn’t be able to communicate.”
As the language metaphor does not help you understand what the pieces of software are talking about, Waterman has come up with two other metaphors below.
#2 An API is a restaurant menu listing all the data you can order from a piece of software
This metaphor helps you understand that an API lists the available options, which may be categorized so you can quickly find what you need. For example: a chat API, which allows developers to add chat functionality to their project, may include different features like the ability to send and receive messages, add emojis, or see read receipts.
Waterman says: “The menu metaphor is useful, because it includes multiple concepts and the interactions between those concepts. However, it won’t help you transfer your existing knowledge about adjacent concepts. A great metaphor would let you use your existing knowledge about the metaphorical objects to infer things about the unknown concepts.”
#3 An API is the door to your data
While at first glance it is very similar to the menu example, it really shines when you start to infer other interactions between a door and a house:
“This metaphor allows you to transfer your existing knowledge about doors onto the new concept of APIs. This may lead you to conclude:
- APIs are used to access data, the same way a door can be opened to let anyone through, or it can be locked, only letting in those who carry a key.
- Some APIs could be open to everyone, while others need a key. If I lose my key, I could talk to the people inside and they’ll let me in.
- The API helps protect my data.
- You might be able to have multiple different APIs for one bit of data: like a house may have multiple doors.”
Examples of APIs
After reviewing the metaphors, it’s much easier to understand this technical concept. See below for some common ways APIs can be used:
- Google Maps, which can be embedded on a web page and will always show the up-to-date information.
- Similarly, services like YouTube, social media platforms, and weather apps will allow other programs to use their API to interact with or display their data.
- .ipify allows computer programs to pull your public IP address.
- AlsoAsked API allows developers to use ‘People Also Asked’ data from online search engines in their own software.
- Online payment processing: if you make a payment online, the system will communicate with the payment provider’s API to process the payment.
- TalkJS is a chat API that allows developers to integrate a messaging platform in their project without having to build it from scratch.