Examples - Cleaner APIs

Code examples and walkthroughs using the Cleaner APIs

Company Cleaner API Example

# See https://github.com/peopledatalabs/peopledatalabs-python
from peopledatalabs import PDLPY

# Create a client, specifying an API key
client = PDLPY(
    api_key="YOUR_API_KEY",
)

query_string = {"website":"peopledatalabs.com"}

response = client.company.cleaner(**query_string)

print(response.text)
// See https://github.com/peopledatalabs/peopledatalabs-js
import PDLJS from 'peopledatalabs';

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

const params = {
  website: "peopledatalabs.com"
}

PDLJSClient.company.cleaner(params).then((data) => {
  console.log(data);
}).catch((error) => {
  console.log(error);
});
# See https://github.com/peopledatalabs/peopledatalabs-ruby
require 'peopledatalabs'

Peopledatalabs.api_key = 'YOUR API KEY'

response = Peopledatalabs::Cleaner.company(kind: "website", value: "peopledatalabs.com")

puts response
package main

import (
    "fmt"
 )

import (
    pdl "github.com/peopledatalabs/peopledatalabs-go"
    pdlmodel "github.com/peopledatalabs/peopledatalabs-go/model"
)

func main() {
    apiKey := "YOUR API KEY"
    // Set API KEY as env variable
    // apiKey := os.Getenv("API_KEY")

    client := pdl.New(apiKey)
    
    params := pdlmodel.CleanCompanyParams {
        Website: "peopledatalabs.com",
    }
    
    response, err := client.Company.Clean(params)
    if err == nil {
        fmt.Println(response)
    }  
}
import requests

url = "https://api.peopledatalabs.com/v5/company/clean"

query_string = {"website":"peopledatalabs.com"}

headers = {
    'accept': "application/json",
    'content-type': "application/json",
    'x-api-key': "YOUR_API_KEY"
    }

response = requests.request("GET", url, headers=headers, params=query_string)

print(response.text)

Location Cleaner API Example

# See https://github.com/peopledatalabs/peopledatalabs-python
from peopledatalabs import PDLPY

# Create a client, specifying an API key
client = PDLPY(
    api_key="YOUR_API_KEY",
)

query_string = {"location":"239 NW 13th Ave, Portland, Oregon 97209, US"}

response = client.location.cleaner(**query_string)

print(response.text)
// See https://github.com/peopledatalabs/peopledatalabs-js
import PDLJS from 'peopledatalabs';

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

const params = {
  location:"239 NW 13th Ave, Portland, Oregon 97209, US"
}

PDLJSClient.location.cleaner(params).then((data) => {
  console.log(data);
}).catch((error) => {
  console.log(error);
});
# See https://github.com/peopledatalabs/peopledatalabs-ruby
require 'peopledatalabs'

Peopledatalabs.api_key = 'YOUR API KEY'

response = Peopledatalabs::Cleaner.location(value: "239 NW 13th Ave, Portland, Oregon 97209, US")

puts response
package main

import (
    "fmt"
 )

import (
    pdl "github.com/peopledatalabs/peopledatalabs-go"
    pdlmodel "github.com/peopledatalabs/peopledatalabs-go/model"
)

func main() {
    apiKey := "YOUR API KEY"
    // Set API KEY as env variable
    // apiKey := os.Getenv("API_KEY")

    client := pdl.New(apiKey)
    
    querystring := pdlmodel.LocationParams{Location: "239 NW 13th Ave, Portland, Oregon 97209, US"}
    
    params := pdlmodel.CleanLocationParams {
        LocationParams: querystring,
    }
    
    response, err := client.Location.Clean(params)
    if err == nil {
        fmt.Println(response)
    }  
}
import requests

url = "https://api.peopledatalabs.com/v5/location/clean"

query_string = {"location":"239 NW 13th Ave, Portland, Oregon 97209, US"}

headers = {
    'accept': "application/json",
    'content-type': "application/json",
    'x-api-key': "YOUR_API_KEY"
    }

response = requests.request("GET", url, headers=headers, params=query_string)

print(response.text)

