What Is an API?
An API (Application Programming Interface) is a contract through which one software component can interact with another software component.
An API does not necessarily mean HTTP. APIs can exist between functions, libraries, operating-system components, databases, processes, and distributed services. A REST API is specifically an API exposed using HTTP concepts and REST architectural constraints.
For example, a frontend may request GET /users/42. The backend interprets that request, retrieves user 42, serializes the result, and returns an HTTP response.
The important idea is contract over implementation. The client should not need to know whether the server uses MongoDB, PostgreSQL, Redis, Java, Node.js, Go, or another technology.
- An API is a communication contract.
- HTTP APIs are only one type of API.
- Clients should depend on the API contract rather than server implementation.
What is the primary purpose of an API?