I have a REST API that looks something like the below where a person can belong to an organisation (but doesn't have to) and a person has many items. The items may also belong to the organisation instead of the person.


There is a scenario where we want to query the items for multiple people within an organisation, what's the correct URL structure to use?

Option 1


Option 2


Option 3

  • None of your options follow the URL structure above.. , you've lopped off the personId parameter and turned it into a query parameter instead. did you mean to do this?
    – Erik
    Commented Jul 2, 2014 at 16:47
  • Yes, because I want to query for items that belong to multiple people.
    – Jamie
    Commented Jul 3, 2014 at 13:23

2 Answers 2


It really doesn't matter that much. Your URL is just a 'unique resource locator' the format you use is up to you. Go with what you are most confortable with and your users will understand.

Having said that I'd go with ?personId=1&personid=2 just because its easy to parse/read

take a look at this similar question

  • Hmm, I think I'd go with something like ?personIDs=1,2,3 Commented May 18, 2015 at 22:09

I would possibly do something similar to how Microsoft deals with choosing pages to print. An example of this is:

To show user 3


To show all users from 10-50


To show user 1 to 3 and 5 and 10 to 20


It gives complete freedom and can be developed quite easily.

For completeness, I've deviced a simple example in Javascript:

var input = "3,4,5,10-20,55".split(',');
var complete = [];

for (var x = 0; x < items.length; x++) {
  var item = input[x];
  if (item.contains("-")) {
    var range = item.split("-");
    for (var i = range[0]; i <= range[1]; i++) {
  } else {

console.log(complete); //["3", "4", "5", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "55"]
  • 1
    noice, gonna write some tests for parsing unparsing this. Commented Aug 1, 2019 at 4:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.