Home / Function/ Query() — fastapi Function Reference

Query() — fastapi Function Reference

Architecture documentation for the Query() function in param_functions.py from the fastapi codebase.

Entity Profile

Dependency Diagram

graph TD
  8864e1f8_8173_ce5c_602b_445aa33f20f8["Query()"]
  24a9a43e_697f_81ce_6a7c_28a423a6f93b["param_functions.py"]
  8864e1f8_8173_ce5c_602b_445aa33f20f8 -->|defined in| 24a9a43e_697f_81ce_6a7c_28a423a6f93b
  8f264cc6_9c21_2715_d7f6_3cfe387c114b["test_no_annotated_defaults()"]
  8f264cc6_9c21_2715_d7f6_3cfe387c114b -->|calls| 8864e1f8_8173_ce5c_602b_445aa33f20f8
  855800fe_8ed6_9992_2502_3aee9f134f35["test_multiple_annotations()"]
  855800fe_8ed6_9992_2502_3aee9f134f35 -->|calls| 8864e1f8_8173_ce5c_602b_445aa33f20f8
  style 8864e1f8_8173_ce5c_602b_445aa33f20f8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

fastapi/param_functions.py lines 358–699

def Query(  # noqa: N802
    default: Annotated[
        Any,
        Doc(
            """
            Default value if the parameter field is not set.

            Read more about it in the
            [FastAPI docs about Query parameters](https://fastapi.tiangolo.com/tutorial/query-params-str-validations/#alternative-old-query-as-the-default-value)
            """
        ),
    ] = Undefined,
    *,
    default_factory: Annotated[
        Union[Callable[[], Any], None],
        Doc(
            """
            A callable to generate the default value.

            This doesn't affect `Path` parameters as the value is always required.
            The parameter is available only for compatibility.
            """
        ),
    ] = _Unset,
    alias: Annotated[
        Optional[str],
        Doc(
            """
            An alternative name for the parameter field.

            This will be used to extract the data and for the generated OpenAPI.
            It is particularly useful when you can't use the name you want because it
            is a Python reserved keyword or similar.

            Read more about it in the
            [FastAPI docs about Query parameters](https://fastapi.tiangolo.com/tutorial/query-params-str-validations/#alias-parameters)
            """
        ),
    ] = None,
    alias_priority: Annotated[
        Union[int, None],
        Doc(
            """
            Priority of the alias. This affects whether an alias generator is used.
            """
        ),
    ] = _Unset,
    validation_alias: Annotated[
        Union[str, AliasPath, AliasChoices, None],
        Doc(
            """
            'Whitelist' validation step. The parameter field will be the single one
            allowed by the alias or set of aliases defined.
            """
        ),
    ] = None,
    serialization_alias: Annotated[
        Union[str, None],
        Doc(
            """
            'Blacklist' validation step. The vanilla parameter field will be the
            single one of the alias' or set of aliases' fields and all the other
            fields will be ignored at serialization time.
            """
        ),
    ] = None,
    title: Annotated[
        Optional[str],
        Doc(
            """
            Human-readable title.

            Read more about it in the
            [FastAPI docs about Query parameters](https://fastapi.tiangolo.com/tutorial/query-params-str-validations/#declare-more-metadata)
            """
        ),
    ] = None,
    description: Annotated[
        Optional[str],
        Doc(
            """

Domain

Subdomains

Frequently Asked Questions

What does Query() do?
Query() is a function in the fastapi codebase, defined in fastapi/param_functions.py.
Where is Query() defined?
Query() is defined in fastapi/param_functions.py at line 358.
What calls Query()?
Query() is called by 2 function(s): test_multiple_annotations, test_no_annotated_defaults.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free