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

unipile-node-sdk

v1.9.2

Published

Unipile node SDK

Downloads

11,599

Readme

Messaging (LinkedIn API, WhatsApp API,etc.) & Email API by Unipile

The Unipile Node.js SDK provides powerful tools to easily integrate with LinkedIn's API, Email API, and other platforms like WhatsApp, Telegram and Instagram. With this SDK, you can seamlessly manage your LinkedIn connections, send messages (including InMail), retrieve profiles, handle invitations, and manage email communications—all using LinkedIn's API and the Email API. Whether you're automating LinkedIn tasks, building scalable messaging solutions across multiple platforms, or managing emails efficiently, Unipile makes it simple and effective.

LinkedIn API and Messaging APIs

Features for Messaging APIs

🔸 Account Connection: Generate a Hosted Auth, Implement a custom authentication 🔸 Message: Start a new chat, Send message, List messages in a chat, List chats, Retrieve a chat, List attendees, Retrieve a chat, List attendees, List all attendees from a chat 🔸 Attachment: Send file attachments, Retrieve an attachment from a message 🔸 User Profile: Retrieve users profiles, Retrieve my profile 🔸 Documentation: Access to All Messaging API Features

LinkedIn Specific

🔹 Send InMail LinkedIn API 🔹 Send Invitation LinkedIn API: Profile view notification, Send invitation, List pending invitation, Delete invitation 🔹 LinkedIn Posts API: List Users/Companies posts, Retrieve a post, Create a new LinkedIn Post, Send Comments in LinkedIn Post, List Post Comments, Add reaction on a post 🔹 Profiles LinkedIn API: List of contacts/Relations, Retrieve Companies Profiles 🔹 Documentation: Access to All LinkedIn API Features

Email API

🔸 Get emails history 🔸 Delete an email 🔸 Send an email 🔸 Reply to an email 🔸 Documentation: Access to All Email API Features

Installation

Node 18 recommended

  npm install unipile-node-sdk

Quick Start

Authenticate using your Unipile account credentials

import { UnipileClient } from 'unipile-node-sdk';

const client = new UnipileClient('https://{YOUR_DSN}', '{YOUR_ACCESS_TOKEN}');

Add a messaging account : LinkedIn

const response = await client.account.connectLinkedin({
  username: 'your LinkedIn username',
  password: 'your LinkedIn password',
});

Retrieve a LinkedIn company profile

const response = await client.users.getCompanyProfile({
  account_id: linkedinAccount.id,
  identifier: 'Unipile',
});

Features for All APIs

Account Connection

You can easily connect multiple accounts

  • Generate a Hosted Auth Wizard link

    await client.account.createHostedAuthLink({
      type: 'create', // or reconnect
      expiresOn: '2024-12-22T12:00:00.701Z',
      api_url: 'your api',
      providers: '*', // * means all provider
      success_redirect_url: 'your success url',
      failure_redirect_url: 'your fail url',
      notify_url: 'your notify url',
    });
  • Implement a custom authentication to connect accounts on your application :

    • LinkedIn username/password
      await client.account.connectLinkedin({
        username: 'your LinkedIn username',
        password: 'your LinkedIn password',
      });
  • LinkedIn cookie/user-agent

    await client.account.connectLinkedinWithCookie({
      access_token: 'V2VsY29tZSB0byBVbmlwaWxlICE-gU2hhbnRheSB5b3Ugc3RheSAh',
      user_agent: 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0.1',
    });
    • Whatsapp API
      await client.account.connectWhatsapp();
    • Instagram API
      await client.account.connectInstagram({
        username: 'your Instagram username',
        password: 'your Instagram password',
      });
    • Messenger API
      await client.account.connectMessenger({
        username: 'your Messenger username',
        password: 'your Messenger password',
      });
    • Telegram API
      await client.account.connectTelegram();
    • X (Twitter) API
      await client.account.connectTwitter({
        username: 'your X username',
        password: 'your X password',
      });
  • Have 2FA / OTP / In-app validation security ? Solve the checkpoint 2FA / OTP

    await client.account.solveCodeCheckpoint({
      account_id: 't5XY4yQzR9WVrlNFyzPMhw',
      provider: 'LINKEDIN',
      code: '******',
    });
  • LinkedIn : initiate or monitor a sync process

    await client.account.resyncLinkedinAccount({
      account_id: 't5XY4yQzR9WVrlNFyzPMhw',
    });

