HTTP and APIs
Beginner
10 min read
How a browser or another program talks to a server: requests, methods, status codes and JSON APIs.
Why it matters
Every web application, mobile app and integration is built on HTTP. Reading a request and its status code is the first step in debugging almost any backend problem.
Where it fits
What you will learn
- Read an HTTP request and response: method, path, headers, body, status.
- Choose the right method and status code for an API endpoint.
- Explain why a server must validate every request it receives.
Before you start
- The software delivery lifecycle✓ Learned
A request and its response
Example
GET /api/projects/42 HTTP/1.1
Host: example.com
Accept: application/json
HTTP/1.1 200 OK
Content-Type: application/json
{"id": 42, "name": "My project"}
Methods and status codes you meet every day
GETreads,POSTcreates,PUT/PATCHchange,DELETEremoves.GETmust never change data.2xxsuccess (200 OK,201 Created,204 No Content).4xxthe client's mistake (400bad input,401not signed in,403not allowed,404not found,422validation failed).5xxthe server's mistake (500a bug,502/504the app behind the proxy did not answer).
Watch out: Treat every request as untrusted: validate input, check that the user may access the resource, and never return more data than the caller needs.
Tip: Open your browser's developer tools (Network tab) on any site to see real requests, headers and status codes.
Official documentation and references
Guides
- MDN — An overview of HTTP ↗ Official · MDN Web Docs
Reference
- MDN — HTTP request methods ↗ Official · MDN Web Docs
- MDN — HTTP response status codes ↗ Official · MDN Web Docs
Specifications
- RFC 9110 — HTTP Semantics ↗ Official · IETF — The standard itself; read it when you need the exact rule.
Practise in Zerethon IDE
- Code Help: JavaScript — Promises and async / await How JavaScript waits for a response with async/await.
Learn next
- SQL databases ›✓ Learned
Related topics
- Authentication and passwords✓ Learned
- JavaScript in the browser✓ Learned
- Nginx as a reverse proxy✓ Learned
- SQL databases✓ Learned
Done with this topic?
Reviewed 2026-10-23. Links go to the official documentation unless marked otherwise.