DEV Community

Discussion on: Design an easy to use and flexible REST API

Collapse
 
orelkan profile image
Orel Kanditan

Hi nice post.

In my opinion, GET /api/user returning the list of all users is unclear as it sounds like a single entity, so it should be GET /api/users. What do you think about that? Is there a standard I'm missing?

Collapse
 
anwar_nairi profile image
Anwar • Edited

I like this suggestion! I am used to matching the name of my routes to the table it corresponds, because Laravel's router will generate the routes for you like this:

Route::resource("user", "UserController");

This will automatically create these routes for you:

Route::get("/user", "UserController@index");
Route::get("/user/{id}", "UserController@show");

// ...

I guess it is a matter of habit for me 😅 Anyway, I think using /api/users for the list of users makes a lot more sense for routes that are served to end users, so good point here!