I am creating a new API and researched for some good API naming conventions.
For example you have an API like:
GET - /users | Get all users
GET - /users/:id | Get user with :id
DELETE - /users/:id | Delete user with :id
POST - /users | Create a new user
Now I want to add a route for getting a user by name to implement a backend route for autocompletion/typeahead component in frontend.
Any suggestions for a good naming?
What do you think about:
GET - /users/name/:name | Get user with :name
Since you would basically just filter users, you should use query parameters to pass any filters
/users?name=xxx&other=xxx
This will allow you to keep your routes clean, and allow you to pass multiple parameters in the future