What is FastAPI in Python?
Why Interviewers Ask This
Advanced questions like this reveal whether a candidate has internalized Python deeply enough to make architectural decisions. Strong answers demonstrate both breadth and depth of experience.
Answer
FastAPI is a modern, high-performance Python web framework for building APIs. It is based on Starlette (ASGI) and Pydantic and uses type hints for automatic request validation, serialization, and documentation. from fastapi import FastAPI; app = FastAPI(); @app.get("/users/{user_id}") async def get_user(user_id: int, include_inactive: bool = False) -> dict: return {"id": user_id}. FastAPI automatically: validates types, generates JSON Schema, and creates interactive API docs at /docs (Swagger UI) and /redoc. Dependency injection: def endpoint(db: Session = Depends(get_db)). Async: use async def for non-blocking endpoints. Pydantic models for request body: class UserCreate(BaseModel): name: str; email: EmailStr. FastAPI is one of the fastest Python frameworks (comparable to Node.js/Go) and has become the industry standard for Python APIs, replacing Flask for many use cases.
Pro Tip
Before answering, structure your response: one-line definition → real-world analogy → concrete example from a project. This makes even complex Python answers easy to follow.