Messages

  • Start a new chat
    await client.messaging.startNewChat({
      account_id: 't5XY4yQzR9WVrlNFyzPMhw',
      attendees_ids: ['user id OR provider id'],
      text: 'new chat with message',
    });
  • Send message
    await client.messaging.sendMessage({
      chat_id: 'vISKyHtDUmagrk6vrnlXhw',
      text: 'Hello World',
    });
  • List messages in a chat
    await client.messaging.getAllMessagesFromChat({
      chat_id: 'vISKyHtDUmagrk6vrnlXhw',
    });
  • List chats
    await client.messaging.getAllChats();
    // OR sort your chats list
    await client.messaging.getAllChats({
      account_type: 'LINKEDIN',
      account_id: 't5XY4yQzR9WVrlNFyzPMhw',
      limit: 50,
      after: '2024-07-22T12:00:00.000Z',
    });
  • Retrieve a chat
    await client.messaging.getChat('vISKyHtDUmagrk6vrnlXhw');
  • List attendees
    await client.messaging.getAllAttendees({
      account_id: 't5XY4yQzR9WVrlNFyzPMhw',
    });
  • List all attendees from a chat
    await client.messaging.getAllAttendeesFromChat('vISKyHtDUmagrk6vrnlXhw');

Attachments

  • Send files attachments

    const path = './src/unipile.png';
    const fileBuffer = await fs.readFile(path);
    
    await client.messaging.sendMessage({
      chat_id: 'vISKyHtDUmagrk6vrnlXhw',
      text: 'Hello World',
      attachments: [['unipile.png', fileBuffer]],
    });
  • Retrieve an attachment from a message

    await client.messaging.getMessageAttachment({
      attachment_id: '5882031366722404334',
      message_id: '3aRdnf34UiympaebB4-NRA',
    });

Users

  • Retrieve users profiles
    await client.users.getProfile({
      account_id: 't5XY4yQzR9WVrlNFyzPMhw',
      identifier: 'user id OR user provider id',
    });
  • Retrieve my profile
    await client.users.getOwnProfile('t5XY4yQzR9WVrlNFyzPMhw');

Extra parameters

If you want to pass some extra parameters for a request beyond what the SDK input defines, all methods allow an extra_params options.

await client.messaging.getMessageAttachment(
  {
    attachment_id: '5882031366722404334',
    message_id: '3aRdnf34UiympaebB4-NRA',
  },
  {
    extra_params: { my_param_name: 'my param value' },
  },
);

Depending on the underlying HTTP request mode used, extra_params will be added to the request query string or json or formData body.

This may be useful if you know about and want to use a parameter that is either omitted or not yet defined in the sdk.

LinkedIn Specific

InMail LinkedIn API

Send InMail LinkedIn API (message to people outside users’ network)

await client.messaging.startNewChat({
  account_id: 't5XY4yQzR9WVrlNFyzPMhw',
  attendees_ids: ['user provider id'],
  text: 'send a inmail',
  options: {
    linkedin: {
      inmail: true,
    },
  },
});

Invitations LinkedIn API

  • Notify LinkedIn Profile View
    await client.users.getProfile({
      account_id: 't5XY4yQzR9WVrlNFyzPMhw',
      identifier: 'user provider id',
      linkedin_sections: '*',
      notify: true,
    });
  • Send LinkedIn Invitation
    await client.users.sendInvitation({
      account_id: 't5XY4yQzR9WVrlNFyzPMhw',
      provider_id: 'user provider id',
      message: 'Send invitation',
    });
  • List pending LinkedIn invitations
    await client.users.getAllInvitationsSent({
      account_id: 't5XY4yQzR9WVrlNFyzPMhw',
    });
  • Delete LinkedIn Invitation
    await client.users.cancelInvitationSent({
      account_id: 't5XY4yQzR9WVrlNFyzPMhw',
      invitation_id: '7221821214065876992',
    });

