Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • Another option for GET /appointments/ would be to query all appointments the current user is allowed to see. That would be only their own appointments for a regular user and the appointments of all users for an administrator. Commented Jan 12, 2021 at 8:03
  • @BartvanIngenSchenau I do not like query state being based upon context, especially not fort REST APIs. Imho it is best to have the query completely describe what data is queried, and not hide the context somewhere. Having a current magic ID is already a compromise, but at least its explicit in the route what happens. Commented Jan 12, 2021 at 10:51
  • For me, an endpoint description of "all the appointments you are allowed to access" is in the same category as what you describe as responses for GET /users/{id}, where you can get a 403 response or a user object based on your authorization level. Commented Jan 12, 2021 at 13:06
  • @BartvanIngenSchenau Sure, its a possibility. Its not entirely wrong to have some redundancy in endpoints, either. However, there is a conceptual difference. If GET /appointments/ delivers all appointments that the user has access to, then it is circumstance that as a normal user, you get exactly your appointments. This falls apart as soon as you have more complex authorization schemes where a user might be able to access more then just their own appointments. And it means its impossible for an admin to query only their appointments. Commented Jan 12, 2021 at 14:55
  • @BartvanIngenSchenau By having a GET /user/{id}/appointment endpoint, you have a contractual guarantee to get exactly what you need and ask for and don't depend on circumstance to get the right answer. Commented Jan 12, 2021 at 14:59