Path Parameter
noun
say it: “path puh-RAM-ih-ter” /pæθ pəˈræmɪtər/
A changing part of a web address, such as the 7 in /recipes/7, which FastAPI hands to your function, converted to the type its hint names.
What is Path Parameter?
A path parameter is a changing part of the URL, like {recipe_id}. The type hint makes FastAPI convert and check it.
@app.get('/recipes/{recipe_id}')
def get_recipe(recipe_id: int):
return find_recipe(recipe_id)
In a sentence
- “The path parameter arrives as an int because the function's hint says recipe_id: int.”
- “In /recipes/{recipe_id}, recipe_id is a path parameter.”
Level: Apprentice · More FastAPI terms at this level
Updated