NodeJS Unofficial LinkedIn API

1.1.2 · active · verified Tue Apr 21

This `linkedin-private-api` package offers an unofficial, TypeScript-written wrapper for interacting with the LinkedIn platform programmatically. It operates by simulating browser requests, allowing automation of tasks without requiring official OAuth tokens; instead, it authenticates using direct user credentials (username and password). The current stable version is 1.1.2, with recent minor updates (v1.1.1, for example, introduced job searching and invitation notes). Its release cadence appears infrequent, suggesting a more conservative development or maintenance-oriented approach. A key differentiator is its ability to bypass official API restrictions, enabling direct automation of tasks such as searching profiles and jobs, sending connection invitations, and managing messages. This functionality is well-suited for specialized automation not covered by the public LinkedIn API, though users must be aware of the inherent risks associated with using unofficial access methods, including potential account action by LinkedIn.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates logging in, searching for jobs and people, sending connection invitations, and exchanging messages.

import { Client } from 'linkedin-private-api';

const username = process.env.USERNAME as string;
const password = process.env.PASSWORD as string;

(async () => {
  // Login
  const client = new Client();
  await client.login.userPass({ username, password });
  
  // Search for React development jobs in Israel
  const jobsScroller = await client.search.searchJobs({
    keywords: 'React',
    filters: { location: 'Israel' },
    limit: 20,
    skip: 5,
  });

  const [someReactJobHit] = await jobsScroller.scrollNext();
  const jobCompanyName = someReactJobHit.hitInfo.jobPosting.companyDetails.company.name;

  // Fetch the job's company
  const companiesScroller = await client.search.searchCompanies({ keywords: jobCompanyName });
  const [{ company: jobCompany }] = await companiesScroller.scrollNext();

  // Search for profiles and send an invitation
  const peopleScroller = await client.search.searchPeople({
    keywords: 'Bill Gates'
  });
  const [{ profile: billGates }] = await peopleScroller.scrollNext();
  
  await client.invitation.sendInvitation({
    profileId: billGates.profileId,
    trackingId: billGates.trackingId,
  });
  
  // Search in my connections
  const ownConnectionsScroller = await client.search.searchOwnConnections({ keywords: 'Bill Gates', limit: 1 });
  const connections = await ownConnectionsScroller.scrollNext();

  // Get conversation
  const [billConversation] = await client.conversation.getConversations({
    recipients: billGates.profileId
  }).scrollNext();
 
  const conversationMessages = await client.message.getMessages({
    conversationId: billConversation.conversationId
  }).scrollNext();
 
  // Send a message
  const sentMessage = await client.message.sendMessage({
    profileId: billGates.profileId,
    text: 'Hey Bill!',
  });
})();

view raw JSON →