Sign up ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

I have a resource that can be represented in one of two ways:

  1. Big Serial Number, or
  2. Small Serial Number

Is it closer adherence to REST principles to:

To me, it seems like having it in the URI (option C) specifies an entirely different resource, and in this case, they should represent the exact same resource. Is option A the best way to represent this?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

How you decide to structure your URI is not essential to REST, which is an interaction model. If you work with web servers, and you work on a per-request basis instead of a conversation basis, you're already in the RESTful way of working.

I'm not aware of an accepted consensus on what shape of URI is preferable, and it may be a matter of opinion. I prefer C because I see the URI path as the 'solid' part of a URI, and the query parameters as a 'temporal', per-query modification, such as requesting it in JSON instead of XML. But ultimately, that's just my opinion. At any rate, there is no rule against having multiple URIs for the same information, so C is no less viable than the others.

StackOverflow has an interesting question and insightful answers on this: REST API Best practices: Where to put parameters?

As for your IDs, I'm going to look at this problem through the lens of a hypothetical user/consumer of your URIs, which brings me to two considerations:

Are your ID types syntactically distinguishable? As in, if I just give you a string, can you tell with 100% certainty which type it is? If yes, don't distinguish between short and long; accept them both interchangeably.

Does the small number need more info? A category, maybe? Then you have two different paths already, and you don't need to worry about the rest (no pun intended):
share|improve this answer
Presently, I would be able to tell the difference, based on pre-defined lengths of the strings (ex: I know 3 characters is the small variant and 9 characters is the big variant). In which case, the only URLs are ( and ( but even though they reference the same resource, would that not make them seem like two distinct resources? – Bullines May 23 '14 at 20:22
@Bullines I don't see an immediate problem with a resource being available from several URIs, but if this does present an issue I'm unaware of, you could define a preferred, canonical URI and have other entry points redirect to your preferred one. – JvR May 23 '14 at 20:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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