How to get Likes Count when searching Facebook Graph API with search=xxx

Couldn’t find this in the documentation but multiple calls to the API are not necessary. You can use summary when querying a feed or multiple posts. Specify this in the fields parameter.

https://graph.facebook.com/PAGE_ID/feed?fields=comments.limit(1).summary(true),likes.limit(1).summary(true)

This will return a response like this.

{
  "data": [
    {
      ....
      "summary": {
        "total_count": 56
      }
      ...
    }, 
    {
      ....
      "summary": {
        "total_count": 88
      }
      ...
    }
  ]
}

This will be much faster than making individual requests for each object just to get the number of comments or likes.

Leave a Comment