Type Hints in FastAPI
noun
say it: “TYP HINTS in FAST-AY-PEE-EYE” /taɪp ˈhɪnts ɪn ˈfæstˌeɪˌpiˌaɪ/
The type annotations on a FastAPI route's parameters, such as plot_id: int, which FastAPI uses to convert and check input and to write the docs.
What is Type Hints in FastAPI?
Type hints like name: str are how you tell FastAPI what to expect. It uses them to check input, convert values, power editor autocompletion and write the docs.
In a sentence
- “The type hints on the route told FastAPI to turn "7" into the number 7.”
- “With type hints on every parameter, a request for /plots/seven got a 422 instead of reaching the code.”
Level: Apprentice · More FastAPI terms at this level
Updated