Different responses to different clients, for the same URL, are fine.
StackExchange does this:
GET /me/comments/{toid}
which is documented here .
Twitter also does this:
GET /statuses/home_timeline
which is documented here .
Both of these URLs display an authenticated user. Yes, it wins caching if users share the cache, but IMO, that's fine. Whether this breaks the "identification resource" REST limitation is probably debatable. The answer to this question, and the subsequent comment there shows me why this is debatable.
In fact, among the options you specify URLs that are not "context sensitive":
GET /api/mails?senderUserId=109&receiverUserId=110
This one will always return messages from 109 to 110. But if one client wants to see this result when viewing "sent" messages, the other will see this result when viewing "received" messages. What a strange ah? In addition, on the server you will need to verify that the authenticated user is 109 | 110, otherwise throw 401 UNAUTHORIZED
.
I would go with something like:
GET /mail/sent
returns all sent mail. A:
GET /mail/sent?to=110 (like applying a 'filter' to /mail/sent) OR GET /mail/sent/110 (clean URL)
returns mail sent to number 110.
source share