- Technically they can be used inter-changeably
- Conventionally,
- If the parameter is a unique identifier - go for path param
- If it’s not unique - go for query param
This convention makes sense for REST at least
- In REST, we use URIs (Unique Resource Identifiers)
- Thus, if the request parameter uniquely identifies a resource, it makes sense to put it in the path param
Usage (Parallels to DB)
- If a DB column is full of unique values, then it can be used to identify - path
- If a column is of categorical values, then it can be used to filter - query