Back to News for Developers

New APIs for Comment Replies

Last week, we launched comment replies on Facebook pages and profiles with more than 10,000 followers. This allows businesses and celebrities to engage with their fans more directly. Today, we’re updating the API so developers can build tools that make it easier for brands to monitor and respond to comment replies.

API Updates

Our API now supports different "views" of the comments on posts through our updated comments API and FQL comment table.

Top Level Comments

The first view of the comments on a post is called "top level". The comments that are on the post (and are not replies to individual comments) are called "top level comments." Top level comments may be ranked, depending on the post and the number of top level comments on that post so far.

The top level view of comments corresponds to what a user would see on Facebook. To get the top level view of comments in Graph API:

GET {object_id}/comments?filter=toplevel

In FQL, you can issue the request:

    SELECT id, fromid, time, text, likes 
    FROM comment 
    WHERE object_id={object_id} AND parent_id='0'
  

Replies

Comments on comments are called "replies." You get replies by querying for the comments on a comment id.

Graph API:

GET {comment_id}/comments

FQL:

    SELECT id, fromid, time, text, likes 
    FROM comment 
    WHERE parent_id={comment_id}

Comment Stream

Another view of the comments on a post is the "stream". The comments "stream" gives all comments (top level and replies to comments) together. The "stream" view provides comments in chronological order, so it's easy for you to just get what's new.

Graph API:

GET {object_id}/comments?filter=stream

FQL:

    SELECT id, fromid, time, text, likes 
    FROM comment 
    WHERE object_id={object_id} 
    ORDER BY time

Getting Started with the APIs

To get started today with the new APIs, opt into the "July 2013 Breaking Changes" migration for your app by visiting the Advanced tab of your app dashboard.

If you're currently using our existing comments APIs, here are a few changes to keep in mind:

  • 'comments' field from 'stream' FQL table is deprecated. Please use the'comment_info' column to fetch the 'can_comment' and 'comment_count' fields.

  • We are removing the fields on the FQL 'comment' table that were used exclusively for legacy Comments Plugins -- 'xid', 'reply_xid', 'username' and 'comments'.

  • We are removing the undocumented 'count' field on the 'comments' connection in the Graph API. Please request '{id}/comments?summary=true' explicitly if you would like the summary field which contains the count (now called 'total_count')

Please read the documentation for details on how to use these new features and the Roadmap for details on the API changes.

We're excited to continue working with you, our community of developers, to improve the quality of the conversations happening on Facebook and can't wait to see what you build.