FastAPI Flashcards

(23 cards)

1
Q

What is the core data validation library integrated with FastAPI?

A

Pydantic

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What HTTP status code does FastAPI return on input validation failure?

A

422 Unprocessable Entity

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the default interactive documentation UI provided by FastAPI at the /docs path?

A

Swagger UI

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What specification does FastAPI use to auto-generate API documentation?

A

OpenAPI (or Swagger)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What keyword is used to provide a reusable component or service to a path operation function?

A

Depends

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the modern, asynchronous standard interface that FastAPI is built upon?

A

ASGI (Asynchronous Server Gateway Interface)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the underlying microframework that provides FastAPI’s routing and tooling?

A

Starlette

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the primary benefit of using async def in FastAPI path operations?

A

Allows non-blocking I/O for higher concurrency/performance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Which security utility in FastAPI simplifies token-based authentication?

A

OAuth2PasswordBearer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Primary protocol FastAPI uses for asynchronous communication

A

ASGI (Asynchronous Server Gateway Interface)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Library FastAPI uses for web routing and core logic

A

Starlette

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Library FastAPI uses for data validation and serialization

A

Pydantic

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Language Pydantic V2 is written in to improve speed

A

Rust

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How FastAPI handles ‘def’ (sync) functions

A

Executes them in a separate thread pool to avoid blocking the event loop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Term for handling multiple tasks by switching during I/O waits

A

Concurrency

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Term for executing multiple tasks simultaneously on different CPU cores

17
Q

Recommended production server combo for FastAPI

A

Gunicorn with Uvicorn workers

18
Q

The bottleneck prevented by using ‘async’ database drivers

A

Event loop blocking

19
Q

Benefit of ‘response_model’ in FastAPI

A

Optimizes serialization and automatically filters output data

20
Q

Where to move heavy static file handling for better performance

A

Nginx or a CDN

21
Q

Impact of excessive middleware on API performance

A

Increases latency by adding processing layers to every request

22
Q

Feature used to share DB connection pools across endpoints

A

Dependency Injection

23
Q

The event loop’s role in FastAPI

A

Managing and scheduling asynchronous tasks/coroutines