What is an API?
Understand the contract that lets two pieces of software work together.
Suppose a weather app shows the forecast for Kanpur. The app probably does not measure the weather itself. It asks another service for weather data and uses the response. The agreed way to make that request is an API.
An interface, not the whole system
API stands for Application Programming Interface. An interface describes how one system can interact with another: what requests are allowed, what information must be supplied, and what kind of response to expect. The API is not necessarily the underlying database or the complete program. It is the boundary through which another program can use selected capabilities.
You can think of it like ordering at a café. The menu tells you what you may ask for and the counter is where the request is made. You do not need access to the kitchen or its inventory system. In software, the API plays the role of that documented menu—but the comparison is only an analogy: software APIs can also enforce rules, permissions, and precise data formats.
A web API in practice
A web API often receives an HTTP request and returns a response. The request identifies an operation and may include parameters or data. The server checks the request, performs the permitted work, and responds—often with structured JSON data.
GET /api/books/42
{
"title": "A Short History of Nearly Everything",
"available": true
}In this simplified example, a client asks for a book with the identifier 42. A successful response might provide a representation of that book. Real APIs define additional details: which methods are allowed, how errors are reported, whether the caller must authenticate, and how much data can be requested.
API does not mean REST
REST is a set of architectural constraints commonly used when designing web APIs. It is one approach, not a synonym for API. APIs also exist between functions in a programming library, between an operating system and an application, or between devices. The common idea is a documented interface that lets software interact without exposing every internal detail.
What to remember
- An API defines how software can request information or actions from another system.
- The API is an interface; it is not automatically the database or the entire application.
- Web APIs commonly use HTTP, but APIs exist in many forms.
- REST is one common design style for web APIs, not the definition of an API.
Keep following what you understand. This article is part of a growing knowledge library; related topics can help you explore the ideas around it.