How to manage Likes?

I’m looking for some guidance as to how to manage Likes (formerly Hearts).

According to this Stackoverflow answer, they are their own object. But I can’t find any information about that object in the Asana documentation. So I have some questions:

  1. Is there an object model available somewhere for Likes? The API Explorer still refers to them as Hearts. When I expand Hearts for a Task, it looks like it’s an object with properties of Id and User. Is that correct?

  2. I’m wondering why they are a separate object and not just a collection of users like Collaborators, Members, etc.?

  3. When accessing this info via my code, should I still use Hearts per the API Explorer or should I use Likes? In my own testing, it appears that both work. I’m assuming we should use Likes but wanted to confirm that there’s not still some reason to use Hearts.

  4. How would one go about adding a Like to a Task via the API?

Thanks for any guidance!

One other puzzle regarding my question #1 about the object model for Likes: the example in the Stackoverflow answer shows it containing properties of “target” and “created_at”, but when I expand Likes, both in the API Explorer and in my own code, I don’t see these properties - I only see “id” and “user”. What’s up with the “target” and “created_at” properties shown in the SO answer?

Hi @Phil_Seeman,

Thanks for reaching out and sorry if the hearts/likes documentation is confusing. We hope to clarify the documentaiton in the future. I’ve addressed your questions below:

  1. There is no standalone documentation for Likes. You can find references to Likes, however, in the Tasks and Stories docs.

  2. Unfortunately, I don’t have any insight into the design decisions that went into making Hearts (which became Likes). Our docs do have an error. As you figured out, the response is not an array of people who’ve liked the task (as the docs indicate). Likes are actually their own object.

  3. You should use Likes as I imagine that we will eventually deprecate Hearts.

  4. The likes array is read-only, however, the liked boolean is writeable as part of a PUT to /tasks/{id}.

There must have been a change in the API. I will investiage further and ask the API team. When I GET /tasks/<task-id>?opt_expand=likes the response is:

"liked": true,
    "likes": [
      {
        "id": 987654321, // like-id
        "user": {
          "id": 123456789, // user-id
          "name": "Jeff Schneider"
        }
      }
    ],

I don’t t get “target” or “created_at” objects either.

1 Like

Hi Jeff,

Thank very much for the reply and the info.

The only comment I’d make here is that the solution I’m creating has a UI and so it would actually be appropriate for a user to be able to make the “like” action there - so the option to create a Like would be useful. But it’s not the end of the world that it’s not available in the API. :smiley:

@Phil_Seeman after doing a bit of digging, you actually can modify likes via the API. While the likes array is read-only, the liked boolean is writeable as part of a PUT to /tasks/{id}. (I updated my response to question #4 above)

Thank you for your feedback – I agree that developers often want to create a new UI for Asana within another tool. We strive for product parity with the API.

Could you provide a bit more detail about what you are building? Knowing how devs actually consume the API helps to shape our API roadmap and docs.

1 Like

@Jeff_Schneider Wow that’s fantastic! Thanks so much for discovering that and letting us know - really appreciate it.

The project is an Asana client with two main features: it’s outlined-based so makes it easy to visualize and work with sub-tasks; and is a thick client so it syncs data to the machine and thus allows for offline use. We actually just put up a very basic page to garner potential interest - see GetTreesana.com.

1 Like