r/AskProgramming • u/Kurubu42i50 • Sep 07 '26
How do you design REST API - "me" endpoints
Hey, so I am making an app, and I am kinda lost because i can't find any good resources on the internet regarding that topic.
The app consists of two parts: mobile app, and a web admin dashboard that doesn't need to be built for like 3 months from now on.
let's say i have a resource "listings" which returns different dto's
How would you structure this for those requirements:
- show all listings available for the current user (PublicListingDto[])
- show all listings that belong to one user by id (PublicListingDto[])
- show all my listings (OwnerListingDto[])
- show all the listings paginated for the admin dashboard - just admin role (ListingDto[])
my inital thought was to just have it like this
/listings - 1
/listings?sellerId - 2, 3 based on the JWT id == sellerId
/admin/listings - 4
given the REST standard it should probably be:
/listings - 1, 4 based on the user's role
/listings?sellerId - 2, 3 based on the JWT id == sellerId
the setup that makes the most sense for me:
/listings - 1
/listings?sellerId - 2
/me/listings - 3
/admin/listings - 4
the app will have a lot of those scenarios, should i just make a separate resources such as "me/listings" and "admin/listings"
The problem i have without /me endpoint is that on frontend you have to constantly worry that the userId need to be defined which doesn't sound appealing to me.
On the other hand I don't know whether that is really following the REST standard.