Repaso
Español
Backend & APIsCoreAPI-38

In GET /users/42/orders?status=paid&limit=10, which are the path parameter and the query parameters?

Options

  1. Path: status. Query: 42 and limit
  2. Path: 42 (the user). Query: status and limit (Correct option)
  3. Both are query parameters of the request
  4. 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.

Key terms

Practice this question in Repaso