School Cleaner API Example

# See https://github.com/peopledatalabs/peopledatalabs-python
from peopledatalabs import PDLPY

# Create a client, specifying an API key
client = PDLPY(
    api_key="YOUR_API_KEY",
)

query_string = {"profile":"linkedin.com/school/ucla"}

response = client.school.cleaner(**query_string)

print(response.text)
// See https://github.com/peopledatalabs/peopledatalabs-js
import PDLJS from 'peopledatalabs';

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

const params = {
  profile:"linkedin.com/school/ucla"
}

PDLJSClient.school.cleaner(params).then((data) => {
  console.log(data);
}).catch((error) => {
  console.log(error);
});
# See https://github.com/peopledatalabs/peopledatalabs-ruby
require 'peopledatalabs'

Peopledatalabs.api_key = 'YOUR API KEY'

response = Peopledatalabs::Cleaner.school(kind: "profile", value: "linkedin.com/school/ucla")

puts response
package main

import (
    "fmt"
 )

import (
    pdl "github.com/peopledatalabs/peopledatalabs-go"
    pdlmodel "github.com/peopledatalabs/peopledatalabs-go/model"
)

func main() {
    apiKey := "YOUR API KEY"
    // Set API KEY as env variable
    // apiKey := os.Getenv("API_KEY")

    client := pdl.New(apiKey)
    
    querystring := pdlmodel.SchoolParams{Profile: "linkedin.com/school/ucla"}
    
    params := pdlmodel.CleanSchoolParams {
        SchoolParams: querystring,
    }
    
    response, err := client.School.Clean(params)
    if err == nil {
        fmt.Println(response)
    }  
}
import requests

url = "https://api.peopledatalabs.com/v5/school/clean"

query_string = {"profile":"linkedin.com/school/ucla"}

headers = {
    'accept': "application/json",
    'content-type': "application/json",
    'x-api-key': "YOUR_API_KEY"
    }

response = requests.request("GET", url, headers=headers, params=query_string)

print(response.text)

Advanced Example

"I want to find employees at a particular company but don't have the PDL identifier for the company."

import json

# See https://github.com/peopledatalabs/peopledatalabs-python
from peopledatalabs import PDLPY

# Create a client, specifying an API key
client = PDLPY(
    api_key="YOUR_API_KEY",
)

company_website = "peopledatalabs.com"

# Clean company then find people at that company:
pdl_employees = []

# Company Cleaning
query_string = { "website": company_website }

response = client.company.cleaner(**query_string)

if response.status_code == 200:
    cleaned_company = response.json()
else:
    cleaned_company = {}
    print(f"Company Cleaner API Error for [{company_website}]: {response.text}")

# Person Search
company_employee_matches = {}

if cleaned_company:
    ES_QUERY = {
        "query": {
            "bool": {
                "must": [
                    {"term": {"job_company_id": cleaned_company['id']}}
                ]
            }
        }
    }

    params = {
        'query': ES_QUERY,
        'size': 100
    }

    response = client.person.search(**params)

    if response.status_code == 200:
        company_employee_matches = response.json()['data']
    else:
        company_employee_matches = {}
        print(f"Person Search Error for [{company_website}]: {response.text}")

print(f"Found {len(company_employee_matches)} employee profiles at {company_website}")
import json

# See https://github.com/peopledatalabs/peopledatalabs-python
from peopledatalabs import PDLPY

# Create a client, specifying an API key
client = PDLPY(
    api_key="YOUR_API_KEY",
)

company_website = "peopledatalabs.com"

# Clean company then find people at that company:
pdl_employees = []

# Company Cleaning
query_string = { "website": company_website }

response = client.company.cleaner(**query_string)

if response.status_code == 200:
    cleaned_company = response.json()
else:
    cleaned_company = {}
    print(f"Company Cleaner API Error for [{company_website}]: {response.text}")

# Person Search
company_employee_matches = {}

