API = Application Programming Interface
An API is a set of rules that allows two software systems to talk to each other.
It acts as a bridge or contract between:
Imagine a weather app:
{
"city": "Bangalore",
"temp": "28°C",
"condition": "Cloudy"
}
You never see how weather is calculated—you just get the result.
APIs help systems:
Example:
API Styles
├─ REST
├─ RPC
├─ GraphQL
└─ SOAP
simple web rules
Uses URLs like:
GET /users
POST /orders
Example:
GET /weather/bangalore
calling a function on another computer
You call methods directly:
getWeather("Bangalore")
ask exactly what you want
Instead of getting fixed data, you request fields:
{
user {
name
email
}
}
Advantage: no extra/unwanted data
old, strict, formal system