Your driver is 4 minutes away
A delivery app says your food is 4 minutes away. A minute later it says 3.
The app does not know this by itself. It asks a server, the server answers, and the app shows the answer.
That question and answer happen millions of times a second across the web.
By the end of this lesson
Note
I can say what a request and a response are.
Key words
| Word | What it means | Example |
|---|---|---|
| Request | a message that asks a server for something | |
| Response | the server's answer to a request | |
| Method | the kind of request | GET |
| Status code | a number that says how the request went | 404 |
| Header | a named detail sent with a request or response | |
| API | a set of addresses a program can send requests to |
The cells students fill in are left blank in this preview.
A request asks and a response answers
The app is the client. It sends a request with a method, an address and some headers.
The server sends back a response. It has a status code, some headers and a body.
The body is the data itself, often in a format called JSON. An API is the set of addresses a server answers on.
A URL is an address in parts
| Part | In https://api.shop.example/orders/1042?fields=status | What it says |
|---|---|---|
| Scheme | https | How to talk: securely |
| Host | api.shop.example | Which server |
| Path | /orders/1042 | Which thing on the server |
| Query | fields=status | Extra choices for this request |
The cells students fill in are left blank in this preview.
The method says what you want
GET reads something and changes nothing. POST creates something new, such as an order.
PUT or PATCH changes something that exists. DELETE removes it.
The same path can do different jobs with different methods.
The first digit of a status says most
A code in the 200s means it worked. The 300s mean the thing has moved somewhere else.
The 400s mean the request was wrong: a bad address, a missing login, a missing field.
The 500s mean the server failed while it tried to answer.
Worked example: real responses
| Request | Status | What it means |
|---|---|---|
| GET /orders/1042 | 200 OK | Here is the order |
| POST /orders | 201 Created | The new order was made |
| GET /orders/9999 | 404 Not Found | No order has that number |
| GET /account, not logged in | 401 Unauthorized | Log in first |
| POST /orders, no items | 400 Bad Request | The request is missing data |
| GET /orders/1042 | 503 Service Unavailable | The server is down or too busy |
The cells students fill in are left blank in this preview.
A common mistake
Warning
Many people think every error is the server's fault. A 400s code means the request was wrong, so check what you sent. Only a 500s code points at the server.
Headers carry the details
A header is a name and a value on one line. content-type: application/json says the body is JSON.
Requests carry headers too, such as a login token. The tool curl -i prints a response with its headers, as below.
A real response with its headers
$ curl -i https://api.shop.example/orders/1042
HTTP/2 200
content-type: application/json
date: Tue, 20 Oct 2026 09:15:02 GMT
cache-control: no-store
{"id": 1042, "status": "out for delivery", "eta_minutes": 4}