Skip to the workspace
Pebellslearn by building
Learn the Basics  ›  Lesson

HTTP — One Request, One Response

HTTP 12 minEvery HTTP exchange is a request made of a method, a path, headers and an optional body, answered by a response with a status, headers and an optional body, and each request stands on its own.

api design / HTTP — One Request, One Response

Explore each scene at your own pace.

01 · The rule

The rule

HTTP — One Request, One Response

Nearly every web API speaks HTTP. If you can read a raw HTTP message, you can debug almost any API problem, because every framework and library is only building these few lines of text for you.

The rule

A request asks with a method and a path; a response answers with a status.

An HTTP request has three parts:

  1. A request line: method, path and version, such as GET /v1/books/42 HTTP/1.1.
  2. Headers: Name: value lines of extra information, like Host or Accept.
  3. An optional body, separated from the headers by a blank line.

A response mirrors it: a status line (HTTP/1.1 200 OK), headers, a blank line, then an optional body.

POST /v1/loans HTTP/1.1
Host: api.booknook.example
Content-Type: application/json

{"book_id": 42, "member_id": 7}

HTTP/1.1 201 Created
Location: /v1/loans/901
Content-Type: application/json

{"id": 901, "book_id": 42, "due": "2026-10-09"}

HTTP is stateless: each request carries everything the server needs to understand it. The server does not remember that the same app asked for book 41 a second ago. Anything that must persist between requests, like who the user is, travels in every request, usually in a header.

HTTP has grown through versions, but the meaning of a message has stayed the same:

  • HTTP/1.1 sends text messages, one at a time on each connection.
  • HTTP/2 sends the same messages as binary frames and multiplexes many requests over one connection at once.
  • HTTP/3 runs HTTP/2's ideas over QUIC, a protocol built on UDP, so one lost packet does not stall every other request.

Methods, paths, headers and status codes mean the same in all three. You design an API once; the version is a transport detail.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.