What is the recommended convention to be followed for identifying different GET endpoints that fetch the same model/entity using different fields/parameters?
For example, there is a
Student entity for which I wish to expose different GET endpoints. Suppose the first GET endpoint is a get-by-id endpoint that fetches
Student based on the provided ID. Another endpoint might involve fetching
Student based on, say,
I have a couple of possible approaches for designing their endpoints
- Use separate endpoints
- Use a single endpoint
/studentsand accept request parameters like
/students?phone=123and then in the backend resolve which method must be used for fetching.
What is the recommended method for this?