if cleaned_company:
    SQL_QUERY = f"""
    SELECT * FROM person
    WHERE job_company_id = '{cleaned_company['id']}'
    """

    params = {
        'sql': SQL_QUERY,
        'size': 100
    }

    response = client.person.search(**params)

    if response.status_code == 200:
        company_employee_matches = response.json()['data']
    else:
        company_employee_matches = {}
        print(f"Person Search Error for [{company_website}]: {response.text}")

print(f"Found {len(company_employee_matches)} employee profiles at {company_website}")
// See https://github.com/peopledatalabs/peopledatalabs-js
import PDLJS from 'peopledatalabs';

const PDLJSClient = new PDLJS({ apiKey: "YOUR_API_KEY" });

const companyWebsite = "peopledatalabs.com";

// Clean company then find people at that company:
var pdlEmployees = [];

// Company Cleaning
const queryString = { "website": companyWebsite };

var cleanedCompany;

PDLJSClient.company.cleaner(queryString).then((data) => {

    cleanedCompany = data;
    
    // Person Search
    var companyEmployeeMatches = {};
    
    const esQuery = {
      query: {
         bool: {
            must:[
               {"term": {"job_company_id": cleanedCompany["id"]}}
            ]
         }
      }
    }
    
    const params = {
        searchQuery: esQuery, 
        size: 100,
    }
    
    PDLJSClient.person.search.elastic(params).then((data) => {
        companyEmployeeMatches = data.data;
        console.log(`Found ${companyEmployeeMatches.length} employee profiles at ${companyWebsite}`);
    }).catch((error) => {
        companyEmployeeMatches = {};
        console.log(`Person Search Error for [${companyWebsite}]: ${error}`);
    });
    
}).catch((error) => {
    console.log(error);
});
// See https://github.com/peopledatalabs/peopledatalabs-js
import PDLJS from 'peopledatalabs';

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

const companyWebsite = "peopledatalabs.com";

// Clean company then find people at that company:
var pdlEmployees = [];

// Company Cleaning
const queryString = { "website": companyWebsite };

var cleanedCompany;

PDLJSClient.company.cleaner(queryString).then((data) => {

    cleanedCompany = data;
    
    // Person Search
    var companyEmployeeMatches = {};
    
    const sqlQuery = `SELECT * FROM person
                        WHERE job_company_id = '` + cleanedCompany["id"] + `';`;
    
    const params = {
        searchQuery: sqlQuery, 
        size: 100,
    }
    
    PDLJSClient.person.search.sql(params).then((data) => {
        companyEmployeeMatches = data.data;
        console.log(`Found ${companyEmployeeMatches.length} employee profiles at ${companyWebsite}`);
    }).catch((error) => {
        companyEmployeeMatches = {};
        console.log(`Person Search Error for [${companyWebsite}]: ${error}`);
    });
    
}).catch((error) => {
    console.log(error);
});
require 'json'

# See https://github.com/peopledatalabs/peopledatalabs-ruby
require 'peopledatalabs'

Peopledatalabs.api_key = 'YOUR API KEY'

company_website = "peopledatalabs.com"

# Clean company then find people at that company:
pdl_employees = []

# Company Cleaning
response = Peopledatalabs::Cleaner.company(kind: "website", value: company_website)

if response['status'] == 200
    cleaned_company = response
else
    cleaned_company = {}
    puts "Company Cleaner API Error for #{company_website}: #{response}"
end

# Person Search
company_employee_matches = {}

if cleaned_company
    ES_QUERY = {
        "query": {
            "bool": {
                "must": [
                    {"term": {"job_company_id": cleaned_company['id']}}
                ]
            }
        }
    }

    response = Peopledatalabs::Search.people(searchType: 'elastic', query: ES_QUERY, size: 100)

    if response['status'] == 200
        company_employee_matches = response['data']
    else
        company_employee_matches = []
        puts "Person Search Error for [#{company_website}]: #{response}"
    end
end
puts "Found #{company_employee_matches.length()} employee profiles at #{company_website}"
require 'json'

# See https://github.com/peopledatalabs/peopledatalabs-ruby
require 'peopledatalabs'

Peopledatalabs.api_key = 'YOUR API KEY'

company_website = "peopledatalabs.com"

