get() — fastapi Function Reference
Architecture documentation for the get() function in applications.py from the fastapi codebase.
Entity Profile
Dependency Diagram
graph TD d15d0d82_652d_c556_d699_e3ccf1192b8e["get()"] 587454b3_6db6_011f_9fa4_3e4e2e09b72d["FastAPI"] d15d0d82_652d_c556_d699_e3ccf1192b8e -->|defined in| 587454b3_6db6_011f_9fa4_3e4e2e09b72d bef02968_6cae_fc82_e854_8b053afd9655["__init__()"] bef02968_6cae_fc82_e854_8b053afd9655 -->|calls| d15d0d82_652d_c556_d699_e3ccf1192b8e c029d7d0_68b4_7ce7_47cc_25c5b9dccd5d["setup()"] c029d7d0_68b4_7ce7_47cc_25c5b9dccd5d -->|calls| d15d0d82_652d_c556_d699_e3ccf1192b8e 1b892f95_174f_a6fa_5ff9_9cd8b88e8ee0["get()"] d15d0d82_652d_c556_d699_e3ccf1192b8e -->|calls| 1b892f95_174f_a6fa_5ff9_9cd8b88e8ee0 28261a63_2ba9_f1ff_1d1b_475348a45a65["Default()"] d15d0d82_652d_c556_d699_e3ccf1192b8e -->|calls| 28261a63_2ba9_f1ff_1d1b_475348a45a65 style d15d0d82_652d_c556_d699_e3ccf1192b8e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
fastapi/applications.py lines 1544–1915
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[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
Source
Frequently Asked Questions
What does get() do?
get() is a function in the fastapi codebase, defined in fastapi/applications.py.
Where is get() defined?
get() is defined in fastapi/applications.py at line 1544.
What does get() call?
get() calls 2 function(s): Default, get.
What calls get()?
get() is called by 2 function(s): __init__, setup.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free