Search code examples
apitrello

How to get activities from trello board


I have built a site that pulls the comments from Trello to show it on my site using this code:

    var resource = "cards/" + card.id + "/actions";
    Trello.get(resource, function(comments) {
            if(!$.isEmptyObject(comments)){
                    var commentStr="<div class='comments_c'>";
                    $.each(comments, function(c, cda){
                            //console.log(cda.data.text);
                            commentStr += "<p>"+cda.data.text+"</p>";
                            //addComments(cda.data.text);
                    });

                    commentStr += "</div>";
            }
            console.log(commentStr);

Now it works fine to pull the comments but it doesn't show the activity like "Sarah Hastings added this card to ". The api documentation doesn't talk about it and I am at a dead-end. We need it for reporting and looking for a way to get the activities (copied, moved, added) from Trello to our site. Any help is appreciated.


Solution

  • By default, the cards/[idCard]/actions endpoint returns actions filtered to commentCard,updateCard:idList. If you want to get actions of additional types from that endpoint you will want to include the filter parameter with the list of action types that you want returned. You can see the full list of options documented here: https://developers.trello.com/advanced-reference/card#get-1-cards-card-id-or-shortlink-actions by clicking Show next to Arguments for that call.

    For example actions of adding cards to a board would be of type: moveCardToBoard so you would want to add that to the filter parameter.