# Clean company then find people at that company:
pdl_employees = []

# Company Cleaning
response = Peopledatalabs::Cleaner.company(kind: "website", value: company_website)

if response['status'] == 200
    cleaned_company = response
else
    cleaned_company = {}
    puts "Company Cleaner API Error for #{company_website}: #{response}"
end

# Person Search
company_employee_matches = {}

if cleaned_company
    SQL_QUERY = """
    SELECT * FROM person
    WHERE job_company_id = '#{cleaned_company['id']}'
    """

    response = Peopledatalabs::Search.people(searchType: 'sql', query: SQL_QUERY, size: 10)

    if response['status'] == 200
        company_employee_matches = response['data']
    else
        company_employee_matches = []
        puts "Person Search Error for [#{company_website}]: #{response}"
    end
end
puts "Found #{company_employee_matches.length()} employee profiles at #{company_website}"
package main

import (
    "fmt"
    "encoding/json"
    "reflect"
)

import (
    pdl "github.com/peopledatalabs/peopledatalabs-go"
    pdlmodel "github.com/peopledatalabs/peopledatalabs-go/model"
)

func main() {
    apiKey := "YOUR API KEY"
    // Set API KEY as env variable
    // apiKey := os.Getenv("API_KEY")

    client := pdl.New(apiKey)
    
    companyWebsite := "peopledatalabs.com"

    // Company Cleaning
    cleanParams := pdlmodel.CleanCompanyParams {
        Website: "peopledatalabs.com",
    }
    
    var cleanedCompany pdlmodel.CleanCompanyResponse
    
    cleanResponse, cleanErr := client.Company.Clean(cleanParams)
    if cleanErr == nil {
        cleanedCompany = cleanResponse
    } else {
        fmt.Printf("Company Cleaner API Error for [%s]: %s", companyWebsite, cleanResponse)
    }
    
    // Person Search
    if !reflect.ValueOf(cleanedCompany).IsZero() {
        elasticSearchQuery := map[string]interface{} {
            "query": map[string]interface{} {
                "bool": map[string]interface{} {
                    "must": []map[string]interface{} {
                        {"term": map[string]interface{}{"job_company_id": cleanedCompany.Id}},
                    },
                },
            },
        }

        searchParams := pdlmodel.SearchParams {
            BaseParams: pdlmodel.BaseParams {
                Size: 100,
            },
            SearchBaseParams: pdlmodel.SearchBaseParams {
                Query: elasticSearchQuery,
            },
        }
        
        SearchResponse, SearchErr := client.Person.Search(searchParams)
        if SearchErr == nil {
            data := SearchResponse.Data
            companyEmployeeMatches, jsonErr := json.Marshal(data)
     
            if jsonErr == nil && !reflect.ValueOf(companyEmployeeMatches).IsZero() {
                fmt.Printf("Found %d employee profiles at %s\n", len(data), companyWebsite)
            }
        } else {
            fmt.Printf("Company Cleaner API Error for [%s]: %s\n", companyWebsite, SearchResponse)
        }
    }
}
package main

import (
    "fmt"
    "encoding/json"
    "reflect"
)

import (
    pdl "github.com/peopledatalabs/peopledatalabs-go"
    pdlmodel "github.com/peopledatalabs/peopledatalabs-go/model"
)

