bigonotes
System DesignAPI Design

REST

Model resources from your core entities, use HTTP methods correctly, and pass data via path, query and body.

4 min readLast updated

REST (Representational State Transfer) models your system as resources that clients act on with standard HTTP methods. It's the default API style for web and mobile backends because it maps cleanly onto your core entities and onto HTTP itself. Good REST design comes down to three things: picking the right resources, using methods correctly, and putting each piece of data in the right part of the request.

Resource modeling#

Resources are the core entities you list before you define the API: users, restaurants, menu items, reservations, reviews. Name them as plural nouns.

For a restaurant reservation app with restaurants, menu items, reservations and reviews, the endpoints look like this:

Endpoint What it does
GET /restaurants List restaurants
GET /restaurants/{id} Get one restaurant
GET /restaurants/{id}/menu-items List a restaurant's menu
POST /restaurants/{id}/reservations Reserve a table at a restaurant
GET /reservations/{id} Get one reservation
POST /restaurants/{id}/reviews Leave a review

Interviewers care more about whether you pick the right resources than about perfect URLs. Still, structuring relationships well shows good design sense.

Nested resources (path) vs flat resources (query)#

The trickiest part is expressing relationships, like "the menu of a restaurant". You have two options.

  • Nest in the path when the relationship is required and hierarchical. A menu item belongs to exactly one restaurant, so /restaurants/{restaurant_id}/menu-items. Remove the restaurant id and the URL makes no sense.
  • Use query parameters when the relationship is optional or used for filtering. /restaurants?cuisine=thai&max_price=30 is "all restaurants, narrowed down". Drop the parameters and it still works and returns everything.

A good way to explain it: "restaurant_id goes in the path because a menu item has no meaning outside its restaurant. Cuisine and price are query parameters because they're optional filters, not part of what the resource is."

HTTP methods#

Once the resources are set, the method says what to do with them. Each HTTP method has a fixed meaning, and clients rely on it.

Method Use Example Idempotent?
GET Read without changing anything GET /restaurants/{id} Yes
POST Create; the server assigns the id POST /restaurants/{id}/reservations No: calling it twice creates two reservations
PUT Replace a whole resource PUT /users/{id} with the full user Yes
PATCH Update part of a resource PATCH /users/{id} with only email Not guaranteed
DELETE Remove DELETE /reservations/{id} Yes: it stays deleted, even if later calls return 404 instead of 204

Idempotency means repeating a request leaves the server in the same state. It matters because networks fail and clients retry. Retrying a GET, PUT or DELETE is safe; retrying a POST can create duplicates unless you add an idempotency key.

Passing data to an API#

A request can carry data in three places, and each has its own role.

Where Role Example
Path parameters Structural: which resource /restaurants/42
Query parameters Modifiers: filter, sort, paginate /restaurants?city=Austin&open_now=true, /restaurants?page=2&limit=20
Request body Payload: the data you're creating or updating Reservation details, anything large or sensitive

The first query parameter follows ?, and the rest are separated by &.

Here's one request that uses all three:

POST /restaurants/42/reservations?send_reminder=true
Content-Type: application/json

{
  "party_size": 4,
  "time": "2025-05-02T19:30:00-05:00",
  "seating": "patio",
  "note": "One guest uses a wheelchair"
}
  • 42 is in the path because you must say which restaurant you're reserving at.
  • send_reminder=true is a query parameter because it only toggles an optional extra.
  • Party size, time, seating and the note go in the body because they're the data being created.

Returning data#

That covers what goes into a request. The response side is simpler: it has two parts, a status code (did it work?) and a body (usually JSON).

Stick to the common codes: 200 OK, 201 Created, 400 Bad Request, 401 Unauthorized, 404 Not Found, 500 Internal Server Error. See HTTP Status Codes for a fuller table.

What matters in an interview is the split: a 4xx means the client sent something wrong, a 5xx means the server failed. Nobody expects the full list from memory.

Key takeaways#

  • Resources come from your core entities. Use plural nouns, not verbs.
  • Use path parameters for required hierarchy and query parameters for optional filters.
  • GET, PUT and DELETE are idempotent; POST isn't, so guard critical POSTs against retries.
  • Path identifies, query modifies, body carries the payload.
  • Use a small set of status codes and know 4xx from 5xx.
Revision notes · 2 min

Core idea#

REST models the system as resources that clients act on with standard HTTP methods. Good REST design means the right resources, correct methods, and each piece of data in the right part of the request.

Key points#

  • Resources come from your core entities. Name them as plural nouns, not verbs.
  • Interviewers care more about the right resources than perfect URLs.
  • Nest in the path when the relationship is required: /restaurants/{restaurant_id}/menu-items.
  • Use query parameters for optional filters: /restaurants?cuisine=thai&max_price=30.
  • Idempotency means a repeated request leaves the server in the same state.
  • A response has a status code and a body, usually JSON.

HTTP methods#

Method Use Idempotent?
GET Read without changing anything Yes
POST Create; the server assigns the id No
PUT Replace a whole resource Yes
PATCH Update part of a resource Not guaranteed
DELETE Remove Yes

Where data goes#

Where Role Example
Path parameters Which resource /restaurants/42
Query parameters Filter, sort, paginate /restaurants?page=2&limit=20
Request body Data to create or update Reservation details, large or sensitive data

Pitfalls#

  • Retrying a POST can create duplicates. Guard critical POSTs with an idempotency key.
  • A repeated DELETE may return 404 instead of 204, but the state is the same.
  • Verbs in URLs (/getReservations) break the resource model.

Say it in an interview#

  • "restaurant_id goes in the path because a menu item has no meaning outside its restaurant."
  • "Path identifies, query modifies, body carries the payload."
  • "4xx is a client error, 5xx is a server error."

Found a mistake? Email ask@bigonotes.com