Part 09 / Topic 1 of 7
Designing a small API
The pipeline from Stage 2 filled a database; now Acme's dispatch team and internal systems need to reach it. Before any framework, decide the contract:
- Resources, not actions:
/shipments/S-2001, not/getShipment?id=S-2001. - Methods carry the verb: GET reads, PATCH updates a field, POST creates, DELETE removes.
- Status codes you already know (Part 4) from the serving side now: 200 success, 404 no such resource, 401 bad credentials, 422 invalid body, 5xx our fault.
- One error format everywhere:
{"detail": "shipment S-9999 not found"}— a message the caller can show a human, never a stack trace.
A small API with a boring, predictable contract is a feature. The customer's engineers will integrate against it without meetings — which is the point.
Done here? The practice set for Part 9 — 4 exercises with solutions — is on the part page.