A URL Splits Into Scheme, Host, Path, Query, and Fragment
A URL divides into five parts: the scheme, the host, the path, the query, and the fragment. The scheme and host say where to connect. The path says what is being pointed at. The query comes after a ? and narrows the request with key-value pairs. The fragment comes after a # and is used only by the browser, so it is never sent to the server. The query and the fragment are optional.
A path parameter is the part of the path that identifies which resource is meant, like the 42 in /users/42. A query parameter is the part that changes how the request to that resource behaves, like ?sort=name.
So the id, which identifies the resource, goes in the path. An optional filter, which doesn't identify a resource, goes in the query.
Break a URL into its scheme, host, path, query, and fragment, and choose between a path parameter and a query parameter for a given piece of data.
Given https://api.example.com/users/42?fields=name,email, which part identifies which specific user the request is about?