I need a URI in my REST API to retrieve the current logged in user. Usually I use GET
on resource with ID, but the client doesn't know the ID of the user.
I found the following solutions:
By user name
This solution uses the user name instead of the ID of the user.
Example:
- Bitbucket REST API:
GET /user/{userSlug}
- Bitbucket REST API:
With own resource
This solution has one resource for users and one additional resource for logged in user.
Examples:
JIRA REST API:
GET /myself
GitHub REST API:
GET /user
Stack Exchange REST API:
GET /me
With symbolic link
This solution has a symbolic link for the ID of the user.
Example:
- Confluence REST API:
GET /user/current
- Confluence REST API:
With filter
This solution uses a filter for the user name.
Example:
- JIRA REST API:
GET /user?username={username}
- JIRA REST API:
Which one is most RESTful? What are the pros and cons?