# API introduction
API is a shorthand for Application Programming Interface, i.e. an ‘interface’ which allows communication between two applications:
- You address the API (= request)
- The API executes internal logic, unknown to the user
- The API sends back information (= response)
High level architecture of the above process:
APIs enable communication between applications
- One application exposes an API
- Exposing an API = giving functionality to the ‘outside world’
- Other applications can consume this API
- Consuming an API = making use of functionality given by an API (= calling an API and using the information given back by the API)
Biggest advantage: ABSTRACTION
- Your application should not know what happens ‘under the hood’ at the API, only the data you get back matters.
- What happens ‘behind’ the API is not known to the user or the consuming application → business logic of the exposing application is better protected.
☕ Abstract example of an API: the coffee machine ☕
The user wants a latte with extra milk:
- 🔌 Start the coffee machine
- ☕ Choose ‘latte’
- 🥛 Choose ‘extra milk’
- ✅ Press ‘start’
- ⏱ Wait until the latte is made
The user does not know what happens inside the coffee machine…
- They chose a latte with extra milk using the touch screen on the coffee machine, but did not specify which internal component of the coffee machine should perform which task.
- The touch screen serves as an API for the coffee machine: the user tells the touch screen what they want, and the touch screen sends this information to the internal components of the coffee machine.