APIs are essential for interactivity and connectivity.
What is it used for?
It is usually so that data can be transferred from one computer to the other. It allows us to buy things online, post on social media, look up directions and much more.
So how does this actually work?
The API basically acts like a messenger. The computer that needs the information calls the API of the other, specifying how the data should be formatted. Then, the other computer returns the information in the format requested.
For example, if you are booking a flight from a travel service like skyscanner, the travel service interacts with the APIs of different airlines to get information and passes it back to the travel service so you can book your seat, find out the price of your ticket and pick a meal.