5. Body
The body contains the main information being sent.
For example, when creating an account:
Name
Email
Password
These details are sent in the request body.
4. Headers
Headers contain extra information.
Examples:
Authentication token
Language preference
Content type
Think of headers as an ID card that identifies who is making the request.
Another Example: WhatsApp
You type:
Hello
Your phone sends the message to the WhatsApp server through its API.
The server stores it and delivers it to your friend's phone.
All this usually happens in less than a second.
Process 3: The Server Processes the Request
The server stores data such as:
Videos
Photos
User accounts
Messages
The server searches for the requested information.
Process 2: The API Receives the Request
The API receives the request and checks if it is valid.
For example:
Does the video exist?
Is the user allowed to watch it?
Is the request correctly formatted?
Process 1: The Client Sends a Request
The client is the application asking for information e.g Your browser, WhatsApp, weather app etc
Example:
You open YouTube and click a video.
Your phone sends a request: "Please play this video."
In the above example:
You = Client (your app)
Waiter = API
Chef/Kitchen = Server
Food = Requested information
The waiter ensures everything is delivered correctly, just as an API does.
Another Example
Imagine you visit a restaurant.
You don't walk into the kitchen and cook your own meal.
Instead:
You tell the waiter what you want.
The waiter takes your order to the chef.
The chef prepares your food.
The waiter brings it back.