What is an API and how does it work, explained simply?
I've read a dozen definitions and they all say 'application programming interface' as if that clears anything up. What is an API actually doing, in normal language?
An API is a set of rules that lets one piece of software ask another piece of software for something, without knowing how that other piece works inside. It's a request-and-response contract.
The restaurant analogy, because it's the one that actually maps correctly: you (the app) sit at a table. The kitchen (the server or database) has the food. You don't walk into the kitchen — you talk to a waiter (the API). The waiter takes your order in a format the kitchen understands, and brings back exactly what you asked for. You never need to know how the kitchen is organised, and the kitchen can be completely rebuilt without changing how you order.
What that looks like technically for a web API:
1. Your app sends a request to a URL, e.g. `GET https://api.example.com/users/42`.
2. The server does whatever it needs to — query a database, run logic, check permissions.
3. It sends back a response, usually JSON: `{ "id": 42, "name": "Asha", "city": "Pune" }`, plus a status code (200 = fine, 404 = not found, 401 = you're not allowed, 500 = the server broke).
The four requests that cover most of what you'll do:
- GET — read something
- POST — create something
- PUT/PATCH — update something
- DELETE — remove something
Why APIs matter so much in practice: they're how software gets built out of other software. A weather widget doesn't measure temperature — it asks a weather API. A checkout page doesn't handle card networks — it asks a payments API. Sign in with Google, embedded maps, sending an email from your app, an AI feature in your product: all API calls. Most of modern development is stitching APIs together with your own logic in between.
The practical way to make this click: open a free public API in your browser and just look at the raw response — you'll see the JSON that an app would receive. Then fetch it from a few lines of JavaScript and print it. The concept usually goes from fuzzy to obvious the moment you see real data arrive from a server you don't own.
One clarification that trips people up: 'API' doesn't only mean web APIs. Any interface a library exposes for other code to use is an API. But when someone says 'call the API' in a web context, they almost always mean the request-response thing described above.