-1

Github uses the convention "/user" (singular) to interact with the logged-in user's info. They still have the full "/users" suite of paths to support getting info based on IDs (or usernames in their case), but the singular resource took me by surprise.

Is this common/accepted/desired across the web, or is this just a quirk that Github uses?

https://developer.github.com/v3/users/

3

Is this common/accepted/desired across the web, or is this just a quirk that Github uses?

I'd guess "uncommon, but acceptable." For instance, the stackexchange API uses /me as a shorthand for "the user associated with this access token".

the singular resource took me by surprise

It really shouldn't (although it isn't at all your fault that it did). The conventions of URI assert that the path segments are organized hierarchically, but there is no requirement or expectation that the root is reserved for collections only.

The canonical example would probably be /index.html.

Could an api use the spelling /users/me instead? Well, REST doesn't care how URI are spelled, and that's certainly a reasonable organization of a hierarchy, so RFC 3986 is satisfied. It's just path segments, so it ought to be straight forward for any reasonable routing implementation.

An organization might reasonably decide that they didn't want two (or more) matching rules in play under a given root.

It really just comes down to which conventions an organization thinks will drive better adoption.

  • 2
    "REST doesn't care how URI are spelled" – I would go further: ReST is about Hypermedia as the Engine of Application State, which means that the Application State advances by following links given to you. Since the links are given to you, and all you need to do is follow them, it is completely irrelevant what the URIs actually are. So, not only does ReST not care how URI are spelled, caring about how URI are spelled implies that you are not doing ReST! (Note there are other reasons to care about how URI are spelled, e.g. debuggability, SEO, etc., but ReST doesn't and mustn't care.) – Jörg W Mittag May 16 '17 at 8:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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