In GET /users/42/orders?status=paid&limit=10, which are the path parameter and the query parameters?
Options
- Path: status. Query: 42 and limit
- Path: 42 (the user). Query: status and limit (Correct option)
- Both are query parameters of the request
- The URL does not contain any parameters
Answer
Path: 42 (identifies the user); query: status and limit (filter/options)
Why
Path parameters are part of the URL path and usually identify a specific resource: /users/42 → user 42.
Query parameters come after ?, separated by &, and usually filter, sort or paginate: status=paid, limit=10.
In FastAPI: def orders(user_id: int, status: str | None = None, limit: int = 10).
Remember
Path = which resource. Query = how to filter it.