Network Update Social Actions

Some shares may have social actions such as likes or comments attached to them. The socialActions API allows you to create and read likes and comments on shares.

Permissions

Permission Description
w_organization_social Post, comment and like posts on behalf of an organization. Restricted to organizations in which the authenticated member has one of the following company page roles.
  • ADMINISTRATOR
  • DIRECT_SPONSORED_CONTENT_POSTER
  • RECRUITING_POSTER/li>
r_organization_social Retrieve organizations' posts, comments, and likes. Restricted to organizations in which the authenticated member has one of the following company page roles.
  • ADMINISTRATOR
  • DIRECT_SPONSORED_CONTENT_POSTER
w_member_social Post, comment and like posts on behalf of an authenticated member.
r_member_social Restricted Retrieve posts, comments, and likes on behalf of an authenticated member. This permission is granted to select developers only.

If you are using legacy permissions, please refer to this page for requesting legacy permissions.

See Organization Access Control for more information on company page roles.

Note

You may never store profile information, other than person URNs retrieved from the shares API.

Social Action Types

The socialActions API allows access to both personal and organization social actions. The type of URN specified in the owner field of a social action indicates the type:

URN Type Social Action Type Description
urn:li:person Personal Social action was created by a member. The member is displayed as the publisher.
urn:li:organization urn:li:organizationBrand Organization Social action was created by a member on behalf of an organizational entity. The organization or brand is displayed as the publisher.

Retrieve Social Actions

Retrieve a Summary of Social Actions

GET https://api.linkedin.com/v2/socialActions/{shareUrn|ugcPostUrn|commentUrn}

Sample Response

{
    "commentsSummary": {
        "totalFirstLevelComments": 4,
        "aggregatedTotalComments": 9
    },
    "$URN": "urn:li:activity:6296748651834277888",
    "likesSummary": {
        "likedByCurrentUser": false,
        "totalLikes": 226
    }
}

Note

Shares without likes or comments do not show likesSummary or commentsSummary respectively. A share without any social action activity returns an empty JSON response.

Batch_GET Summary of Social Actions

Sample Request

GET https://api.linkedin.com/v2/socialActions?ids={shareUrn1|ugcPostUrn1|commentUrn1}&ids={shareUrn2|ugcPostUrn2|commentUrn2}

Sample Response

{
    "statuses": {},
    "results": {
        "urn:li:share:6297772917862207488": {
            "commentsSummary": {
                "totalFirstLevelComments": 9,
                "aggregatedTotalComments": 11
            },
            "$URN": "urn:li:activity:6297772917849616384",
            "likesSummary": {
                "likedByCurrentUser": false,
                "totalLikes": 287
            },
            "target": "urn:li:activity:6297772917849616384"
        },
        "urn:li:share:6296748651846864896": {
            "commentsSummary": {
                "totalFirstLevelComments": 4,
                "aggregatedTotalComments": 9
            },
            "$URN": "urn:li:activity:6296748651834277888",
            "likesSummary": {
                "likedByCurrentUser": false,
                "totalLikes": 226
            },
            "target": "urn:li:activity:6296748651834277888"
        }
    },
    "errors": {}
}

Retrieve Likes on Shares

Sample Request

GET https://api.linkedin.com/v2/socialActions/{shareUrn|ugcPostUrn|commentUrn}/likes

Sample Response

{
    "elements": [
        {
            "actor": "urn:li:person:ub1n1QYzp_",
            "created": {
                "actor": "urn:li:person:ub1n1QYzp_",
                "time": 1501914549125
            },
            "lastModified": {
                "actor": "urn:li:person:ub1n1QYzp_",
                "time": 1501914549125
            },
            "$URN": "urn:li:like:(urn:li:person:ub1n1QYzp_,urn:li:activity:6297772917849616384)",
            "object": "urn:li:activity:6297772917849616384"
        }
    ],
    "paging": {
        "total": 287,
        "count": 10,
        "start": 0,
        "links": [
            {
                "rel": "next",
                "href": "/v2/socialActions/urn:li:activity:6297772917849616384/likes?count=10&start=10",
                "type": "application/json"
            }
        ]
    }
}

Note

To prevent timeouts, set the page count to less than 600 when you fetch likes.

Retrieve Comments on Shares

Sample Request

