API is nothing but the connection between the two systems.
For example :
HERE budhha airlines is a main boss whos service is being used by the esewa, khalti, and IME Pay.
Esewa , Khalti , and IME Pay are the three tech apps . and we have to book the tickets from the esewa(let say there are three seats ) and booked it, and another person, let's say B booked the same tickets for buddha air from khalti then it will be updated to 1 seat left from 2 seats. and if again, another person booked the tickets from another IME pay then, no seats will be available for another person. This is just an example, how the system is getting used.
So, here buddha air is acting like a boss, who is serving them to the esewa ,khalti, and IME pay to use their server and use some portion or the features of its services. It wont give its database access, never coz if the database is deleted then who will be the responsible person.
let's illustrate with another example.
An API key is there, for more security. And, if someone is making a weather app, he can’t afford a big satellite,which is so costly right, so what he does is, he just buys or uses the free api from the website and generates the data of weather to his app. This is a basic insight on API.