linkedin#
OCaml client for the LinkedIn Voyager API.
Typed OCaml bindings for LinkedIn's internal Voyager API, providing access to
profiles and feed posts. Authentication uses browser session cookies (li_at
and JSESSIONID) rather than OAuth. Includes a command-line tool that can
automatically extract session cookies from Chrome's encrypted cookie store on
macOS.
The library uses requests for HTTP, jsont for JSON encoding/decoding,
cookie for cookie management, 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 — default is Markdown with YAML frontmatter
linkedin get <url> --format md # (default)
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-- HTTP client authenticated withli_atandJSESSIONIDcookies. Providesme,profile,posts, andpostendpoints.Profile-- LinkedIn profile type with public ID, name, headline, summary, location, and entity URN. Includes JSON codecs for bothprofileViewand/meresponse formats.Post-- Feed post type with URN, text, author name, timestamps, and engagement counts. Includes codecs for feed responses and normalized Voyager responses.Chrome_cookies-- Extracts and decrypts LinkedIn session cookies from Chrome's SQLite cookie store on macOS using Keychain, PBKDF2, and AES-CBC.Linkedin_url-- Parses LinkedIn profile, post, and Pulse article URLs into structured types. Recognises/in/{id},/feed/update/urn:...,/posts/{slug}, and/pulse/{slug}formats.Pulse-- LinkedIn Pulse article type with title, author, subtitle, publication date, and body rendered as Markdown.fetchretrieves a public article by URL or slug. Useslambdasoupto parse the article HTML. Low-level; most users want {!Item} instead.Item-- Unified view of any LinkedIn item (Pulse article or short feed post).getfetches by URL and dispatches internally to Pulse or Post.feedwalks a member's share feed and returns article+post summaries interleaved in reverse-chronological order. Includes JSON codecs for feeding a website or ingestion pipeline.