Search code examples
javascriptlinkedin-api

How to fetch user posts from Linkedin


I am making an app where a user can sign in via LinkedIn (oAuth) and after that he can see his recent posts (activity feed). I am struggling to find that API end point with which I can retrieve the user's posts. Is there any such end point available


Solution

  • I think these two might be of most help for you:

    Find Posts by Account

    GET https://api.linkedin.com/rest/posts?dscAdAccount={encode dscAdAccount}&q=dscAdAccount&dscAdTypes=List(STANDARD,VIDEO)
    

    Find Posts by Authors

    GET https://api.linkedin.com/rest/posts?author={encoded person urn or organization urn like urn%3Ali%3Aperson%3A5abc_dEfgH or urn%3Ali%3Aorganization%3A2414183}&q=author&count=10&sortBy=LAST_MODIFIED
    

    Read this to learn about URNs:

    URNs are used to represent foreign associations to an entity (persons, organizations, and so on) in an API. A URN is a string-based identifier with the format:

    urn:{namespace}:{entityType}:{id}

    For example:

    urn:li:person:123
    urn:li:organization:456
    urn:li:sponsoredAccount:789
    

    URNs encode more information, including the entity type. Using the entity type, it's possible to dereference a URN and access the underlying data of the entity using a process called decoration.

    URN values returned from LinkedIn's APIs are a maximum of 255 characters in length. IDs

    Simple integer IDs are returned to represent an object's primary key. Your application should support transforming URNs into IDs and vice versa. IDs versus URNs

    IDs are self-referencing identifiers similar to a primary key. URNs are Globally Unique Identifiers (GUID) used to represent an entity's foreign associations.

    In the example below, we fetch details about a share and use a projection to limit the results to the id and owner fields. The shares API returns an id that is the primary key and an owner that is a foreign reference to the person who created the share in the form of a URN.