Intuition The ONE core idea
A REST API is a shared postal system for data : your program's "things" (a user, an order) each get a permanent street address (a URL), and the outside world sends short standardized letters — read this, replace that, delete this — to those addresses. Everything else in the topic (methods, status codes, versioning, pagination) is just the grammar of those letters and the replies.
Before you can read the parent note, you need to own every piece of notation it quietly assumes. We build each one from nothing, anchor it to a picture, and say why the topic needs it . Read top to bottom — each brick sits on the previous one.
Definition Client / Server
A server is a program that waits, holding data, ready to answer questions. A client is a program that asks. Your phone app is a client; the company's computer holding all the users is the server.
Picture two people passing notes. One person (the client) writes a request note and hands it over; the other (the server) reads it, does the work, and hands back a reply note. Neither ever sees inside the other's brain — only the notes cross the gap .
Intuition Why the topic needs this
REST is entirely about the shape of those two notes: the request note and the reply note. If you don't picture the gap between client and server, phrases like "the server replies with a status code" have nowhere to live. Everything below is either something written on the request or on the reply .
Related deeper reading: HTTP protocol .
HTTP (HyperText Transfer Protocol) is the agreed format for those notes. A protocol is just a rulebook both sides follow so a note written by one is understandable by the other — like agreeing that a letter starts with "Dear ..." and ends with "Sincerely".
Every request note in HTTP has the same fixed layout:
And every reply note:
You'll meet each labelled part below. Notice the parent note's whole structure — "HTTP Methods", "Status Codes", "the body is JSON" — is just: fill in these blanks .
A URI (Uniform Resource Identifier) is the unique name of one thing. A URL is a URI that also tells you where to find it . For our purposes treat them as the same: the address string like /users/42.
Break the address into parts you can see:
/users — a collection (a folder holding many things).
/users/42 — one item inside it (the user whose id is 42).
?limit=20&offset=40 — the query string : extra knobs after the ?, joined by &, each written key=value.
Intuition Why the topic needs this
The parent's central rule is "URLs name nouns , not actions". You cannot judge whether /deleteUser is bad design until you can read a URL and see that delete is a verb hiding in the address — it belongs in the method (Section 5), not here. The ?key=value&key=value grammar is exactly what pagination (?limit=20&offset=40) rides on.
The / slash separates levels, like folders on a computer. Reading /users/42/orders/7 left to right: "inside users, the one with id 42, inside its orders, the one with id 7."
Definition Resource · State · Representation
A resource is the "thing" living at an address (user 42). Its state is the current values it holds (name = Ada, email = ada@x.com ). A representation is a written snapshot of that state you can put in a note — usually JSON .
JSON is text that writes data as key: value pairs inside curly braces. It is how the body of a note carries structured information.
{ "name": "Ada", "email": "ada@x.com" }
Read it as a labelled box: the key "name" points at the value "Ada". Square brackets [ ... ] mean a list , e.g. [ {...}, {...} ] is "a list of two boxes".
Intuition Why the topic needs this
The "R" and the "T" in REST are literally R epresentational state T ransfer: you never move the real resource, you move a JSON snapshot of its state back and forth. When the parent says "PUT is a full replace — omitted fields get wiped", it means the snapshot you send overwrites the whole box, so a missing key erases that value.
The method is the single word at the front of the request that says what you want to do to the resource at that address. There are only a handful: GET, POST, PUT, PATCH, DELETE.
Picture the same address /users/42 as a mailbox, and the method as a rubber stamp you press on the envelope before sending:
GET stamp = "send me a copy" (read).
POST stamp = "here's a new one, file it" (create).
PUT stamp = "replace what's there with this".
PATCH stamp = "change just these fields".
DELETE stamp = "throw it away".
Intuition Why the topic needs this
This is the "uniform interface" idea: because the verb is a fixed stamp and not baked into the address, once you can read/create/update/delete one resource you can do it to every resource. The parent's whole methods table is just these five stamps applied to a collection vs an item.
Two words the parent leans on hard:
Definition Safe · Idempotent
Safe = pressing the stamp changes nothing on the server (a GET just reads). Idempotent = pressing the same stamp many times leaves the server in the same final state as pressing it once.
Intuition The picture of idempotency
Imagine a light switch labelled "OFF" (that's DELETE, or PUT-to-a-value). Flip it once → off. Flip it again → still off. Ten times → still off. Same ending, no matter how many presses. Now imagine a "add one coin" button (POST create): press it three times, three coins. Not idempotent. This is exactly why a timed-out payment retry is dangerous with POST and safe with PUT.
Deeper: Idempotency and retries .
A header is a Name: value side-note attached to the envelope, carrying meta -information rather than the main data. Examples: Content-Type: application/json ("the body is JSON"), Location: /v1/users/42 ("the thing I just made lives here"), Accept: application/vnd.myapp.v2+json ("please answer in version 2").
Picture sticky notes on the outside of the envelope — the letter inside is the body; the sticky notes are headers telling the sorter how to handle it.
Intuition Why the topic needs this
Header versioning, the Location header returned by 201 Created, and caching with ETag all live here. When the parent says "include a Location: header", it means "stick a note on the reply telling the client the new address." See also Caching and ETags and Authentication vs Authorization (the token you log in with travels in a header).
A status code is a 3-digit number at the top of the reply that summarizes what happened , in a form a machine can branch on without reading English.
The first digit is a family. Think of it as the mood of the reply:
Intuition Why the topic needs this
The parent's biggest "mistake" callout is returning 200 {ok:false}. You can only see why that's wrong once you know the status code is the machine-readable headline: monitoring tools, browser caches, and client libraries all decide what to do by reading only that number . Hiding a failure behind 200 blinds every one of them. The famous members (201, 204, 400, 401, 403, 404, 409, 429, 500, 503) are just specific citizens of these families.
The pagination section uses two symbols a 12-year-old may not have met.
Definition Floor and Ceiling
⌊ x ⌋ (floor ) = round down to the nearest whole number. ⌊ 2.3 ⌋ = 2 , ⌊ 2.9 ⌋ = 2 .
⌈ x ⌉ (ceiling ) = round up to the nearest whole number. ⌈ 2.3 ⌉ = 3 , ⌈ 2.0 ⌉ = 2 .
Draw the number line. Floor jumps left to the nearest fence-post (integer); ceiling jumps right . If a number is already a whole number, both stay put.
Intuition Why the topic needs this
"How many pages hold N items, L per page?" If 23 items sit in bins of 10, you get 2 full bins and a third half-empty bin — you still need that third page. Rounding down would throw away the leftover 3 items; rounding up keeps them. That's why total pages is ⌈ N / L ⌉ , and the whole-number identity ⌈ N / L ⌉ = ⌊( N + L − 1 ) / L ⌋ lets a computer (which does integer division = floor) compute a ceiling.
Interval notation the parent uses: [ a , b ) means "from a included up to b excluded ". Page p covers rows [( p − 1 ) L , p L ) — the square bracket grabs the start row, the round bracket stops just before the next page's first row, so no row is counted twice.
Read the arrows as "you need this before that." Everything funnels into REST API design — the parent note (topic) .
Cover the answers. If you can say each one aloud, you're ready for the parent note.
What is the difference between a client and a server? The client asks (sends the request note); the server holds the data and answers (sends the reply note).
What are the four labelled parts of an HTTP request? Method (verb), URL (address), headers (side-notes), body (payload).
In /users/42?limit=20, name each part. /users = collection, /42 = the item's id, ?limit=20 = a query-string knob.
What is a resource vs its representation? The resource is the thing at an address; the representation is a written JSON snapshot of its current state.
Read this JSON: {"name":"Ada"}. A box with one key name whose value is the text Ada.
Name the five HTTP methods and their plain verbs. GET = read, POST = create, PUT = replace, PATCH = partial-update, DELETE = remove.
Define "safe" and "idempotent". Safe = changes nothing on the server; idempotent = doing it many times ends in the same state as doing it once.
Give a real-world picture of idempotency. A light switch set to OFF — flip it any number of times, still off (like DELETE); a "add coin" button is not idempotent (like POST create).
What lives in a header? Give two examples. Meta-info: Content-Type: application/json, Location: /v1/users/42.
What does the first digit of a status code tell you? The family: 2xx success, 3xx redirect, 4xx client's fault, 5xx server's fault.
Compute ⌊ 2.7 ⌋ and ⌈ 2.1 ⌉ . Floor = 2, ceiling = 3.
Why is total pages ⌈ N / L ⌉ and not ⌊ N / L ⌋ ? The leftover items after the last full page still need their own page; rounding down would drop them.
What does the interval [( p − 1 ) L , p L ) mean? Rows from ( p − 1 ) L included up to p L excluded — the slice belonging to page p , with no overlap.