__init__() — fastapi Function Reference
Architecture documentation for the __init__() function in routing.py from the fastapi codebase.
Entity Profile
Dependency Diagram
graph TD fbb5c527_c628_1375_0b4b_0dc27f28dba6["__init__()"] ecadd3bc_0c58_b4e5_06d8_57da79199adc["APIRouter"] fbb5c527_c628_1375_0b4b_0dc27f28dba6 -->|defined in| ecadd3bc_0c58_b4e5_06d8_57da79199adc 28261a63_2ba9_f1ff_1d1b_475348a45a65["Default()"] fbb5c527_c628_1375_0b4b_0dc27f28dba6 -->|calls| 28261a63_2ba9_f1ff_1d1b_475348a45a65 1b892f95_174f_a6fa_5ff9_9cd8b88e8ee0["get()"] fbb5c527_c628_1375_0b4b_0dc27f28dba6 -->|calls| 1b892f95_174f_a6fa_5ff9_9cd8b88e8ee0 12dce19e_74a0_f6cd_7c8f_689f6d3bd491["post()"] fbb5c527_c628_1375_0b4b_0dc27f28dba6 -->|calls| 12dce19e_74a0_f6cd_7c8f_689f6d3bd491 6cff2dad_2230_1fe5_9de2_64e60765b27c["route()"] fbb5c527_c628_1375_0b4b_0dc27f28dba6 -->|calls| 6cff2dad_2230_1fe5_9de2_64e60765b27c 6c327ac9_4150_128f_0bae_3ab3977f34f5["_wrap_gen_lifespan_context()"] fbb5c527_c628_1375_0b4b_0dc27f28dba6 -->|calls| 6c327ac9_4150_128f_0bae_3ab3977f34f5 style fbb5c527_c628_1375_0b4b_0dc27f28dba6 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
fastapi/routing.py lines 740–999
def __init__(
self,
*,
prefix: Annotated[str, Doc("An optional path prefix for the router.")] = "",
tags: Annotated[
Optional[list[Union[str, Enum]]],
Doc(
"""
A list of tags to be applied to all the *path operations* in this
router.
It will be added to the generated OpenAPI (e.g. visible at `/docs`).
Read more about it in the
[FastAPI docs for Path Operation Configuration](https://fastapi.tiangolo.com/tutorial/path-operation-configuration/).
"""
),
] = None,
dependencies: Annotated[
Optional[Sequence[params.Depends]],
Doc(
"""
A list of dependencies (using `Depends()`) to be applied to all the
*path operations* in this router.
Read more about it in the
[FastAPI docs for Bigger Applications - Multiple Files](https://fastapi.tiangolo.com/tutorial/bigger-applications/#include-an-apirouter-with-a-custom-prefix-tags-responses-and-dependencies).
"""
),
] = None,
default_response_class: Annotated[
type[Response],
Doc(
"""
The default response class to be used.
Read more in the
[FastAPI docs for Custom Response - HTML, Stream, File, others](https://fastapi.tiangolo.com/advanced/custom-response/#default-response-class).
"""
),
] = Default(JSONResponse),
responses: Annotated[
Optional[dict[Union[int, str], dict[str, Any]]],
Doc(
"""
Additional responses to be shown in OpenAPI.
It will be added to the generated OpenAPI (e.g. visible at `/docs`).
Read more about it in the
[FastAPI docs for Additional Responses in OpenAPI](https://fastapi.tiangolo.com/advanced/additional-responses/).
And in the
[FastAPI docs for Bigger Applications](https://fastapi.tiangolo.com/tutorial/bigger-applications/#include-an-apirouter-with-a-custom-prefix-tags-responses-and-dependencies).
"""
),
] = None,
callbacks: Annotated[
Optional[list[BaseRoute]],
Doc(
"""
OpenAPI callbacks that should apply to all *path operations* in this
router.
It will be added to the generated OpenAPI (e.g. visible at `/docs`).
Read more about it in the
[FastAPI docs for OpenAPI Callbacks](https://fastapi.tiangolo.com/advanced/openapi-callbacks/).
"""
),
] = None,
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.
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does __init__() do?
__init__() is a function in the fastapi codebase, defined in fastapi/routing.py.
Where is __init__() defined?
__init__() is defined in fastapi/routing.py at line 740.
What does __init__() call?
__init__() calls 5 function(s): Default, _wrap_gen_lifespan_context, get, post, route.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free