Skip to content
Engineering

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
The API is a contract: as long as requests and responses keep this shape, either side can change how it works inside. That is why breaking changes, such as renaming a field, need a new version.

Worked example