get() — fastapi Function Reference
Architecture documentation for the get() function in routing.py from the fastapi codebase.
Entity Profile
Dependency Diagram
graph TD 1b892f95_174f_a6fa_5ff9_9cd8b88e8ee0["get()"] ecadd3bc_0c58_b4e5_06d8_57da79199adc["APIRouter"] 1b892f95_174f_a6fa_5ff9_9cd8b88e8ee0 -->|defined in| ecadd3bc_0c58_b4e5_06d8_57da79199adc d15d0d82_652d_c556_d699_e3ccf1192b8e["get()"] d15d0d82_652d_c556_d699_e3ccf1192b8e -->|calls| 1b892f95_174f_a6fa_5ff9_9cd8b88e8ee0 ff95ab0c_7f10_f29e_f615_ea529a87d199["get_openapi_operation_metadata()"] ff95ab0c_7f10_f29e_f615_ea529a87d199 -->|calls| 1b892f95_174f_a6fa_5ff9_9cd8b88e8ee0 200f313e_38b9_296f_f9aa_afdeacb6b8ad["get_openapi_path()"] 200f313e_38b9_296f_f9aa_afdeacb6b8ad -->|calls| 1b892f95_174f_a6fa_5ff9_9cd8b88e8ee0 ad8d62d9_53da_514b_c06f_53293eb1e5ae["get_request_handler()"] ad8d62d9_53da_514b_c06f_53293eb1e5ae -->|calls| 1b892f95_174f_a6fa_5ff9_9cd8b88e8ee0 a0d87950_5de5_3ab2_72f7_0a20a6e00434["get_websocket_app()"] a0d87950_5de5_3ab2_72f7_0a20a6e00434 -->|calls| 1b892f95_174f_a6fa_5ff9_9cd8b88e8ee0 d8b4fb83_3521_0b7e_fcfa_0c7f161ca116["__init__()"] d8b4fb83_3521_0b7e_fcfa_0c7f161ca116 -->|calls| 1b892f95_174f_a6fa_5ff9_9cd8b88e8ee0 fbb5c527_c628_1375_0b4b_0dc27f28dba6["__init__()"] fbb5c527_c628_1375_0b4b_0dc27f28dba6 -->|calls| 1b892f95_174f_a6fa_5ff9_9cd8b88e8ee0 c1d02f65_9a84_123a_bdd4_304e5732f35a["include_router()"] c1d02f65_9a84_123a_bdd4_304e5732f35a -->|calls| 1b892f95_174f_a6fa_5ff9_9cd8b88e8ee0 306d2b89_dcbb_e5e5_1f73_f6502e8fbf6a["test_get_path()"] 306d2b89_dcbb_e5e5_1f73_f6502e8fbf6a -->|calls| 1b892f95_174f_a6fa_5ff9_9cd8b88e8ee0 ab4b18c4_8861_3800_8b44_9a88963732a7["test_openapi_schema()"] ab4b18c4_8861_3800_8b44_9a88963732a7 -->|calls| 1b892f95_174f_a6fa_5ff9_9cd8b88e8ee0 151590c8_e931_55e7_3262_5eca3d623171["test_top_level_generate_unique_id()"] 151590c8_e931_55e7_3262_5eca3d623171 -->|calls| 1b892f95_174f_a6fa_5ff9_9cd8b88e8ee0 4fd33aaf_fe3e_7115_3638_8d3a4c4e1b68["test_router_overrides_generate_unique_id()"] 4fd33aaf_fe3e_7115_3638_8d3a4c4e1b68 -->|calls| 1b892f95_174f_a6fa_5ff9_9cd8b88e8ee0 b5d0d990_bd82_76ac_e2e3_5f9bb785fbaf["test_router_include_overrides_generate_unique_id()"] b5d0d990_bd82_76ac_e2e3_5f9bb785fbaf -->|calls| 1b892f95_174f_a6fa_5ff9_9cd8b88e8ee0 style 1b892f95_174f_a6fa_5ff9_9cd8b88e8ee0 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
fastapi/routing.py lines 1509–1884
def get(
self,
path: Annotated[
str,
Doc(
"""
The URL path to be used for this *path operation*.
For example, in `http://example.com/items`, the path is `/items`.
"""
),
],
*,
response_model: Annotated[
Any,
Doc(
"""
The type to use for the response.
It could be any valid Pydantic *field* type. So, it doesn't have to
be a Pydantic model, it could be other things, like a `list`, `dict`,
etc.
It will be used for:
* Documentation: the generated OpenAPI (and the UI at `/docs`) will
show it as the response (JSON Schema).
* Serialization: you could return an arbitrary object and the
`response_model` would be used to serialize that object into the
corresponding JSON.
* Filtering: the JSON sent to the client will only contain the data
(fields) defined in the `response_model`. If you returned an object
that contains an attribute `password` but the `response_model` does
not include that field, the JSON sent to the client would not have
that `password`.
* Validation: whatever you return will be serialized with the
`response_model`, converting any data as necessary to generate the
corresponding JSON. But if the data in the object returned is not
valid, that would mean a violation of the contract with the client,
so it's an error from the API developer. So, FastAPI will raise an
error and return a 500 error code (Internal Server Error).
Read more about it in the
[FastAPI docs for Response Model](https://fastapi.tiangolo.com/tutorial/response-model/).
"""
),
] = Default(None),
status_code: Annotated[
Optional[int],
Doc(
"""
The default status code to be used for the response.
You could override the status code by returning a response directly.
Read more about it in the
[FastAPI docs for Response Status Code](https://fastapi.tiangolo.com/tutorial/response-status-code/).
"""
),
] = None,
tags: Annotated[
Optional[list[Union[str, Enum]]],
Doc(
"""
A list of tags to be applied to the *path operation*.
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/#tags).
"""
),
] = None,
dependencies: Annotated[
Optional[Sequence[params.Depends]],
Doc(
"""
A list of dependencies (using `Depends()`) to be applied to the
*path operation*.
Read more about it in the
Domain
Subdomains
Defined In
Called By
- __init__()
- __init__()
- get()
- get_openapi_operation_metadata()
- get_openapi_path()
- get_request_handler()
- get_websocket_app()
- include_router()
- test_app_path_operation_overrides_generate_unique_id()
- test_callback_override_generate_unique_id()
- test_get()
- test_get_path()
- test_openapi_schema()
- test_router_include_overrides_generate_unique_id()
- test_router_overrides_generate_unique_id()
- test_router_path_operation_overrides_generate_unique_id()
- test_subrouter_top_level_include_overrides_generate_unique_id()
- test_top_level_generate_unique_id()
- test_warn_duplicate_operation_id()
Source
Frequently Asked Questions
What does get() do?
get() is a function in the fastapi codebase, defined in fastapi/routing.py.
Where is get() defined?
get() is defined in fastapi/routing.py at line 1509.
What does get() call?
get() calls 3 function(s): Default, api_route, include_router.
What calls get()?
get() is called by 19 function(s): __init__, __init__, get, get_openapi_operation_metadata, get_openapi_path, get_request_handler, get_websocket_app, include_router, and 11 more.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free