title: REST API, path variable vs request param
body: <p>I am currently writing a webservice providing access to some resources. I try to follow REST but I am facing a problem concerning some parts of my API.</p>
  
  <p>I have the follwing uris:</p>
  
  <ul>
  <li><em>/myservice/users/</em> : to get all users</li>
  <li><em>/myservice/users/{userId}</em> : to get a specific user</li>
  <li><em>/myservice/badges/</em> : to get all badges</li>
  <li><em>/myservice/badges/{badgeId}</em> : to get a specific badge</li>
  </ul>
  
  <p>Now, my problem is, i have to implement a way to get all users that have a particular badge.
  I can consider that this is just a filter I apply on the list of users, hence the following uri:</p>
  
  <ul>
  <li><em>/myservice/users/?filter=badge:{badgeId}</em></li>
  </ul>
  
  <p>Or I can consider that this is just a sub-resources of a badge, hence the following uri:</p>
  
  <ul>
  <li><em>/myservice/badges/{badgeId}/users/</em></li>
  </ul>
  
  <p>Which one seems the must 'REST-compliant' ?</p>
  
  <p>I must say I have read some posts on this subject specifically this one: <a href="https://stackoverflow.com/questions/3198492/rest-standard-path-parameters-or-request-parameters">Rest Standard: Path parameters or Request parameters</a> but they don't seem to cover my problem.</p>