I understand that when naming RESTful URI's it is commonly accepted to use plurals to represent collections of resources. I am curious as to the argument for using singular nouns instead.
2 Answers
Some resources contain only a single item. Good examples would be everything for which you don't need an ID to find out what data to render. Very common for example would be the Login resource. You have (from the users and browsers view) only a single login. You can create it, you can destroy it but you won't have an index action with several Logins to choose from.
Similar examples would be some mostly static pages like company information, imprints, contact forms and similar things that only display a single item or only allow a single create action.
It could be a matter of discussion if using singular nouns really adds much to readability of the code.
Because:
- English plural rules like "cherries" are not the nicest thing to think of while developing API, particularly when english is not your mother tongue.
- Sometimes you want to generate endpoint from the model, which is usually singular. It does not play nicely with the above.
- The argument "usually you start querying by a Get to display a list" does not refer to any real use case. And you will end up querying single items as much as and even more than a list of items.