REST API Design – How to Approach User Related Resources

api-designrest

I have a REST API in development were some resources are user related, and users need to authenticate to access those resources. It's tempting to take a shortcut and replace an identifier of:

/profile/[user_id]/

with

/profile/

considering that the user_id is known based on authentication data. In such case the /profile/ identifier means a different resource for each user. This does not seem very representational, unless we consider that the Authentication header is being a part of the identifier.
A more complex example when let's say there is an 'item' resource available for all users and every user can set their own 'label' property to an item. Again it's tempting to have just

/item/[item_id]/label/

instead of

/item/[item_id]/label/[user_id]

I have found one example where striping the user_id part has lead to potential problems (a case where an admin user was introduced, who should be able to access all users resources, but also filter them by user – A Web application as a REST API client: how to handle resource identifiers) but it didn't seem a very big issue.
Are there any good reasons why authentication data should not be considered part of the resource identifier?

Best Answer

I've used /profiles/me before, it doesn't strike me as not representational. Some popular REST APIs have it as well. See this answer on SO.

If you're worried about ambiguity, you can always have a fully defined URI alongside the short one pointing to the same resource, and give that one to clients in sensitive contexts.