Basic Interview Questions
What is FastAPI and why is it fast?
FastAPI is a Python framework for building APIs using type hints. It is fast to run because it is built on Starlette (an async ASGI toolkit) and Pydantic v2 (validation implemented in Rust), and fast to write because validation, serialization and docs come from the type hints.
What is the difference between path and query parameters?
Path parameters are part of the URL path (/users/{user_id}) and identify a resource. Query parameters come after ? (?skip=0&limit=10) and usually filter, sort or paginate. In FastAPI, function arguments named in the path are path parameters; other simple types are query parameters.
What is Pydantic used for in FastAPI?
Pydantic models define the shape of request bodies and responses. FastAPI uses them to parse JSON, convert types, validate constraints, return clear 422 errors, filter output with response_model, and generate the OpenAPI schema.
What does a 422 response mean?
"Unprocessable Entity": the request was well-formed but failed validation (wrong type, missing field, constraint violated). FastAPI returns it automatically with a detail list describing each error.
Where are the automatic docs?
/docs (Swagger UI, interactive), /redoc (ReDoc) and the raw schema at /openapi.json.