How to retrieve engagement metrics for Facebook posts using Graph API?

I’m trying to figure out how to get likes, comments, and shares for Facebook posts using the Graph API. The old FQL method is being phased out, and I’m struggling to find a good alternative.

I know you can get likes and comments with endpoints like this:

POST_ID/likes?summary=true
POST_ID/comments?summary=true

But I can’t find a way to get the share count. I’m specifically looking for a method that uses the POST_ID, not the URL.

I’ve tried using this:

PAGE_ID/feed?fields=comments.limit(1).summary(true),likes.limit(1).summary(true)

But it doesn’t give me the share count. I’m hoping to get a response that looks something like this:

{
  "data": [{
    "likes": 3506,
    "comments": 263,
    "shares": 278
  }]
}

Any ideas on how to achieve this with the Graph API? I’d really appreciate some help!

I’ve encountered this challenge as well. Unfortunately, Facebook has indeed removed direct access to share counts via the Graph API. However, there’s a workaround you might find useful. Try using the ‘insights’ endpoint with the ‘post_reactions_by_type_total’ metric. It won’t give you exact share counts, but it provides a breakdown of reactions, including shares. The query would look something like this:

POST_ID/insights?metric=post_reactions_by_type_total

This returns various reaction types, including ‘share’. It’s not a perfect solution, but it’s currently the closest approximation available through the API. Keep in mind that you’ll need appropriate permissions to access this data.

hey there! i’ve been using graph api for a while and had the same issue. unfortunately, there’s no direct way to get share count using POST_ID anymore. facebook removed that metric from the api. :frowning: you could try using the engagement field instead, which gives total interactions. it’s not perfect but might help. good luck!

As someone who’s worked extensively with Facebook’s Graph API, I can confirm that getting share counts directly is no longer possible. It’s frustrating, I know. However, I’ve found a decent workaround that might help you.

Try using the ‘post_impressions_by_story_type’ metric in the insights endpoint. It gives you a breakdown of impressions, including those from shares. The query would look like this:

POST_ID/insights?metric=post_impressions_by_story_type

This won’t give you an exact share count, but it’ll show you how many impressions came from shares, which can be a useful proxy. Remember, you’ll need the appropriate permissions to access this data.

Also, consider using the ‘engagement’ field as mentioned earlier. While not perfect, it can give you a general idea of a post’s performance. Hope this helps with your metrics tracking!