Parameters in FastAPI

Parameters in FastAPI: Path Parameters and Their Types, Query Parameters: Filters and Options.

Updated

  1. Path Parameters and Their Types (Apprentice): A path parameter such as {game_id} lets one FastAPI route answer every address of its shape, its type hint turns the text from the address into a number, FastAPI answers 422 when it can't, and a fixed path such as /games/today goes above the path parameter that would catch it.
  2. Query Parameters: Filters and Options (Apprentice): A FastAPI function parameter that isn't in the route's path is read from the query string, so a default of None makes an optional filter, a bool reads yes-or-no values such as true and 0, and several filters combine in one request.