func main() {
    apiKey := "YOUR API KEY"
    // Set API KEY as env variable
    // apiKey := os.Getenv("API_KEY")

    client := pdl.New(apiKey)
    
    companyWebsite := "peopledatalabs.com"

    // Company Cleaning
    cleanParams := pdlmodel.CleanCompanyParams {
        Website: "peopledatalabs.com",
    }
    
    var cleanedCompany pdlmodel.CleanCompanyResponse
    
    cleanResponse, cleanErr := client.Company.Clean(cleanParams)
    if cleanErr == nil {
        cleanedCompany = cleanResponse
    } else {
        fmt.Printf("Company Cleaner API Error for [%s]: %s", companyWebsite, cleanResponse)
    }
    
    // Person Search
    if !reflect.ValueOf(cleanedCompany).IsZero() {
        sqlQuery := "SELECT * FROM person" +
            " WHERE job_company_id='" + cleanedCompany.Id + "';"

        searchParams := pdlmodel.SearchParams {
            BaseParams: pdlmodel.BaseParams {
                Size: 100,
            },
            SearchBaseParams: pdlmodel.SearchBaseParams {
                SQL: sqlQuery,
            },
        }
        
        SearchResponse, SearchErr := client.Person.Search(searchParams)
        if SearchErr == nil {
            data := SearchResponse.Data
            companyEmployeeMatches, jsonErr := json.Marshal(data)
     
            if jsonErr == nil && !reflect.ValueOf(companyEmployeeMatches).IsZero() {
                fmt.Printf("Found %d employee profiles at %s\n", len(data), companyWebsite)
            }
        } else {
            fmt.Printf("Company Cleaner API Error for [%s]: %s\n", companyWebsite, SearchResponse)
        }
    }
}
import json
import requests

PDL_COMPANY_CLEANER_URL = "https://api.peopledatalabs.com/v5/company/clean"
PDL_PERSON_SEARCH_URL = "https://api.peopledatalabs.com/v5/person/search"

API_KEY = "####" # Enter your api key here

company_website = "peopledatalabs.com"

# Clean company then find people at that company:
pdl_employees = []

# Company Cleaning
query_string = { "website": company_website }

headers = {
    'accept': "application/json",
    'content-type': "application/json",
    'x-api-key': API_KEY
}

response = requests.request("GET", PDL_COMPANY_CLEANER_URL, headers=headers, params=query_string)

if response.status_code == 200:
    cleaned_company = response.json()
else:
    cleaned_company = {}
    print(f"Company Cleaner API Error for [{company_website}]: {response.text}")

# Person Search
company_employee_matches = {}

if cleaned_company:
    headers = {
        'Content-Type': "application/json",
        'X-api-key': API_KEY
    }

    ES_QUERY = {
        "query": {
            "bool": {
                "must": [
                    {"term": {"job_company_id": cleaned_company['id']}}
                ]
            }
        }
    }

    params = {
        'query': json.dumps(ES_QUERY),
        'size': 100
    }

    response = requests.get( PDL_PERSON_SEARCH_URL, headers=headers, params=params)

    if response.status_code == 200:
        company_employee_matches = response.json()['data']
    else:
        company_employee_matches = {}
        print(f"Person Search Error for [{company_website}]: {response.text}")


print(f"Found {len(company_employee_matches)} employee profiles at {company_website}")
import json
import requests

PDL_COMPANY_CLEANER_URL = "https://api.peopledatalabs.com/v5/company/clean"
PDL_PERSON_SEARCH_URL = "https://api.peopledatalabs.com/v5/person/search"

API_KEY = "####" # Enter your api key here

company_website = "peopledatalabs.com"

# Clean company then find people at that company:
pdl_employees = []

# Company Cleaning
query_string = { "website": company_website }

headers = {
    'accept': "application/json",
    'content-type': "application/json",
    'x-api-key': API_KEY
}

response = requests.request("GET", PDL_COMPANY_CLEANER_URL, headers=headers, params=query_string)

if response.status_code == 200:
    cleaned_company = response.json()
else:
    cleaned_company = {}
    print(f"Company Cleaner API Error for [{company_website}]: {response.text}")

# Person Search
company_employee_matches = {}

if cleaned_company:
    headers = {
        'Content-Type': "application/json",
        'X-api-key': API_KEY
    }

    SQL_QUERY = f"""
    SELECT * FROM person
    WHERE job_company_id = '{cleaned_company['id']}'
    """

    params = {
        'sql': SQL_QUERY,
        'size': 100
    }

    response = requests.get( PDL_PERSON_SEARCH_URL, headers=headers, params=params)

    if response.status_code == 200:
        company_employee_matches = response.json()['data']
    else:
        company_employee_matches = {}
        print(f"Person Search Error for [{company_website}]: {response.text}")


print(f"Found {len(company_employee_matches)} employee profiles at {company_website}")

Did this page help you?