We made a free JS library to quickly access professional data on people and companies
Tags: javascript, webdev, opensource, productivity
Published: 2022-02-22 14:49:56

What would you build with easy access to person and company data? What if you could instantly query a database for “all the companies in San Francisco using react” or “the GitHub profiles of senior software engineers at Google”?

Having the right data can sometimes make or break your project, and we often we rule out working on interesting projects simply because we don’t know how to get the data we need.

We wanted to create an easier way to get high-quality (and ethically-sourced) data - so we built an open-source library to do just that!


{% embed https://github.com/peopledatalabs/peopledatalabs-js %}

### Features

This is a simple client library that supports over a dozen different endpoints for accessing the different datasets we’ve built[^1]. Some of the key features are:

#### Totally minified
We know how much bloated npm packages can weigh down your project, so we kept it super lightweight with this library - less than 2KB compressed.

#### Framework agnostic
We wrote it using plain vanilla JS. This means you can easily integrate it into any of your javascript projects, whether you’re deploying to a server or running right in the browser.

#### Supports all our endpoints
This library supports [every single one of our endpoints](https://github.com/peopledatalabs/peopledatalabs-js#-endpoints-), so you can easily query the data you want, the way you want. Everything is just one function call away!


## Getting Started
Getting set up is a breeze!

1. Pull the package from the npm repository:
`npm i peopledatalabs`

2. Sign up for a [free API key](https://www.peopledatalabs.com/signup) 

And that’s it! Now just import the client and initialize it with your API key and you’re ready to go 🚀
```js
import PDLJS from 'peopledatalabs';
const PDLJSClient = new PDLJS({ apiKey: "YOUR API KEY" });
```

## Examples
So what can you do, once you’re set up? Here’s a few quick examples:

### Finding person-related information
Maybe you’re interested in data related to people? Here’s what that query from before would look like using our **Person Search API**:

```js
// Find the github profiles for senior software engineers at Google
const sqlQuery = `
  SELECT * FROM person 
  WHERE job_company_website='google.com' 
  AND job_title='senior software engineer'
  AND github_url IS NOT NULL;`

PDLJSClient.person.search.sql({
  searchQuery: sqlQuery,
  size: 10
}).then((data) => {
  for (let record of data['data']) {
    console.log(record['github_url'])
  }
  console.log(`Total Number of Available Records: ${data['total']}`);
}).catch((error) => {
  console.log(error);
});
```
### Finding company-related information
Or if you’re interested in company data instead, you could use our **Company Enrichment API** to get full profiles on individual companies. For example, let’s look up Salesforce:

```js
// Get the full profile for Salesforce
PDLJSClient.company.enrichment({ 
  website: 'salesforce.com' 
}).then((data) => {
  console.log(data);
}).catch((error) => {
  console.log(error);
});
```

### Using supporting endpoints
We’ve also got several auxiliary endpoints to help you with data cleaning and autocompletion. For example, you could use our **Autocomplete API** to build an interactive form (like the one below) by generating real-time suggestions for company names:

![GIF of interactive form field displaying suggestions provided by the autocomplete api](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eq5rwn2wtdyhrreq1wzr.gif)

```js
// Autocomplete Suggestions for Company Names starting with "str"
PDLJSClient.autocomplete({ 
  field: "company", 
  text: "str" 
}).then((data) => {
  console.log(data);
}).catch((error) => {
  console.log(error);
});
```
## Documentation

If you’re interested in learning more, you can check out our [GitHub](https://github.com/peopledatalabs/peopledatalabs-js) repo for documentation, full working examples, and links to additional resources!

## Wrapping Up
We hope you find this library useful, and we would love to see what you build. Of course nothing is ever perfect, so if you find a bug or if you have any suggestions or questions we are always happy to hear (pull requests welcome!)
 
So give it a spin, and let us know what you think! 

\- With ❤️  from the People Data Labs team


## Who We Are
At PDL, we are in the business of building the world’s best datasets on business profiles and companies. We are an organization that believes the future of every business will be data-driven, and we want to make that happen through building the world’s most comprehensive and ethically-sourced B2B datasets. 

We have a rapidly growing user base across numerous industries, ranging from recruiting to investment and competitive intelligence. We’re a fun-loving team and always [looking for great talent to join](https://boards.greenhouse.io/peopledatalabs)!

[^1]: Curious about how we built our datasets? We put a fair bit of engineering behind it and we shared our process in this [whitepaper](https://www.peopledatalabs.com/resources/data-build) - check it out!