Skip to content

The LinkedIn comments API: what it lets an app do

5 min read

PostCat AI is not affiliated with LinkedIn.

The LinkedIn comments API is the socialActions/comments API. It lets an app write and read comments on shares. It offers methods to get a comment, get comments on a share or on a comment, and create, edit and delete a comment. Before an app can fetch data or access member data, it must be authorized and authenticated.

Artem Luko

Founder of PostCat AI

0+

followers on LinkedIn

He grew his own LinkedIn post by post. PostCat AI is everything he learned, in one place.

Learn how

What the LinkedIn comments API lets an app do

LinkedIn's documentation lists these methods:

  • Get a Comment
  • Batch Get a Collection of Comments
  • Get Comments on Shares
  • Get Comments on Comments
  • Create a Comment
  • Edit a Comment
  • Delete a Comment

A single comment is read with a GET request to https://api.linkedin.com/rest/socialActions/{shareUrn|ugcPostUrn|commentUrn}/comments/{commentId}. Several comments can be read in one call with .../comments/ids=List({commentId}). The comments on a share come from a GET request to https://api.linkedin.com/rest/socialActions/{shareUrn|ugcPostUrn|commentUrn}/comments.

Where to find the documentation

The reference for the API is on Microsoft Learn, which is where LinkedIn publishes its developer docs. Start with Microsoft Learn: Comments API. The LinkedIn Help Center covers only what members do on the site and the app, not the API.

Permissions you need

Each permission decides what an app may do. The table below keeps the wording of LinkedIn's documentation.

PermissionWhat it lets an app doAccess
w_member_socialLets an app post, comment and like posts on behalf of an authenticated memberListed under Share on LinkedIn in the open permissions table
w_member_social_feedLets an app create, modify and delete comments and reactions on posts on the member's behalfMember permission (3-legged) for the Community Management API
r_member_social_feedLets an app retrieve posts, reactions and likes on behalf of an authenticated memberRestricted, granted to select developers only
w_organization_social_feedLets an app post, comment and react on behalf of an organizationRestricted to organizations where the member has one of the company page roles

The permission tables are not the same in every API version. Check the version you plan to use before you rely on a row.

Comment fields: actor, message and replies

Every comment has an actor, which is the URN of who is commenting. The actor field is required. A urn:li:person actor makes a personal comment, with the member as publisher. A urn:li:organization or urn:li:organizationBrand actor makes an organization comment that a member wrote on the entity's behalf.

The message field is required text, and it may include links to people and organizations. Content such as an image is optional.

A reply is a nested comment. Its parentComment field holds the URN of the parent comment. That field is not available for first-level comments.

To edit a comment, the request uses the header X-RestLi-Method: PARTIAL_UPDATE and a patch that sets the message text. Delete a Comment is one of the listed methods.

Turning comments on or off

Comments on a post are switched on and off through a different API, the Social Metadata API. Set commentsState to CLOSED to disable comments, and to OPEN to enable them. Disabling comments deletes all existing comments on the thread. Reactions stay as they are. Re-enabling comments lets people write comments on the thread again.

The Social Metadata API accepts only thread URNs. It rejects any write that uses a comment URN. For creating and retrieving a comment, use the Comments API. The summary counts are commentSummary.count, which includes replies, and commentSummary.topLevelCount, which leaves replies out.

Commenting by hand on LinkedIn

If you want to test the feel of a comment before you call the API, do it by hand first. The steps follow LinkedIn Help: Comment on posts and reply to a comment.

  1. Click Comment below the post, or click the textbox that says Add a comment.
  2. Type your comment.
  3. Optionally, click the Emoji icon, the GIF icon or the Image icon.
  4. Click Comment.

To reply, click Reply below a comment, or click the text box that says Add a reply, type your reply, then click Reply. Members can also limit commenting to connections only, which stops people who are not 1st-degree connections from commenting.

To edit your own comment, click the More icon to the right of the comment, click the Edit icon and make the changes, then click Save Changes. The comment then shows (edited) above it. The steps follow LinkedIn Help: Edit a comment.

How to start

Read the reference for the API version you plan to use, because the permission rows change between versions. Begin with a single read call on a post you own. Add writes only after the reads return what you expect.

What the help pages we read do not say

The help pages we read do not state these:

  • API rate limits and quotas.
  • Fees or pricing for API access.
  • How to create an app, how to get Marketing Developer Platform or Community Management access, how long approval takes, and whether individual developers qualify.
  • Whether an app without admin rights can read comments on other members' posts.
  • The request format for Delete a Comment, pagination and count limits, and which API version is current.

PostCat AI and comments

PostCat AI is an independent product, not run or endorsed by LinkedIn. It answers comments under the posts it publishes, after approval or by itself, and it works only through LinkedIn's official API. Its prices are on the pricing page.

Sources
  • Comments API - LinkedIn (learn.microsoft.com)
  • LinkedIn Help: Comment on posts and reply to a comment
  • LinkedIn Help: Edit comments in your LinkedIn feed
  • Getting Access to LinkedIn APIs - LinkedIn (learn.microsoft.com)
  • Increasing Access - LinkedIn (learn.microsoft.com)
  • Community Management - Overview - LinkedIn (learn.microsoft.com)
  • Migration Guide for Community Management API - LinkedIn (learn.microsoft.com)
  • Integration Requirements for Community Management - LinkedIn (learn.microsoft.com)
  • Social Metadata API - LinkedIn (learn.microsoft.com)
  • Posts API - LinkedIn (learn.microsoft.com)

Frequently asked questions

Yes. The socialActions/comments API lets an app write and read comments on shares. It has methods to get, create, edit and delete comments. The reference is on Microsoft Learn.

Start with your team's next post.

Connect your team's LinkedIn profiles and start with a free trial.