LinkedIn Voyager API client
README.md

linkedin #

LinkedIn Voyager API client.

linkedin reads LinkedIn profiles, feed posts and Pulse articles, for example to archive a member's own writing or republish it on a personal site. It binds the internal Voyager API that LinkedIn's web client calls, with typed values for each kind of item, and authenticates with the browser session cookies li_at and JSESSIONID rather than OAuth, and its command-line tool reads those cookies out of Chrome's encrypted cookie store on macOS.

Voyager is undocumented and LinkedIn changes it without notice, so the response parsers walk the JSON by path rather than through fixed codecs, and a change on LinkedIn's side can break them.

The library uses requests for HTTP, nox-json for JSON, nox-cookie for cookies, lambdasoup for article HTML, and Eio for concurrency.

Installation #

Install with opam:

$ opam install linkedin

If opam cannot find the package, it may not yet be released in the public opam-repository. Add the overlay repository, then install it:

$ opam repo add samoht https://tangled.org/gazagnaire.org/opam-overlay.git
$ opam update
$ opam install linkedin

Usage #

Library #

let show_me ~li_at ~jsessionid =
  Eio_main.run @@ fun env ->
  Eio.Switch.run @@ fun sw ->
  let api = Linkedin.Api.v ~sw env ~li_at ~jsessionid in
  match Linkedin.Api.me api with
  | Ok profile -> Fmt.pr "%a@." Linkedin.Profile.pp profile
  | Error e -> Fmt.epr "%a@." Linkedin.Api.pp_error e

Command-line #

# One-time: authenticate by reading your Chrome session
linkedin login
linkedin logout            # remove saved cookies

# Show your own profile
linkedin me

# Show another user's profile
linkedin profile johndoe
linkedin profile https://www.linkedin.com/in/johndoe

# Fetch any LinkedIn item (Pulse article or feed post)
linkedin get https://www.linkedin.com/pulse/my-article-johndoe-abcde/
linkedin get https://www.linkedin.com/feed/update/urn:li:activity:7123456789

# Choose the output format; the default is Markdown with YAML front matter
linkedin get <url> --format md       # (default) via Item.to_markdown
linkedin get <url> --format html     # raw article body HTML
linkedin get <url> --format json     # structured record via Item.json
linkedin get <url> --json            # alias for --format json

# Walk a person's recent feed (articles + posts, reverse-chronological)
linkedin feed johndoe
linkedin feed -n 500 johndoe
linkedin feed johndoe --json

API #

  • Api is the HTTP client authenticated with the li_at and JSESSIONID cookies, with the me, profile, posts and post endpoints.
  • Profile is a member profile: public identifier, name, headline, summary, location and entity URN, read from both the profileView and the /me responses.
  • Post is a feed post: URN, text, author name, timestamps and engagement counts.
  • Chrome_cookies extracts and decrypts the LinkedIn session cookies from Chrome's SQLite cookie store on macOS, with the key from the Keychain, PBKDF2 and AES-CBC.
  • Url parses profile, post and Pulse article URLs: /in/{id}, /feed/update/urn:..., /posts/{slug} and /pulse/{slug}.
  • Pulse is a Pulse article with its title, author, subtitle, publication date and body rendered as Markdown; fetch retrieves a public article by URL or slug. Most callers want Item instead.
  • Html is the small typed decoder over lambdasoup that Pulse uses.
  • Item is either kind of item, a Pulse article or a feed post. get fetches one by URL, and feed walks a member's share feed and returns article and post summaries, newest first, with JSON codecs for a website or an ingestion pipeline.

License #

ISC