An API is an interface that lets one program talk to another without opening its files or database.
Instead of directly accessing databases or files, applications go through APIs. APIs define what requests are allowed and what responses you'll get. REST APIs use HTTP requests, GET to retrieve data, POST to create data, PUT to update, DELETE to remove. GraphQL is an alternative where you specify exactly what data you want and it returns only that.
GRPC uses protocol buffers for higher performance. Every modern application is built on APIs. A web application calls backend APIs.
The backend calls database APIs, payment APIs, analytics APIs. Everything is mediated through interfaces. APIs abstract complexity. You don't need to know how the backend works. You just know that if you POST to /create-account with username and password, you get back a response. This abstraction enables teams to work independently. The API is the contract.
Frontend developers can work on UI while backend developers build the system behind the API. Designing good APIs is an art. A bad API is hard to use. A good API is intuitive. Endpoints are named logically. Responses are predictable. Error messages are clear. API design decisions made early shape what applications can build on top.
MDN defines an API as a set of rules for software to talk to other software. The browser's fetch() call is an API. So is Stripe's HTTP interface.
API Communication
Explore how applications communicate through different API types