An API (Application Programming Interface) is a way for one program to ask another program for something.
The restaurant example
- You (the app) read the menu and order.
- The waiter (the API) takes your order to the kitchen.
- The kitchen (the server) cooks and the waiter brings back your food (the response).
You don't need to know how the kitchen works — only what you can order.
A real example
A weather app asks a weather API:
GET https://api.example.com/weather?city=Toronto
and gets back data like:
{ "city": "Toronto", "temp": 12, "sky": "cloudy" }
The app then shows that nicely on screen.
Where you meet APIs
- Paying online (Stripe's API takes the payment).
- Logging in with Google.
- Maps inside a delivery app.
- The live games on this site use an API to save top scores.
Keep API keys secret
Many APIs need a key (like a password). It must stay on the server, never inside the web page, or anyone could copy it and use your account.