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

peopledatalabs

v8.0.1

Published

JavaScript client with TypeScript support for the People Data Labs API

Downloads

32,227

Readme

This is a simple JavaScript client library to access the various API endpoints provided by People Data Labs.

This library bundles up PDL API requests into simple function calls, making it easy to integrate into your projects. You can use the various API endpoints to access up-to-date, real-world data from our massive Person and Company Datasets.

✨ Features

  • Supports all People Data Labs API endpoints
  • Built-in Typescript support

Table of Contents

🔧 Installation

  1. Pull the package from the npm repository:
yarn add peopledatalabs

or

npm i peopledatalabs
  1. If you get a error while running a typescript project, add "esModuleInterop": true to your tsconfig

  2. Sign up for a free PDL API key

🚀 Usage

First, create the PDLJS client:

import PDLJS from 'peopledatalabs';

const PDLJSClient = new PDLJS({ apiKey: 'YOUR API KEY' })

Then, send requests to any PDL API Endpoint:

Using Person APIs

// By Enrichment
try {
  const response = await PDLJSClient.person.enrichment({ phone: '4155688415' });

  console.log(response);
} catch (error) {
  console.log(error);
}

// By Preview Enrichment
try {
  const response = await PDLJSClient.person.enrichmentPreview({ phone: '4155688415' });

  console.log(response);
} catch (error) {
  console.log(error);
}

// By Bulk Enrichment
const bulkEnrichmentRecords = {
  requests: [
    {
      params: {
        profile: ['linkedin.com/in/seanthorne'],
      },
    },
    {
      params: {
        profile: ['linkedin.com/in/randrewn'],
      },
    },
  ],
};

try {
  const response = await PDLJSClient.person.bulk.enrichment(bulkEnrichmentRecords);

  console.log(response.items);
} catch (error) {
  console.log(error);
}

// By Search (SQL)
const sqlQuery = "SELECT * FROM person WHERE location_country='mexico' AND job_title_role='health'AND phone_numbers IS NOT NULL;"

try {
  const response = await PDLJSClient.person.search.sql({ searchQuery: sqlQuery, size: 10 });

  console.log(response.total);
} catch (error) {
  console.log(error);
}

// By Search (Elasticsearch)
const esQuery = {
  query: {
    bool: {
      must:[
        { term: { location_country: 'mexico' } },
        { term: { job_title_role: 'health' } },
        { exists: { field: 'phone_numbers' } }
      ]
    }
  }
}

try {
  const response = await PDLJSClient.person.search.elastic({ searchQuery: esQuery, size: 10 });

  console.log(response.total);
} catch (error) {
  console.log(error);
}

// By Fuzzy Enrichment
try {
  const response = await PDLJSClient.person.identify({ name: 'sean thorne' });

  console.log(response);
} catch (error) {
  console.log(error);
}

Using Company APIs

// By Enrichment
try {
  const response = await PDLJSClient.company.enrichment({ website: 'peopledatalabs.com' });

  console.log(response);
} catch (error) {
  console.log(error);
}

// By Bulk Enrichment
const bulkEnrichmentRecords = {
  requests: [
    {
      params: {
        profile: ['linkedin.com/in/peopledatalabs'],
      },
    },
    {
      params: {
        profile: ['linkedin.com/in/apple'],
      },
    },
  ],
};

try {
  const response = await PDLJSClient.company.bulk.enrichment(bulkEnrichmentRecords);

  console.log(response.items);
} catch (error) {
  console.log(error);
}

// By Search (SQL)
const sqlQuery = "SELECT * FROM company WHERE tags='big data' AND industry='financial services' AND location.country='united states';"

try {
  const response = await PDLJSClient.company.search.sql({ searchQuery: sqlQuery, size: 10 });

  console.log(response.total);
} catch (error) {
  console.log(error);
}

// By Search (Elasticsearch)
const esQuery = {
  query: {
    bool: {
      must:[
        { term: { tags: 'big data' } },
        { term: { industry: 'financial services' } },
        { term: { location_country: 'united states' } }
      ]
    }
  }
}

try {
  const response = await PDLJSClient.company.search.elastic({ searchQuery: esQuery, size: 10 });

  console.log(response.total);
} catch (error) {
  console.log(error);
}

Using Autocomplete API

// Get Autocomplete Suggestions
try {
  const response = await PDLJSClient.autocomplete({ field: 'title', text: 'full', size: 10 });

  console.log(response);
} catch (error) {
  console.log(error);
}

Using Cleaner APIs

// Clean Raw Company Strings
try {
  const response = await PDLJSClient.company.cleaner({ name: 'peOple DaTa LabS' });

  console.log(response);
} catch (error) {
  console.log(error);
}

// Clean Raw Location Strings
try {
  const response = await PDLJSClient.location.cleaner({ location: '455 Market Street, San Francisco, California 94105, US' });

  console.log(response);
} catch (error) {
  console.log(error);
}

// Clean Raw School Strings
try {
  const response = await PDLJSClient.school.cleaner({ name: 'university of oregon' });

  console.log(response);
} catch (error) {
  console.log(error);
}

Using Job Title Enrichment API

// Enrich a Job Title
try {
  const response = await PDLJSClient.jobTitle({ jobTitle: 'software engineer' });

  console.log(response);
} catch (error) {
  console.log(error);
}

Using Skill Enrichment API

// Enrich a Skill
try {
  const response = await PDLJSClient.skill({ skill: 'c++' });

  console.log(response);
} catch (error) {
  console.log(error);
}

