API Design in System Design Interviews
Table of Contents + â
So youâve done the first part of the interview well:
- You asked your clarifying questions and pinned down the requirements.
- You agreed on the scope out loud, like âletâs build posting and a feed, skip messaging for nowâ.
- Now thereâs this little gap before you start drawing boxes, and a lot of people rush right past it.
Hereâs the thing. Right after requirements, the smartest move is to define the API. It sounds fancy, but all it means is writing down the exact requests a client can make. And once youâve done that, the system stops being fuzzy. You know exactly what it does, because youâve listed every action it supports.
đŻ Why Design the API
Let me tell you the pain first:
- You skip the API and jump straight to boxes and arrows.
- Halfway through, the interviewer asks âokay, so how does a user actually post something?â and you freeze.
- You realize youâve been drawing a system without knowing what itâs supposed to do.
Defining the API fixes that before it happens. So why is it such a strong move?
- It turns fuzzy features into concrete operations. âUsers can postâ becomes a real request with a method, a path, an input, and an output.
- It sets the API contract. The contract is just the agreement on what each request takes in and what it gives back, so the client and the server both know what to expect.
- It keeps you and the interviewer pointed at the same target. Everyone can see, in plain text, what the system promises to do.
The thing is, this step is quick. You spend a few minutes here, and the whole rest of the design gets easier, because now youâre building servers and databases to support a clear list of operations.
Where this fits in the interview
Defining the API is one step in the bigger flow. If you havenât seen that flow yet, read The System Design Interview Process first. And if you want the deeper version of how real APIs work, REST APIs Explained has you covered.
đ What to Define
Okay so what does âdefine the APIâ actually mean? You go through each core feature you scoped, and for every one of them, you write down four things:
- The method. This is the kind of action. An HTTP method is the verb of the request.
GETreads something,POSTcreates something,PUTupdates,DELETEremoves. So the method tells you at a glance whether this request reads data or changes it. - The path. This is the address of the thing youâre acting on, like
/postsor/feed. It names the resource, which is just whatever the request is about, a post, a user, a feed. - The inputs. This is what the client has to send. For creating a post, thatâs the text and maybe the userâs ID. Be specific about what goes in.
- The outputs. This is what the server sends back. For creating a post, maybe the new postâs ID. For reading a feed, a list of posts.
Hereâs how one request flows once youâve defined it. The client sends a request to a specific endpoint, the server does its work, and a response comes back.
Do this for each core feature and youâve got your whole API. Each endpoint maps to exactly one thing a user can do. Thatâs the goal.
â¨ď¸ A Few Endpoints
Letâs make this real. Say we scoped a simple social app where people can post and scroll a feed. Here are a couple of endpoints, written the way youâd jot them on the whiteboard.
First, creating a post. A user sends some text, and we hand back an ID for the new post.
POST /posts Input: { userId, text } Output: { postId, createdAt }Letâs read what that says:
POSTis the method, so we know this request creates something new./postsis the path, the collection of posts weâre adding to.- The input is the userâs ID and the text they typed.
- The output is the new postâs ID and when it was made, so the client can show it right away.
Next, reading the feed. The user asks for their feed, and we send back a list of posts.
GET /feed?userId=42&page=1 Input: userId, page number Output: { posts: [ ... ], nextPage }Reading this one:
GETis the method, so this just reads data, it doesnât change anything./feedis the path, and the bits after the?are query parameters, which are little extra inputs tacked onto the path.- We ask for a
pagebecause a feed can be huge, so we grab it a chunk at a time. - The output is the list of posts plus a
nextPagemarker, so the client knows how to ask for more.
And one more, fetching a single post by its ID.
GET /posts/{postId} Input: postId (in the path) Output: { postId, userId, text, createdAt }See how this reads almost like plain English? Anyone glancing at these three lines knows what the system does. Thatâs the whole point. Youâve turned âpeople can post and scroll a feedâ into concrete operations the rest of your design has to support.
đ Feature to Endpoint
A neat way to show your thinking is to line up each feature next to the endpoint that handles it. It proves every feature you scoped has a home, and nothing extra snuck in.
| Feature | Endpoint | What it does |
|---|---|---|
| Create a post | POST /posts | Saves a new post, returns its ID |
| View one post | GET /posts/:postId | Fetches a single post by its ID |
| See the feed | GET /feed | Returns a page of posts for the user |
| Like a post | POST /posts/:postId/likes | Adds a like to that post |
| Follow a user | POST /users/:userId/follow | Makes the caller follow that user |
Lay it out like this and the interviewer can see your whole system at a glance. It also catches gaps fast. If a feature has no endpoint, you missed something. If an endpoint has no feature, youâre building stuff nobody asked for.
đ§Š Keep It Focused
Now hereâs a trap thatâs easy to fall into. You start listing endpoints, and you overdo it:
- You add
PUT /posts/{postId}for editing, thenDELETEfor removing, then endpoints for drafts, bookmarks, reports, and on and on. - None of that was in the scope you agreed on. You scoped posting and a feed.
- So now youâre burning interview minutes designing things the interviewer never asked for.
The fix is simple. Only design the API for the core features you scoped:
- Look back at the scope you pinned down in the requirements step. Thatâs your list.
- One endpoint per core feature is plenty to show you understand the system.
- If the interviewer wants more later, theyâll ask. You can always add an endpoint on the spot.
Think of the API as a sketch of the system, not the full manual. A tight, focused API says you know what matters. A giant pile of endpoints just says you canât tell the core from the extras.
Match the API to the scope
Every endpoint should trace back to a feature you and the interviewer agreed on. If you canât point to the requirement an endpoint serves, drop it. Over-listing endpoints wastes time and muddies your design.
đ Small Things That Impress
Once your core endpoints are down, a few light touches make you sound like youâve actually built APIs before. You donât need to go deep, just mention them.
- Pagination for lists. Any endpoint that returns a list, like the feed, shouldnât dump a million items at once. So you return one page at a time, using a
pageor a cursor. Mentioning this shows youâre thinking about real-world scale. - Auth where itâs needed. Some actions need to know whoâs calling, like posting or following. Auth, short for authentication, is just the system checking who you are, usually with a token sent along in the request. Point out which endpoints need it.
- Sensible status codes. A status code is the short number the response sends back to say how it went. Use
201when you create something,200for a successful read,404when the thing isnât found,401when the caller isnât logged in. Picking the right ones shows polish.
One line on each of these during the interview is enough. It signals maturity without eating your time.
â ď¸ Common Mistakes and Misconceptions
A few habits trip people up at this step. Letâs clear them out.
- âSkip the API and jump straight to boxes.â This is the big one. If you draw servers and databases before defining what the system does, your design has no anchor. Define the API first, then the boxes have a clear job.
- âDesign every possible endpoint.â More endpoints donât make you look thorough, they make you look unfocused. Stick to the core features you scoped, and stop there.
- âIgnore the inputs and outputs.â Writing just
POST /postsand moving on isnât enough. The contract lives in what goes in and what comes back. Spell those out, even briefly, or the endpoint doesnât really mean anything. - âTreat the API as the final answer.â Itâs a sketch to guide the design, not a finished spec. Itâs fine to refine it as the interview goes on.
đ ď¸ Practice Challenge
Time to try it yourself. Take this prompt: âDesign a simple to-do app, where a user can create tasks, see their list of tasks, mark a task done, and delete a task.â
Walk through the API the same way we just did:
- List the core features. Create a task, list tasks, mark done, delete. Thatâs your scope.
- Write an endpoint for each. Pick the method, the path, the inputs, and the outputs. For example,
POST /taskswith input{ userId, text }and output{ taskId }. - Add the small touches. Where would you paginate? Which endpoints need auth? What status code would you return when a task is created?
- Check your list. Does every feature have exactly one endpoint? Did any extra endpoint sneak in that wasnât in the scope?
Do this on paper, out loud, like Alex is sitting across from you grading it. The more you rehearse turning features into clean endpoints, the faster this step goes in a real interview.
đ§Š What Youâve Learned
You can now define the API for a system in an interview, cleanly and quickly. Hereâs what youâve picked up.
- â Define the API right after requirements, before you draw any boxes.
- â For each core feature, write the method, the path, the inputs, and the outputs.
- â The inputs and outputs are the API contract, the promise of what goes in and what comes back.
- â Map one endpoint to each scoped feature, and keep it focused, no extras.
- â Mention pagination for lists, auth where itâs needed, and sensible status codes.
- â Treat the API as a sketch that guides the design, not a final spec.
Check Your Knowledge
Test what you learned. Pick an answer for each question, then click Check.
- 1
When should you define the API in a system design interview?
Why: You define the API after pinning the scope and before the high-level design, so the boxes have a clear job to support.
- 2
Which four things do you write down for each endpoint?
Why: For each core feature you note the method, the path, the inputs the client sends, and the outputs the server returns.
- 3
What is an API contract?
Why: The contract is the inputs and outputs both sides agree on, so the client and server can be built separately and still fit together.
- 4
Why should you avoid listing every possible endpoint?
Why: Designing endpoints nobody scoped burns time and makes it look like you cannot tell the core from the extras.
đ Whatâs Next?
With the API defined, you know exactly what the system does. Next, you build the pieces that make those endpoints work.
- Database Selection Strategy helps you pick the right store for the data your endpoints read and write.
- REST APIs Explained goes deeper into how real APIs are designed, with methods, paths, and status codes in full.
Define the API on a few small prompts, and pretty soon turning fuzzy features into clean endpoints will feel automatic.