An API (application programming interface) is the set of rules one program uses to ask another for data or actions: what you can ask for, how to ask and what format the answer comes in. That is how a weather app shows the forecast without measuring anything: it asks a weather service's API.
📱The app builds a request→📨It reaches the API→🗄️The service looks it up→📦The answer comes back
Put it to the test
A question from the app. Pick an answer.
Your app asks a weather service's API for the forecast. What does it get?
The database stays on the service's side. A response travels through the API, not the whole database.
The API defines what you can ask for and how the answer comes back, for example JSON with the temperature. The database and the server stay on the other side.
Your app does not get into the server: it sends a request, and the server decides what to answer.
Your phone does not measure the temperature outside. When you open the weather app, it sends a request to a weather service's API: "give me the weather in Rosario". The service, which does collect measurements, answers with a few tidy pieces of data, often in JSON, and the app draws them with its own icons and colors.
That is why two weather apps can show the same numbers with different designs: they ask the same API. And if the service goes down, the app may stop getting fresh data.
The request: a fictional example
GET https://api.example.com/v1/weather?city=rosario
The most common mistake is using them as synonyms. The database is where the service stores all its measurements. The server is the computer that receives requests and handles them. The API is the agreement: which questions are accepted, with what data and what shape the answer takes.
Your app never sees the database or gets into the server: it only gets what the API chooses to expose. What it can read or change depends on the operations and permissions the service provides. That is the point: the service can switch databases or move servers, and as long as the API answers the same way, your app keeps working.
The APIs you use without noticing
The "Sign in with Google" button, the map inside a delivery app or paying by card in an online store are another company's APIs used from your app. AI too: the AI buttons in many apps talk to a model through an AI API and authenticate with an API key. To connect an assistant to tools there is also MCP, which also runs on requests and responses.