DEV Community

Discussion on: Best practice for building a RESTful API

Collapse
 
belkheir profile image
Mahamed Belkheir

I like to think about plural vs singular by what that part of the url means, if it's an entity, a plural makes sense, you're not saying "I want all the posts", it's more like "I want to interact with the entity 'Posts'", with a GET at "/" being all/pagination, "/:id" being a singular fetch, Posting to a entity would be making a create request and what not.

I like this approach because it lowers variance, and imo easier to abstract for the frontend, instead of having to manually pick the singular/plural form, you can have just one word to refer to all the entity CRUD operations