FastAPI Class — fastapi Architecture
Architecture documentation for the FastAPI class in applications.py from the fastapi codebase.
Entity Profile
Dependency Diagram
graph TD 587454b3_6db6_011f_9fa4_3e4e2e09b72d["FastAPI"] 53e07af2_3e5c_ea1f_ee6c_abc9792bf48b["HTTPException"] 587454b3_6db6_011f_9fa4_3e4e2e09b72d -->|extends| 53e07af2_3e5c_ea1f_ee6c_abc9792bf48b 58bb043a_10d8_c308_5564_225558a63815["RequestValidationError"] 587454b3_6db6_011f_9fa4_3e4e2e09b72d -->|extends| 58bb043a_10d8_c308_5564_225558a63815 b73e338b_e4cd_2e94_eb5a_5e6ac7b197b0["WebSocketRequestValidationError"] 587454b3_6db6_011f_9fa4_3e4e2e09b72d -->|extends| b73e338b_e4cd_2e94_eb5a_5e6ac7b197b0 a4e9210e_542f_dbd2_500a_37b56326c1e7["AsyncExitStackMiddleware"] 587454b3_6db6_011f_9fa4_3e4e2e09b72d -->|extends| a4e9210e_542f_dbd2_500a_37b56326c1e7 6c1867f2_34c4_b2ed_5639_41766e6fd7ce["applications.py"] 587454b3_6db6_011f_9fa4_3e4e2e09b72d -->|defined in| 6c1867f2_34c4_b2ed_5639_41766e6fd7ce bef02968_6cae_fc82_e854_8b053afd9655["__init__()"] 587454b3_6db6_011f_9fa4_3e4e2e09b72d -->|method| bef02968_6cae_fc82_e854_8b053afd9655 0ad508e9_c474_fd89_127a_1e77e78303e4["build_middleware_stack()"] 587454b3_6db6_011f_9fa4_3e4e2e09b72d -->|method| 0ad508e9_c474_fd89_127a_1e77e78303e4 a9c07abb_aad1_48b4_2dbe_359121a449b2["openapi()"] 587454b3_6db6_011f_9fa4_3e4e2e09b72d -->|method| a9c07abb_aad1_48b4_2dbe_359121a449b2 c029d7d0_68b4_7ce7_47cc_25c5b9dccd5d["setup()"] 587454b3_6db6_011f_9fa4_3e4e2e09b72d -->|method| c029d7d0_68b4_7ce7_47cc_25c5b9dccd5d 685cfafc_8748_c8d0_a18b_4be786160320["__call__()"] 587454b3_6db6_011f_9fa4_3e4e2e09b72d -->|method| 685cfafc_8748_c8d0_a18b_4be786160320 25327e8f_c38b_0b1b_93ba_5cf6834fddb3["add_api_route()"] 587454b3_6db6_011f_9fa4_3e4e2e09b72d -->|method| 25327e8f_c38b_0b1b_93ba_5cf6834fddb3 17bcf28f_7595_a117_1722_327988604d26["api_route()"] 587454b3_6db6_011f_9fa4_3e4e2e09b72d -->|method| 17bcf28f_7595_a117_1722_327988604d26 ba33b279_1103_0775_a008_211bf9ab87de["add_api_websocket_route()"] 587454b3_6db6_011f_9fa4_3e4e2e09b72d -->|method| ba33b279_1103_0775_a008_211bf9ab87de 7c16e84d_2ff5_4884_612a_8f36a61c9299["websocket()"] 587454b3_6db6_011f_9fa4_3e4e2e09b72d -->|method| 7c16e84d_2ff5_4884_612a_8f36a61c9299
Relationship Graph
Source Code
fastapi/applications.py lines 48–4672
class FastAPI(Starlette):
"""
`FastAPI` app class, the main entrypoint to use FastAPI.
Read more in the
[FastAPI docs for First Steps](https://fastapi.tiangolo.com/tutorial/first-steps/).
## Example
```python
from fastapi import FastAPI
app = FastAPI()
```
"""
def __init__(
self: AppType,
*,
debug: Annotated[
bool,
Doc(
"""
Boolean indicating if debug tracebacks should be returned on server
errors.
Read more in the
[Starlette docs for Applications](https://www.starlette.dev/applications/#instantiating-the-application).
"""
),
] = False,
routes: Annotated[
Optional[list[BaseRoute]],
Doc(
"""
**Note**: you probably shouldn't use this parameter, it is inherited
from Starlette and supported for compatibility.
---
A list of routes to serve incoming HTTP and WebSocket requests.
"""
),
deprecated(
"""
You normally wouldn't use this parameter with FastAPI, it is inherited
from Starlette and supported for compatibility.
In FastAPI, you normally would use the *path operation methods*,
like `app.get()`, `app.post()`, etc.
"""
),
] = None,
title: Annotated[
str,
Doc(
"""
The title of the API.
It will be added to the generated OpenAPI (e.g. visible at `/docs`).
Read more in the
[FastAPI docs for Metadata and Docs URLs](https://fastapi.tiangolo.com/tutorial/metadata/#metadata-for-api).
**Example**
```python
from fastapi import FastAPI
app = FastAPI(title="ChimichangApp")
```
"""
),
] = "FastAPI",
summary: Annotated[
Optional[str],
Doc(
"""
A short summary of the API.
It will be added to the generated OpenAPI (e.g. visible at `/docs`).
Domain
Defined In
Source
Frequently Asked Questions
What is the FastAPI class?
FastAPI is a class in the fastapi codebase, defined in fastapi/applications.py.
Where is FastAPI defined?
FastAPI is defined in fastapi/applications.py at line 48.
What does FastAPI extend?
FastAPI extends HTTPException, RequestValidationError, WebSocketRequestValidationError, AsyncExitStackMiddleware.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free