Using IP Enrichment API

// Enrich an IP Address
try {
  const response = await PDLJSClient.ip({ ip: '72.212.42.169' });

  console.log(response);
} catch (error) {
  console.log(error);
}

Using Sandbox APIs

// By Enrichment
try {
  const response = await PDLJSClient.person.enrichment({
    email: '[email protected]',
    sandbox: true,
  });

  console.log(response);
} catch (error) {
  console.log(error);
}

// By Search (SQL)
try {
  const response = await PDLJSClient.person.search.sql({
    searchQuery: "SELECT * FROM person WHERE location_country='mexico';",
    size: 10,
    sandbox: true,
  });

  console.log(response.total);
} catch (error) {
  console.log(error);
}

// By Search (Elasticsearch)
const esQuery = {
  query: {
    bool: {
      must:[
        { term: { location_country: 'mexico' } }
      ]
    }
  }
}

try {
  const response = await PDLJSClient.person.search.elastic({ searchQuery: esQuery, size: 10, sandbox: true });

  console.log(response.total);
} catch (error) {
  console.log(error);
}

// By Fuzzy Enrichment
try {
  const response = PDLJSClient.person.identify({ email: '[email protected]', sandbox: true });

  console.log(response);
} catch (error) {
  console.log(error);
}

🌐 Endpoints

Person Endpoints | API Endpoint | PDLJS Function | |-|-| | Person Enrichment API | PDLJS.person.enrichment({ ...params }) | | Person Preview Enrichment API | PDLJS.person.enrichmentPreview({ ...params }) | | Person Bulk Person Enrichment API | PDLJS.person.bulk.enrichment({ ...records }) | | Person Search API | SQL: PDLJS.person.search.sql({ ...params }) Elasticsearch: PDLJS.person.search.elastic({ ...params })| | Person Identify API | PDLJS.person.identify({ ...params }) |

Company Endpoints | API Endpoint | PDLJS Function | |-|-| | Company Enrichment API | PDLJS.company.enrichment({ ...params }) | | Company Bulk Enrichment API | PDLJS.company.bulk.enrichment({ ...records }) | | Company Search API | SQL: PDLJS.company.search.sql({ ...params }) Elasticsearch: PDLJS.company.search.elastic({ ...params })|

Supporting Endpoints | API Endpoint | PDLJS Function | |-|-| | Autocomplete API | PDLJS.autocomplete({ ...params }) | | Company Cleaner API | PDLJS.company.cleaner({ ...params }) | | Location Cleaner API | PDLJS.location.cleaner({ ...params }) | | School Cleaner API | PDLJS.school.cleaner({ ...params }) | | Job Title Enrichment API | PDLJS.jobTitle({ ...params }) | | Skill Enrichment API | PDLJS.skill({ ...params }) | | IP Enrichment API | PDLJS.ip({ ...params }) |

Sandbox Endpoints | API Endpoint | PDLJS Function | |-|-| | Person Enrichment Sandbox API | PDLJS.person.enrichment({ ...params, sandbox: true }) | | Person Search Sandbox API | SQL: PDLJS.person.search.sql({ ...params, sandbox: true }) Elasticsearch: PDLJS.person.search.elastic({ ...params, sandbox: true })| | Person Identify Sandbox API | PDLJS.person.identify({ ...params, sandbox: true }) |

📘 Documentation

All of our API endpoints are documented at: https://docs.peopledatalabs.com/

These docs describe the supported input parameters, output responses and also provide additional technical context.

As illustrated in the Endpoints section above, each of our API endpoints is mapped to a specific method in the PDLJS class. For each of these class methods, all function inputs are mapped as input parameters to the respective API endpoint, meaning that you can use the API documentation linked above to determine the input parameters for each endpoint.

As an example:

The following is valid because name is a supported input parameter to the Person Identify API:

PDLJS.person.identify({ name: 'sean thorne' })

Conversely, this would be invalid because fake_parameter is not an input parameter to the Person Identify API:

PDLJS.person.identify({ fake_parameter: 'anything' })

Special Note about Search API Support

Our Person Search API and Company Search API endpoints both support two types of query syntax: you can construct search queries using either SQL or Elasticsearch syntax.

In the PDLJS class, the person and company search functions are broken out into two syntax-specific methods as follows: | Data Type | Search Query Syntax | Function | | -- | -- | -- | | Person | SQL | PDLJS.person.search.sql({ ...params }) | | Person | Elasticsearch | PDLJS.person.search.elastic({ ...params }) | | Company | SQL | PDLJS.company.search.sql({ ...params }) | | Company | Elasticsearch | PDLJS.company.search.elastic({ ...params }) |

You can pass your query to these methods using the special searchQuery function argument, as shown in the following example:

const sqlQuery = "SELECT * FROM company WHERE website='peopledatalabs.com';"

try {
  const response = await PDLJS.company.search.sql({ searchQuery: sqlQuery, size: 10 });

  console.log(response.total)
} catch (error) {
  console.log(error)
}

Upgrading to v6.X.X

NOTE: When upgrading to v6.X.X from vX.X.X and below, Retrieve and Bulk Retrieve were both changed to make the pretty, titlecase and filter_updated to be siblings of the requests parameter.

Upgrading to v5.X.X

NOTE: When upgrading to v5.X.X from v4.X.X and below, Bulk Enrichment was moved from PDLJS.person.bulk({ ...records }) to PDLJS.person.bulk.enrichment({ ...records })