Let's say I have several users and each one has a user_id and also friends

To access their friends, they should be logged in, so a session will be established with the server.

Should the REST API for their friends be user/:user_id/friends or just friends


The URL should be the same whether user is logged in or not.

The whole point of REST is to be as stateless as possible. Holding a stateful session so that you can say friends instead of user/:user_id/friends is not stateless, and the URL pointing to a particular resource should always be the same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.