Documentation · Chapter 12

Expose data through a clear HTTP contract.

An API lets another program use application capabilities through HTTP. It returns structured JSON rather than an HTML page.

Every lesson starts from the problem, explains the mechanism, then gives a concrete verification.

≈ 75 min

A contract between programs

Humans interpret layout; programs need stable field names, types, statuses, and error shapes. Documented behavior matters more than pretty output.

Resources and endpoints

A resource is a business concept such as movies. Endpoints combine method and path: GET /api/movies reads, POST /api/movies creates.

Choose status codes deliberately

Use 200 for success, 201 for creation, 204 for empty deletion, 401 for missing identity, 403 for forbidden action, 404 for absence, 422 for invalid input, and 429 for excess.