GET https://api.linkedin.com/v2/socialActions/{shareUrn|ugcPostUrn|commentUrn}/comments

Sample Response

{
    "elements": [
        {
            "actor": "urn:li:organization:2414183",
            "commentsSummary": {
                "totalFirstLevelComments": 2,
                "aggregatedTotalComments": 2,
                "selectedComments": [
                    "urn:li:comment:(urn:li:activity:6273189577469632512,6412871083845840896)",
                    "urn:li:comment:(urn:li:activity:6273189577469632512,6412870985699127296)"
                ]
            },
            "created": {
                "actor": "urn:li:organization:2414183",
                "time": 1528947543455
            },
            "lastModified": {
                "actor": "urn:li:organization:2414183",
                "time": 1528947543455
            },
            "id": "6412870797412618240",
            "message": {
                "attributes": [],
                "text": "I'm a  comment."
            },
            "$URN": "urn:li:comment:(urn:li:activity:6273189577469632512,6412870797412618240)",
            "object": "urn:li:activity:6273189577469632512"
        },
    ],
    "paging": {
        "total": 15,
        "count": 10,
        "start": 0,
        "links": [
            {
                "rel": "next",
                "href": "/v2/socialActions/urn:li:activity:6273189577469632512/comments?count=10&start=10",
                "type": "application/json"
            }
        ]
    }
}

If a top level comment has nested comments, the commentsSummary.selectedComments array provides a preview of the two most recent nested comments.

Note

