Script Valley
REST API Development: Beginner to Production
HTTP Foundations and REST PrinciplesLesson 1.1

How HTTP request-response cycle works

HTTP protocol, request structure, response structure, status codes, headers, stateless communication

The HTTP Request-Response Cycle

Every API call is an HTTP transaction. The client sends a request; the server sends back a response. That's it. Understanding this cycle is the foundation of everything else.

Anatomy of an HTTP Request

A request has four parts: method (GET, POST, PUT, DELETE), URL (the resource address), headers (metadata like Content-Type), and an optional body (data payload for POST/PUT).

GET /users/42 HTTP/1.1
Host: api.example.com
Authorization: Bearer eyJhbGci...
Accept: application/json

Anatomy of an HTTP Response

The server replies with a status code, headers, and a body. Status codes are grouped by first digit: 2xx success, 3xx redirect, 4xx client error, 5xx server error.

HTTP/1.1 200 OK
Content-Type: application/json

{
  "id": 42,
  "name": "Alice"
}

HTTP is stateless β€” each request is independent. The server stores no memory of previous requests unless you explicitly pass context (a token, session ID, etc.) in every request. This constraint is intentional and scales well.

Up next

What makes an API RESTful β€” the 6 constraints

Sign in to track progress

How HTTP request-response cycle works β€” HTTP Foundations and REST Principles β€” REST API Development: Beginner to Production β€” Script Valley β€” Script Valley