Concepts 🚀 Project 🧮 Labs
🧮 Labs / FastAPI / Query params — ?key=value after the path

Query params — ?key=value after the path

Function args that AREN'T path params become query params. Optional with defaults.

main.py v3.1
API simulator click Simulate
Click "Simulate" to see what this FastAPI app does.
🧠 How it works

Function args that aren't path params are auto-treated as query params. Arg with default (limit: int = 10) — optional. Arg without default (q: str) — required. Optional[T] = None — explicitly optional, defaults to None. bool params accept: true/false, 1/0, yes/no, on/off (case-insensitive). Query params appear after ? in URL, separated by &: ?a=1&b=2&c=3. Great for pagination (skip/limit), filters (category), feature flags (verbose).

✏️ Try these changes
  • Change limit: int = 10 to limit: int = 5
    → fewer items per page
  • Add a new query param sort: str = 'asc'
    → /items?sort=desc
  • Change verbose: bool = False to verbose: bool = True
    → default flips
  • Add a required query param by removing the default: q: str
    → /items?q=... is required, returns 422 if missing