We recommend:

  • Getting a summary of social actions before attempting to fetch comments or likes for a share directly. If there are no comments or likes for a share, a request to fetch comments or shares returns 404 - Not Found.
  • Setting the page count to less than 200 when you fetch shares to prevent timeouts.
  • Retrieve Comments on Comments

    To resolve nested comments for a given parent comment, provide a parent commentUrn as the target in the request URL. A commentUrn is a composite URN constructed using a comment ID and activityUrn.

    Sample Request

    GET https://api.linkedin.com/v2/socialActions/urn:li:comment:(activity:6273189577469632512,6275822846992351232)/comments
    

    Sample Response

    {
        "elements": [
            {
                "actor": "urn:li:person:4VK4q4L5af",
                "created": {
                    "actor": "urn:li:person:4VK4q4L5af",
                    "time": 1496272844878
                },
                "parentComment": "urn:li:comment:(urn:li:activity:6273189577469632512,6275822846992351232)",
                "lastModified": {
                    "actor": "urn:li:person:4VK4q4L5af",
                    "time": 1496272844878
                },
                "id": "6275823178275262464",
                "message": {
                    "attributes": [],
                    "text": "I'm a nested comment 789."
                },
                "$URN": "urn:li:comment:(urn:li:activity:6273189577469632512,6275823178275262464)",
                "object": "urn:li:activity:6273189577469632512"
            },
        ],
        "paging": {
            "total": 2,
            "count": 10,
            "start": 0,
            "links": []
        }
    }
    

    Create and Delete Social Actions

    Create Comment

    Sample Request

    POST https://api.linkedin.com/v2/socialActions/{shareUrn|ugcPostUrn|commentUrn}/comments
    

    Request Body Fields

    Field Description Format Required
    actor Entity which authored the comment organization URN or person URN Yes
    message Text of the comment. May contain attributes such as links to people and organizations. Text Yes
    parentComment For nested comments, this is the urn of the parent comment. This is not available for first-level comments. Composite URN No

    Use the object field in the request body to specify the URN of the share to which the comment belongs. This share should be used in the request URL, and represented as an URN.

    Sample Request Body

    {
        "actor": "urn:li:person:324_kGGaLE",
        "message": {
            "attributes": [],
            "text": "This is a comment"
        }
    }
    

    Use the ID returned in the response header to take further action on the newly created comment. The following response body also contains a comment URN which can be used as parent comment for creating nested comments.

    Sample Response Header

    X-LinkedIn-Id: 6276098912847822848
    

    Sample Response Body

    {
        "$URN": "urn:li:comment:(urn:li:activity:6273189577469632512,6276098912847822848)",
        "actor": "urn:li:person:324_kGGaLE",
        "agent": "urn:li:person:324_kGGaLE",
        "created": {
            "actor": "urn:li:person:324_kGGaLE",
            "time": 1496338584923
        },
        "id": "6276098912847822848",
        "lastModified": {
            "actor": "urn:li:person:324_kGGaLE",
            "time": 1496338584923
        },
        "likesSummary": {},
        "message": {
            "attributes": [],
            "text": "This is a comment."
        },
        "object": "urn:li:activity:6273189577469632512"
    }
    

    Delete Comment from Share

    Sample Request

    DELETE https://api.linkedin.com/v2/socialActions/{shareUrn|ugcPostUrn}/comments/{comment ID}
    

    Query Parameters

    Field Description Format Required
    actor Entity deleting the comment organization URN Only when deleting comment as an organization

    Create a Comment on a Comment

    To create a nested comment, add a parentComment field to your request body. The value is a composite URN, which is comprised of the activityUrn and parent comment ID.

    Sample Request Body

    {
        "actor": "urn:li:organization:2414183",
        "message": {
            "text": "Dunder Mifflin's Dundie Award goes to Dwight Schrute!"
        },
        "object": "urn:li:share:6305471423242596352",
        "parentComment": "urn:li:comment:(urn:li:activity:6305471423192264704,6308007194273021952)"
    }
    

    Comment Mentioning

    Comment text may contain attributes, which are links to other LinkedIn entities such as people or organizations. Mentioning requires knowledge of the URN for the referenced entity. You must also specify the part of the comment text that should be rendered as a link to the entity.

    Schema

    Field Description Format Required
    length The length of the annotation link integer yes
    start The starting character index beginning the annotation link integer yes
    value An object that includes the URN of the organization or member you want to mention in the comment. URN no

    Sample Request Body

    {
        "actor": "urn:li:organization:2414183",
        "message": {
            "attributes": [
                {
                    "length": 17,
                    "start": 0,
                    "value": {
                        "com.linkedin.common.CompanyAttributedEntity": {
                            "company": "urn:li:organization:2414183"
                        }
                    }
                },
                {
                    "length": 14,
                    "start": 38,
                    "value": {
                        "com.linkedin.common.MemberAttributedEntity": {
                            "member": "urn:li:person:uOeeiwWoxO"
                        }
                    }
                }
            ],
            "text": "Dunder Mifflin's Dundie Award goes to Dwight Schrute!"
        },
        "object": "urn:li:share:6305471423242596352"
    }
    

    Create a Like on a Share

    Sample Request

    POST https://api.linkedin.com/v2/socialActions/{shareUrn|ugcPostUrn|commentUrn}/likes
    

    Use the object field in the request body to specify the URN of the entity to which the like belongs. This object should be a sub-entity of the top-level share indicated in the request URL, and should be represented as a URN of format urn:li:share:{id}.

    The actor field in the request body is used to specify the entity performing the action. It should be represented by a urn:li:person:{id} or urn:li:organization:{id} URN.

    {
        "actor": "urn:li:person:0XV6h162Ub",
        "object": "urn:li:share:6280442346811207680"
    }
    

    Sample Response

    {
        "$URN": "urn:li:like:(urn:li:person:0XV6h162Ub,urn:li:activity:6280442346165280768)",
        "actor": "urn:li:person:0XV6h162Ub",
        "agent": "urn:li:person:0XV6h162Ub",
        "created": {
            "actor": "urn:li:person:0XV6h162Ub",
            "time": 1497380688598
        },
        "lastModified": {
            "actor": "urn:li:person:0XV6h162Ub",
            "time": 1497380688598
        },
        "object": "urn:li:activity:6280442346165280768"
    }
    

    Create a Like on a Comment

    Likes can be created on comments by using the comment URN as the target key in the request URL. Similar to liking a share, the object value should be set to the top level share URN.

    Sample Request

    POST https://api.linkedin.com/v2/socialActions/{commentUrn}/likes
    
    {
        "actor": "urn:li:person:0XV6h162Ub",
        "object": "urn:li:share:6280442346811207680"
    }
    

    Delete a Like

    Sample Request

    DELETE https://api.linkedin.com/v2/socialActions/{shareUrn|ugcPostUrn|commentUrn}/likes/{actor URN}?actor={actor URN}
    

    Query Parameters

    Field Description Format Required
    actor Entity deleting the like. Must supply the entity that created the like. organization URN or person URN Yes