Posts LinkedIn API

  • List Users' and Companies' LinkedIn Posts
    await client.users.getAllPosts({
      account_id: 't5XY4yQzR9WVrlNFyzPMhw',
      identifier: 'user/company provider id',
    });
  • Retrieve a LinkedIn post
    await client.users.getPost({
      account_id: 't5XY4yQzR9WVrlNFyzPMhw',
      post_id: '7222176104768270337',
    });
  • Create a LinkedIn Post
    await client.users.createPost({
      account_id: 't5XY4yQzR9WVrlNFyzPMhw',
      text: 'post content',
    });
  • Send Comments on LinkedIn Post
    await client.users.sendPostComment({
      account_id: 't5XY4yQzR9WVrlNFyzPMhw',
      post_id: '7222176104768270337',
      text: 'comment',
    });
  • List LinkedIn Post Comments
    await client.users.getAllPostComments({
      account_id: 't5XY4yQzR9WVrlNFyzPMhw',
      post_id: '7222176104768270337',
    });
  • Add reaction to a LinkedIn post
    await client.users.sendPostReaction({
      account_id: 't5XY4yQzR9WVrlNFyzPMhw',
      post_id: '7222176104768270337',
      reaction_type: 'funny',
    });

Profiles LinkedIn API

  • List of contacts/Relations
    await client.users.getAllRelations({
      account_id: 't5XY4yQzR9WVrlNFyzPMhw',
    });
  • Retrieve User Profiles
    await client.users.getProfile({
      account_id: 't5XY4yQzR9WVrlNFyzPMhw',
      identifier: 'user provider id',
      linkedin_api: 'sales_navigator',
      linkedin_sections: ['experience', 'about'],
      notify: true,
    });
  • Retrieve Companies Profiles
    await client.users.getCompanyProfile({
      account_id: 't5XY4yQzR9WVrlNFyzPMhw',
      identifier: 'Unipile',
    });

Email API

Get emails history

  • List all emails

    await client.email.getAll({ account_id: 't5XY4yQzR9WVrlNFyzPMhw' });
  • Retrieve a specific email

await client.email.getOne('TnOWcaycS52dwnhgADlb2w');
  • Retrieve a specific email by external provider id
await client.email.getOne.byProvider('some email provider id', 'some account id');
  • List all folders from an email Account
await client.email.getAllFolders({ account_id: 't5XY4yQzR9WVrlNFyzPMhw' });
  • Retrieve a specific folder
await client.email.getOneFolder('aG0z55cmQOO1y2180eAeuQ');
  • Retrieve a specific folder by external provider id
await client.email.getOneFolder.byProviderId('some folder provider id', 'some account id');
  • Retrieve a specific attachment
await client.email.getEmailAttachment({
  email_id: 'TnOWcaycS52dwnhgADlb2w',
  attachment_id: 'AQMkADAwATNiZmYAZC1jM2ZmAC00MzA1LTAwAi0wMAoARgAAA6zgXpjd',
});
  • Retrieve a specific attachment using an email external provider id
await client.email.getEmailAttachment.byProviderId({
  account_id: 't5XY4yQzR9WVrlNFyzPMhw',
  email_id: 'some email provider id',
  attachment_id: 'AQMkADAwATNiZmYAZC1jM2ZmAC00MzA1LTAwAi0wMAoARgAAA6zgXpjd',
});

Delete an email

  • Delete a specific email
await client.email.delete('TnOWcaycS52dwnhgADlb2w');
  • Delete a specific email by external provider id
await client.email.delete.byProviderId('some email provider id', 'some account id');

Send an email

await client.email.send({
  account_id: 't5XY4yQzR9WVrlNFyzPMhw',
  to: [{ identifier: '[email protected]' }],
  subject: 'email subject',
  body: 'email body content',
});

Reply to an email

await client.email.send({
  account_id,
  body: 'send a mail',
  subject: 're: parent email subject',
  to: [{ identifier: '[email protected]' }],
  reply_to: 'some email provider id',
});