0%
API Design Interviews: REST, gRPC, GraphQL, Pagination, Idempotency, Versioning and Webhooks
Core Decisions
Resource Modeling: Turning a Domain Into an API
In the framework from the first lesson, step one gives you a short list of use cases and the consumers who need them. Step two turns that list into resources. This is the step that most decides whether the rest of the interview goes smoothly, because every later decision hangs off it. Endpoints are operations on resources. Schemas describe resources. Pagination, idempotency and versioning all apply to resources. If the resource model is muddled, every later step inherits the muddle, and the interviewer will see you patching symptoms instead of designing.
The good news is that resource modeling is a learnable procedure rather than a talent. You read the use cases, pull out the nouns, decide which nouns deserve to be resources, work out how they relate, and then decide how they are identified and addressed. This lesson walks through that procedure and the judgment calls inside it.
What a resource actually is
A resource is a thing in the domain that a consumer wants to name, read or change, and that has an identity which persists between requests. An order is a resource: you create it, you read it later by its id, its status changes over time. A booking, an invoice, a user, a document and a payment are resources for the same reason. A resource has a type, an identifier, a set of fields and a lifecycle.
A resource is not the same thing as a database table. The table behind an order might be split into orders, order_lines and order_status_history, and the API might still expose a single order resource with embedded line items. In the other direction, one table might back two resources, such as a users table that powers both a public profile resource and a private account resource with different fields and different permissions. Interviewers often probe this exact point. A candidate who says the API mirrors the schema has skipped the design work; a candidate who says the API models what consumers need and the storage can be shaped independently is showing judgment.
Pull the nouns out of the use cases
Take the use cases you agreed in step one and read them aloud with an eye for nouns. Suppose the prompt is a food delivery API and you agreed on three use cases: a customer browses nearby restaurants and their menus, a customer places an order and pays for it, and a customer tracks the order until it arrives. The nouns are customer, restaurant, menu, menu item, order, payment, courier and delivery. That list is your first draft of the resource model.
Not every noun survives. Some are attributes rather than resources: an address might be a field on the customer, or it might be a resource of its own if customers save several and pick one at checkout. Some are views over other resources: a menu might simply be the list of menu items belonging to a restaurant, so you might model it as a sub collection rather than a resource with its own identity. Some are internal and should never be exposed, such as the dispatch queue that assigns couriers. The test for each noun is simple. Does a consumer need to refer to this thing by name in a later request? If yes, it needs an identity and is probably a resource. If no, it is probably a field or an implementation detail.
Name the consumer for each resource
Step one also told you who the consumers are, and different consumers see different resources. In the delivery example there are at least three: the customer app, the restaurant tablet and the courier app. The customer sees orders as things they placed. The restaurant sees the same orders as tickets to prepare. The courier sees deliveries, which reference an order but carry pickup and dropoff details the customer never needs.
Saying this out loud early prevents a common failure: designing one giant order resource with every field any consumer could want, then struggling with permissions because the customer must not see the restaurant's internal notes and the courier must not see the payment method. Often the right answer is one underlying order with consumer specific representations, or separate resources such as delivery that reference the order. You do not have to settle it immediately, but naming the consumers tells the interviewer you know the question exists.
Keep the first model small
A strong candidate does not try to model the entire business. They model the resources that the agreed use cases need and mention the ones they are deliberately leaving out. For the delivery API that might be: restaurants, menu items under restaurants, orders, payments and deliveries, with reviews, promotions and loyalty points explicitly out of scope. Five resources is enough to design a coherent API in an interview. Twelve resources will consume the time you need for endpoints and cross cutting concerns.
Write the list where the interviewer can see it, one line per resource, with its owner and two or three key fields. A short written list becomes the anchor for the rest of the discussion. When you later define endpoints, you point at the list. When the interviewer adds a requirement, you check whether it needs a new resource or a new field on an existing one.
A worked first pass
Here is what a first pass at the delivery model might look like on the board, written in plain text rather than a formal schema:
Notice what is already visible. Every resource has an id. Most have a status, which hints that they have lifecycles you will need to describe. The relationships are explicit: menu items belong to restaurants, payments and deliveries point at orders. Customers and couriers appear only as references because, for these use cases, the API consumes their identity from authentication rather than managing them. That last point is worth saying aloud, since it shows you are scoping deliberately rather than forgetting.
What the interviewer is checking in step two
At this point the interviewer is looking for a few specific things. Did the resources come from the use cases, or from a generic template? Did you distinguish resources from fields and from internal machinery? Did you think about which consumer sees what? Did you keep the model small enough to finish? And can you explain why a given noun is a resource and another is not? None of these require deep protocol knowledge, which is why this step is where candidates with strong backend experience sometimes stumble: they jump to tables, queues and caches and never present the model the consumer will actually see.
Common first pass mistakes
Three mistakes show up again and again. The first is modeling the user interface rather than the domain, for example a home screen resource that bundles banners, recommendations and recent orders. That is a legitimate aggregate for one client, and a backend for frontend layer might serve it, but it is not the core resource model. The second is exposing internal pipeline stages as resources, such as a fraud check resource that clients can create, when the fraud check is really an internal step in creating a payment. The third is creating separate resources for what is really one resource in different states, such as pending orders, active orders and completed orders as three collections. Those are one orders collection with a status field and a filter, and the next section explains why that matters.
Saying it out loud
A short narration makes step two land. Something like: from the use cases I see five resources, restaurants with menu items under them, orders, payments and deliveries. Customers and couriers come from authentication, so I will reference them by id rather than manage them. Reviews and promotions are out of scope. Does that match what you want to focus on? That takes about thirty seconds, it gives the interviewer a chance to redirect you before you invest in endpoints, and it is itself evidence of navigation. If the interviewer says they care most about the courier side, you have learned where the deep dive will be, and you can give deliveries more fields and a fuller lifecycle while keeping the other resources thin.
Before any endpoint, write one line per resource with its owner and two or three key fields. Five lines on the board give you and the interviewer a shared anchor for every later decision, and they make missing or duplicate resources obvious.