← All notes

Path and query parameters in FastAPI

Answer: The value of the path parameter item_id will be passed to your function as the argument item_id. When you declare other function parameters that are not part of the path parameters, they are automatically interpreted as "query" parameters. (S1, S2)

Types give validation

Query parameters

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: FastAPI docs, Path Parameters - FastAPI, MIT (fastapi/fastapi LICENSE; Copyright (c) 2018 Sebastián Ramírez; https://github.com/fastapi/fastapi/blob/master/LICENSE); FastAPI docs, Query Parameters - FastAPI, MIT (fastapi/fastapi LICENSE; Copyright (c) 2018 Sebastián Ramírez; https://github.com/fastapi/fastapi/blob/master/LICENSE).

Cite this

Permanent ID: iil:note:gbmmqzdy

iinventedlight. 2026. "Path and query parameters in FastAPI." iinventedlight Library, iil:note:gbmmqzdy, version of 2026-11-04. https://iinventedlight.com/library/notes/fastapi-path-query-params/. License: CC-BY-4.0.

@misc{iil_note_gbmmqzdy,
  author = {{iinventedlight}},
  title = {{Path and query parameters in FastAPI}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-04},
  url = {https://iinventedlight.com/library/notes/fastapi-path-query-params/},
  note = {Permanent ID iil:note:gbmmqzdy. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.

For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/fastapi-path-query-params.md.