DEV Community

Sarvesh Kesharwani
Sarvesh Kesharwani

Posted on

Whats the difference b/w Path and Query in FastAPI?

Path parameters are part of the URL path and are required.
Example: /get_patient_data/1
— here, 1 is a path parameter.

Query parameters come after the ? in the URL and are **optional **by default.
Example: /sorted_patient_list?sort_by=asc
— here, sort_by=asc is a query parameter.

Top comments (0)