REST
Definition
REST (representational state transfer) is an architectural style for web APIs in which resources, such as users or orders, have URLs and are read or changed with standard HTTP methods like GET, POST, PUT and DELETE.
Diagram
Request
POST /v1/shipments Authorization: Bearer sk_test_… Content-Type: application/json { "to": "Ikeja, Lagos", "weight_kg": 2.4 }
- Method: what to do (GET reads, POST creates, PATCH updates, DELETE removes)
- URL: which resource
- Headers: who is asking, and in what format
- Body: the data sent
Response
201 Created Content-Type: application/json { "id": "shp_8421", "price": 3500, "label_url": "https://…" }
- 2xx: it worked
- 4xx: the request was wrong (401 not signed in, 404 not found, 429 too many)
- 5xx: the server failed