I'm looking at implementing a new RESTFul call where a User can follow/unfollow a generic 'thing' item, but I need to know the best or common approach below, 1 or 2?

1) A GET or POST on the following URL's:



2) A POST containing thing_to_follow_id




The first seems the most restful, but it feels wrong to post an empty payload where the second allow me to do a GET and return all things a user is following.

What is the best approach here?

3 Answers 3


Per the HTTP spec, GET calls should be safe - that is,

the client does not request, and does not expect, any state change on the origin server as a result of applying a safe method to a target resource

Furthermore, one of the principles of REST is that URIs point to things (nouns), rather than to actions (verbs). In your case, the user would have a collection of things that they follow. That might look more like:

add a new thing to the collection of things the user follows
POST /user/follows 

get all the things the user follows
GET /user/follows

stop following a thing
DELETE /user/follows/{id}

Another option would be to use a mapping resource, such as:

add a new thing to the collection of things the user follows
POST /user-follows

 get all the things the user follows
 GET /user-follows?userId={id}

 get all the users following a thing
 GET /user-follows?thingId={id}

 stop following a thing
 DELETE /user-follows/{id}
 DELETE /user-follows?thingId={id}&userId={id}
  • @svarog raises a good point. In some of these cases - those where you have all the information on the client - PUT would be superior to POST because of its idempotency guarantee.
    – Eric Stein
    Jan 9, 2017 at 14:42
  • Yes, that makes sense! GET should always be safe and the fact a user is 'creating' a new object should not be done with a GET. But, what worries me is that I would also need to find out the 'follow ID' to unfollow an item or edit it. For example, if a user is following an 'Article' to unfollow it I would need to know they were first following it. I guess that's an easy problem to resolve tho.
    – MarkK
    Jan 9, 2017 at 15:29

You can think of the mapping between a user and a thing to follow as a unique resource in of itself, which can have two different states, either true or false depending on whether the user is following the thing in question.

So a way of doing this would be for the client to PUT a new state of that resource on the server, since the client should already know the location of the resource. Your URL schema could be something like


or something similar that conveys that this is a resource representing the state of mapping between user and thing.

A GET on this resource would tell you if User A is following Thing B

  GET /users/<user_id>/things/<thing_id>

  200 OK
  {following: true}

And the client can change that state by PUTing a new state

  PUT  /users/<user_id>/things/<thing_id>

  {following: false}

  204 No Content

As you are basically updating/creating some line in some table when a user decides to follow or unfollow an item, you shouldn't be using GET.

Rather user POST or PUT



And unless you are actually deleting something (if someone else can later choose to follow that item) then don't use a DELETE.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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