npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

linkedin-web-api

v1.0.4

Published

## Installation

Downloads

8

Readme

NodeJS LinkedIn WEB API

Installation

npm install linkedin-web-api

Example usage

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

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

(async () => {
  // Login
  const client = new Client();
  await client.login.userPass({ username, password, proxy });

  // search for companies
  const companiesScroller = await client.search.searchCompanies({ keywords: 'Microsoft' });
  const [{ company: microsoft }] = await companiesScroller.scrollNext();

  // Search for profiles and send an invitation
  const peopleScroller = await client.search.searchPeople({
    keywords: 'Bill Gates',
    filters: {
      pastCompany: microsoft.companyId,
    },
  });
  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!',
  });
})();

API

Repositories

Classes that expose methods for communicating with linkedin API.
Each repository describes a LinkedIn entity that we can operate on it. Example: InvitationRepository.

The methods are divided into 3 types:

  • Single entity getters - example: conversation.getConversation({ conversationId: CONVERSATION_ID }) Single entity getters return a LinkedIn Entity.

  • Multiple entities getters - for example invitation.getSentInvitations({ skip: 10, limit: 5 })
    Multiple entities getters return a Scroller.

  • Mutations - for example invitation.sendInvitation({ ... })
    Mutations return a Response entity

Scrollers

Wrapper classes that enable a convenient work with paginated responses. For example - PeopleScroller.
Most of LinkedIn requests return paginated responses, (just like in the UI), scrollers just provide a structured way to navigate between pages.

There are two types of scrollers:

  • Index scroller - Accepts 2 properties:
    skip (number) - Starting index (How many entities to skip).
    limit (number) - How many entities to fetch on each iteration.

  • Time scrollers - Accepts one property:
    createdBefore (Date) - Defines the point of time to start fetching entities.

Example:

// index scroller
let companiesScroller = client.search.searchCompanies();
let companies = await companiesScroller.scrollNext(); // returns first page with 10 results
companies = await companiesScroller.scrollNext(); // next page
companies = await companiesScroller.scrollBack(); // previous page

// overriding skip and limit
companiesScroller = client.search.searchCompanies({ skip: 100, limit: 1 });
companies = await companiesScroller.scrollNext(); // returns first page with 1 results
companies = await companiesScroller.scrollNext(); // next page
companies = await companiesScroller.scrollBack(); // previous page

// overriding createdBefore for time scroller
const twoDaysAgo = moment().subtract(2, 'days').toDate();
let messagesScroller = client.message.getMessages({
  conversationId: CONVERSATION_ID,
  createdBefore: twoDaysAgo,
});
messages = await companiesScroller.scrollNext();

What's coming next?

A lot!

This is a new project, and as such, there's a lot that need to be done.
Some new features that I expect to develop soon:

  • Media support - fetch, like, comment and create a new post.
  • Invitation improvements - be able to do some more actions like "remove connection".
  • Search improvements - support jobs searching.
  • Improve login API
  • Add services so automate common workflows

Want a specific feature? Please open a feature request :)
Also, i'll be more than happy to welcome new contributors to this project.

Legal

This code is in no way affiliated with, authorized, maintained, sponsored or endorsed by Linkedin or any of its affiliates or subsidiaries. This is an independent and unofficial API. Use at your own risk.

Note that using this API might cause your account being banned.
Always take care; we cannot be held for any account being banned.