Skip to content
RED SAGSkills
easyFull Stack Developer interview question

Design the REST API endpoints for a simple blog with posts and comments. What URLs, methods and status codes would you use?

What the interviewer wants to hear

  • Use nouns for resources and HTTP methods for actions
  • Nested routes for comments under a post
  • Correct status codes such as 200, 201, 204, 400, 401, 404
  • Pagination and filtering through query parameters
  • Validation and consistent error format

Model answer

I would model posts and comments as resources. GET /api/posts lists posts with pagination like ?limit=20&cursor=abc, and GET /api/posts/:id returns one post. POST /api/posts creates a post and returns 201 with the new object. PATCH /api/posts/:id updates some fields and DELETE /api/posts/:id returns 204. For comments, GET /api/posts/:id/comments and POST /api/posts/:id/comments, and DELETE /api/comments/:id for a single comment. I would return 400 for invalid input with a clear JSON error body, 401 when the user is not logged in, 403 when they are not allowed, and 404 when the item does not exist. I would validate input on the server with a schema library like Zod, keep the response shape consistent, and only allow the author or an admin to edit or delete a post.

Can you answer it under time pressure?

Take a timed easy round and get scored on every answer.

Start mock interview

More easy Full Stack Developer questions