Implement FastAPI CRUD endpoints from skeletons

Quick Overview

This question evaluates a candidate's ability to implement RESTful CRUD endpoints with FastAPI, focusing on API contract consistency, HTTP status codes and idempotency, input validation and exception handling, and unit testing.

Implement FastAPI CRUD endpoints from skeletons

Company: Credit Genie

Role: Software Engineer

Category: System Design

Difficulty: medium

Interview Round: Technical Screen

Given a FastAPI project with two working endpoint functions (create and read) and shared Pydantic models, implement the remaining update and delete endpoints to complete CRUD. Requirements: a) match the existing request/response schemas and status codes; b) preserve idempotency and return 404 vs 204 appropriately; c) validate inputs and handle exceptions; d) write unit tests for all four endpoints; e) explain how you would approach this if you have never used FastAPI before, by leveraging the existing endpoints as templates and the framework documentation.

Quick Answer: This question evaluates a candidate's ability to implement RESTful CRUD endpoints with FastAPI, focusing on API contract consistency, HTTP status codes and idempotency, input validation and exception handling, and unit testing.

|Home/System Design/Credit Genie
Credit Genie logo
Credit Genie
Sep 6, 2025, 12:00 AM
mediumSoftware EngineerTechnical ScreenSystem Design
8
0

Implement Update and Delete Endpoints in a FastAPI CRUD Service

Context

You are given a FastAPI project that already has working Create and Read endpoints and shared Pydantic models for request/response. Extend the service to complete CRUD by adding Update and Delete endpoints that are consistent with the existing code style and API contracts.

Assumptions (adjust to match the actual project):

  • The resource is an "Item" stored in memory or a repository abstraction.
  • Existing endpoints follow typical REST conventions:
    • POST /items → 201 Created with response body of the created item.
    • GET /items/{item_id} → 200 OK with item body, or 404 if not found.
  • The same Pydantic models are reused across endpoints (e.g., ItemCreate, ItemUpdate, ItemRead).

Requirements

  1. Implement Update and Delete endpoints that match existing request/response schemas and status codes.
  2. Preserve idempotency where applicable and return 404 vs 204 appropriately.
  3. Validate inputs and handle exceptions cleanly (e.g., 422 for invalid input, 404 for not found).
  4. Write unit tests covering all four endpoints (Create, Read, Update, Delete), including success and error paths.
  5. Explain how you would approach this if you have never used FastAPI before, leveraging existing endpoints as templates and the FastAPI documentation.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...