(Sorry, the title of the question is difficult to summarize this question.)
On Facebook, you like things. On Twitter, you follow people. On GitHub, you also follow people and star repositories and gists.
All of these cases are quite similar: these connections are lightweight, not "resources" themselves. For instance. none of these three APIs provides public identifiers for such connections.
The question arises: what is the "best" (from the point of view of REST) โโway to open the API to create / request / delete these connections?
Facebook does [ 1 ]:
GET /:id/likes to request a liked object (more precisely, users who like this object)
POST /:id/likes to like something (on behalf of an authorized user, a body was not required)
DELETE /:id/likes , unlike anything (on behalf of the user to whom auth'ed was granted)
The query and creation make sense, but DELETE bit "unRESTful" because you are not actually deleting the /:id/likes resource (an array of users who like this object).
This discrepancy manifests itself in another case [ 2 ]:
GET /me/likes/:id to ask if you like something.
Thus, a connection request requests a completely different resource than creating or deleting it.
GitHub relies on the /me/likes/:id style for the following users and main repositories [ 3 ]:
(Note that GitHub /user represents an auth'ed user, such as Facebook /me .)
GET /user/starred/:owner/:repo to query if a repo is taking place (returns 204 or 404, no body anyway)
PUT /user/starred/:owner/:repo for the main role of the repo (the body does not need in the request)
DELETE /user/starred/:owner/:repo to disorder the repo
This is much more consistent, but unfortunately it separates the individual "stars" from the group:
GET /repos/:owner/:repo/stargazers to request users who prevented the repo
GitHub , interestingly, uses a different style for the main roles [ 4 ]:
GET /gists/:id/star to ask if you have a gist marked
PUT /gists/:id/star for the main role
DELETE /gists/:id/star to unorder gist
This saves the action in the lead role using a gist resource, such as Facebook, rather than a user resource.
GitHub does not publish giant writers, but presumably it will be, for example:
GET /gists/:id/stargazers to request users who flagged gist
While star-shaped ones do represent a different resource / name than a star, the names are similar and clearly related, and both are on the same resource.
The only drawback I can think of is to name the resource. Something like star works, but actions like follow or like harder.
(You do not need to include the Twitter API as an example, as it is hardly RESTful.)
Obviously, there is no absolutely RESTful API for creating / requesting / deleting things that are not proper resources, but are there any other pros / cons that I don't see, or other styles to consider?
Thanks!