Quickstart - Person Search API

A fast hands-on introduction to the Person Search API

Getting Started

In order to use our Person Search API, you must have an active API key. You can look up your API key by logging into our self-serve dashboard and going to the API Keys section.

👍

Need an API Key?

If you don't have an API key, you can easily create one by signing up for a self-serve account. Check out our Self-Serve Quickstart Guide, which walks you through the sign-up process as well as how to use the self-serve API dashboard.

Simple Example

As mentioned in the Overview, the Person Search API is a way to filter and segment individual profiles included in our Person Dataset. In order to use the Person Search API, you will need either an Elasticsearch query or an SQL query.

Here's a quick example that demonstrates retrieving the individual profiles of those whose location_country is mexico, whose job_title_role is health and whose record includes a field of phone_numbers:

import json

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

# Create a client, specifying your API key
client = PDLPY(
    api_key="YOUR API KEY",
)

# Create an Elasticsearch query
ES_QUERY = {
  'query': {
    'bool': {
        'must': [
            {'term': {'location_country': "mexico"}},
            {'term': {'job_title_role': "health"}},
            {'exists': {'field': "phone_numbers"}}
      ]
    }
  }
}

# Create a parameters JSON object
PARAMS = {
  'query': ES_QUERY,
  'size': 10,
  'pretty': True
}

# Pass the parameters object to the Person Search API
response = client.person.search(**PARAMS).json()

# Check for successful response
if response["status"] == 200:
  data = response['data']
  # Write out each profile found to file
  with open("my_pdl_search.jsonl", "w") as out:
    for record in data:
      out.write(json.dumps(record) + "\n")
  print(f"successfully grabbed {len(data)} records from pdl")
  print(f"{response['total']} total pdl records exist matching this query")
else:
  print("NOTE. The carrier pigeons lost motivation in flight. See error and try again.")
  print("Error:", response)
import json

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

# Create a client, specifying your API key
client = PDLPY(
    api_key="YOUR API KEY",
)

# Create an SQL query
SQL_QUERY = \
"""
  SELECT * FROM person
  WHERE location_country='mexico'
  AND job_title_role='health'
  AND phone_numbers IS NOT NULL;
 """

# Create a parameters JSON object
PARAMS = {
  'sql': SQL_QUERY,
  'size': 10,
  'pretty': True
}

# Pass the parameters object to the Person Search API
response = client.person.search(**PARAMS).json()

# Check for successful response
if response["status"] == 200:
  data = response['data']
  # Write out each profile found to file
  with open("my_pdl_search.jsonl", "w") as out:
    for record in data:
      out.write(json.dumps(record) + "\n")
  print(f"successfully grabbed {len(data)} records from pdl")
  print(f"{response['total']} total pdl records exist matching this query")
else:
  print("NOTE. The carrier pigeons lost motivation in flight. See error and try again.")
  print("Error:", response)
# Elasticsearch
curl -X GET 'https://api.peopledatalabs.com/v5/person/search' \
-H 'X-Api-Key: xxxx' \
--data-raw '{
  "size": 10,
  "query": {
    "bool": {
      "must": [
        {"term": {"location_country": "mexico"}},
        {"term": {"job_title_role": "health"}},
        {"exists": {"field": "phone_numbers"}}
      ]
    }
  }
}'

# SQL
curl -X GET \
  'https://api.peopledatalabs.com/v5/person/search' \
  -H 'X-Api-Key: xxxx' \
  --data-raw '{
    "size": 10,
    "sql": "SELECT * FROM person WHERE location_country='\''mexico'\'' AND job_title_role='\''health'\'' AND phone_numbers IS NOT NULL;"
}'
// See https://github.com/peopledatalabs/peopledatalabs-js
import PDLJS from 'peopledatalabs';

import fs from 'fs';

// Create a client, specifying your API key
const PDLJSClient = new PDLJS({ apiKey: "YOUR API KEY" });

// Create an Elasticsearch query
const esQuery = {
  query: {
    bool: {
      must:[
        {term: {location_country: "mexico"}}, 
        {term: {job_title_role: "health"}}, 
        {exists: {field: "phone_numbers"}}
      ]
    }
  }
}

// Create a parameters JSON object
const params = {
  searchQuery: esQuery, 
  size: 10,
  pretty: true
}

// Pass the parameters object to the Person Search API
PDLJSClient.person.search.elastic(params).then((data) => {
    // Write out all profiles found to file
    fs.writeFile("my_pdl_search.jsonl", Buffer.from(JSON.stringify(data.data)), (err) => {
        if (err) throw err;
    });
    console.log(`successfully grabbed ${data.data.length} records from pdl`);
    console.log(`${data["total"]} total pdl records exist matching this query`)
}).catch((error) => {
    console.log("NOTE. The carrier pigeons lost motivation in flight. See error and try again.")
    console.log(error);
});
// See https://github.com/peopledatalabs/peopledatalabs-js
import PDLJS from 'peopledatalabs';

import fs from 'fs';

// Create a client, specifying your API key
const PDLJSClient = new PDLJS({ apiKey: "YOUR API KEY" });

// Create an SQL query
const sqlQuery = `SELECT * FROM person 
                  WHERE location_country='mexico' 
                  AND job_title_role='health'
                  AND phone_numbers IS NOT NULL;`

// Create a parameters JSON object
const params = {
  searchQuery: sqlQuery, 
  size: 10,
  pretty: true
}

// Pass the parameters object to the Person Search API
PDLJSClient.person.search.sql(params).then((data) => {
    // Write out all profiles found to file
    fs.writeFile("my_pdl_search.jsonl", Buffer.from(JSON.stringify(data.data)), (err) => {
        if (err) throw err;
    });
    console.log(`successfully grabbed ${data.data.length} records from pdl`);
    console.log(`${data["total"]} total pdl records exist matching this query`)
}).catch((error) => {
    console.log("NOTE. The carrier pigeons lost motivation in flight. See error and try again.")
    console.log(error);
});
require 'json'

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

# Set your API key
Peopledatalabs.api_key = 'YOUR API KEY'

# Create an Elasticsearch query
ES_QUERY = {
  "query": {
    "bool": {
        "must": [
            {"term": {"location_country": "mexico"}},
            {"term": {"job_title_role": "health"}},
            {"exists": {"field": "phone_numbers"}}
      ]
    }
  }
}

# Pass parameters to the Person Search API
response = Peopledatalabs::Search.people(searchType: 'elastic', query: ES_QUERY, size: 10, pretty: true)

# Check for successful response
if response['status'] == 200
    data = response['data']
    # Write out each profile found to file
    File.open("my_pdl_search.jsonl", "w") do |out|
        data.each { |record| out.write(JSON.dump(record) + "\n") }
    end
    puts "successfully grabbed #{data.length()} records from pdl"
    puts "#{response['total']} total pdl records exist matching this query"
end
require 'json'

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

# Set your API key
Peopledatalabs.api_key = 'YOUR API KEY'

# Create an SQL query
SQL_QUERY = \
"""
  SELECT * FROM person
  WHERE location_country='mexico'
  AND job_title_role='health'
  AND phone_numbers IS NOT NULL;
 """

# Pass parameters to the Person Search API
response = Peopledatalabs::Search.people(searchType: 'sql', query: SQL_QUERY, size: 10, pretty: true)

# Check for successful response
if response['status'] == 200
    data = response['data']
    # Write out each profile found to file
    File.open("my_pdl_search.jsonl", "w") do |out|
        data.each { |record| out.write(JSON.dump(record) + "\n") }
    end
    puts "successfully grabbed #{data.length()} records from pdl"
    puts "#{response['total']} total pdl records exist matching this query"
end
package main

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

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

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

    // Create a client, specifying your API key
    client := pdl.New(apiKey)
    
    // Create an Elasticsearch query
    elasticSearchQuery := map[string]interface{} {
        "query": map[string]interface{} {
            "bool": map[string]interface{} {
                "must": []map[string]interface{} {
                    {"term": map[string]interface{}{"location_country": "mexico"}},
                    {"term": map[string]interface{}{"job_title_role": "health"}},
                    {"exists": map[string]interface{}{"field": "phone_numbers"}},
                },
            },
        },
    }

    // Create a parameters JSON object
    params := pdlmodel.SearchParams {
        BaseParams: pdlmodel.BaseParams {
            Size: 10,
            Pretty: true,
        },
        SearchBaseParams: pdlmodel.SearchBaseParams {
            Query: elasticSearchQuery,
        },
    }
    
    // Pass the parameters object to the Person Search API
    response, err := client.Person.Search(params)
    // Check for successful response
    if err == nil {
        data := response.Data
        // Create file
        out, outErr := os.Create("my_pdl_search.jsonl")
        defer out.Close()
        if (outErr == nil) {
            for i := range data {
                // Convert each profile found to JSON
                record, jsonErr := json.Marshal(data[i])
                // Write out each profile to file
                if (jsonErr == nil) {
                    out.WriteString(string(record) + "\n")
                }
            }
            out.Sync()
        }
        fmt.Printf("successfully grabbed %d records from pdl\n", len(data))
        fmt.Printf("%d total pdl records exist matching this query\n", response.Total)
    }  
}
package main

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

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

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

    // Create a client, specifying your API key
    client := pdl.New(apiKey)
    
    // Create an SQL query
    sqlQuery := "SELECT * FROM person" +
        " WHERE location_country='mexico'" +
        " AND job_title_role='health'" +
        " AND phone_numbers IS NOT NULL;"

    // Create a parameters JSON object
    params := pdlmodel.SearchParams {
        BaseParams: pdlmodel.BaseParams {
            Size: 10,
            Pretty: true,
        },
        SearchBaseParams: pdlmodel.SearchBaseParams {
            SQL: sqlQuery,
        },
    }
    
    // Pass the parameters object to the Person Search API
    response, err := client.Person.Search(params)
    // Check for successful response
    if err == nil {
        data := response.Data
        // Create file
        out, outErr := os.Create("my_pdl_search.jsonl")
        defer out.Close()
        if (outErr == nil) {
            for i := range data {
                // Convert each profile found to JSON
                record, jsonErr := json.Marshal(data[i])
                // Write out each profile to file
                if (jsonErr == nil) {
                    out.WriteString(string(record) + "\n")
                }
            }
            out.Sync()
        }
        fmt.Printf("successfully grabbed %d records from pdl\n", len(data))
        fmt.Printf("%d total pdl records exist matching this query\n", response.Total)
    }  
}
import requests, json

# Set your API key
API_KEY = # YOUR API KEY

# Set the Person Search API URL
PDL_URL = "https://api.peopledatalabs.com/v5/person/search"

# Set headers
H = {
  'Content-Type': "application/json",
  'X-api-key': API_KEY
}

# Create an Elasticsearch query
ES_QUERY = {
  'query': {
    'bool': {
        'must': [
            {'term': {'location_country': "mexico"}},
            {'term': {'job_title_role': "health"}},
            {'exists': {'field': "phone_numbers"}}
      ]
    }
  }
}

# Create a parameters JSON object
PARAMS = {
  'query': json.dumps(ES_QUERY),
  'size': 10,
  'pretty': True
}

# Pass the parameters object to the Person Search API
response = requests.get(
  PDL_URL,
  headers=H,
  params=PARAMS
).json()

# Check for successful response
if response["status"] == 200:
  data = response['data']
  # Write out each profile found to file
  with open("my_pdl_search.jsonl", "w") as out:
    for record in data:
      out.write(json.dumps(record) + "\n")
  print(f"successfully grabbed {len(data)} records from pdl")
  print(f"{response['total']} total pdl records exist matching this query")
else:
  print("NOTE. The carrier pigeons lost motivation in flight. See error and try again.")
  print("Error:", response)
import requests, json

# Set your API key
API_KEY = # YOUR API KEY

# Set the Person Search API URL
PDL_URL = "https://api.peopledatalabs.com/v5/person/search"

# Set headers
H = {
  'Content-Type': "application/json",
  'X-api-key': API_KEY
}

# Create an SQL query
SQL_QUERY = \
"""
  SELECT * FROM person
  WHERE location_country='mexico'
  AND job_title_role='health'
  AND phone_numbers IS NOT NULL;
 """

# Create a parameters JSON object
PARAMS = {
  'sql': SQL_QUERY,
  'size': 10,
  'pretty': True
}

# Pass the parameters object to the Person Search API
response = requests.get(
  PDL_URL,
  headers=H,
  params=PARAMS
).json()

# Check for successful response
if response["status"] == 200:
  data = response['data']
  # Write out each profile found to file
  with open("my_pdl_search.jsonl", "w") as out:
    for record in data:
      out.write(json.dumps(record) + "\n")
  print(f"successfully grabbed {len(data)} records from pdl")
  print(f"{response['total']} total pdl records exist matching this query")
else:
  print("NOTE. The carrier pigeons lost motivation in flight. See error and try again.")
  print("Error:", response)

The response returned is a list of individual profiles if the query passed matches records in our dataset:

{
  "status": 200,
  "data": [
    {
      "id": "qEnOZ5Oh0poWnQ1luFBfVw_0000",
      "full_name": "sean thorne",
      "first_name": "sean",
      "middle_initial": "f",
      "middle_name": "fong",
      "last_name": "thorne",
      "gender": "male",
      "birth_year": "1990",
      "birth_date": null,
      "linkedin_url": "linkedin.com/in/seanthorne",
      "linkedin_username": "seanthorne",
      "linkedin_id": "145991517",
      "facebook_url": "facebook.com/deseanthorne",
      "facebook_username": "deseanthorne",
      "facebook_id": "1089351304",
      "twitter_url": "twitter.com/seanthorne5",
      "twitter_username": "seanthorne5",
      "github_url": null,
      "github_username": null,
      "work_email": "[email protected]",
      "personal_emails": ["[email protected]"],
      "mobile_phone": "+14155688415",
      "industry": "computer software",
      "job_title": "co-founder and chief executive officer",
      "job_title_role": null,
      "job_title_sub_role": null,
      "job_title_levels": [
        "owner",
        "cxo"
      ],
      "job_company_id": "peopledatalabs",
      "job_company_name": "people data labs",
      "job_company_website": "peopledatalabs.com",
      "job_company_size": "11-50",
      "job_company_founded": "2015",
      "job_company_industry": "computer software",
      "job_company_linkedin_url": "linkedin.com/company/peopledatalabs",
      "job_company_linkedin_id": "18170482",
      "job_company_facebook_url": "facebook.com/peopledatalabs",
      "job_company_twitter_url": "twitter.com/peopledatalabs",
      "job_company_location_name": "san francisco, california, united states",
      "job_company_location_locality": "san francisco",
      "job_company_location_metro": "san francisco, california",
      "job_company_location_region": "california",
      "job_company_location_geo": "37.77,-122.41",
      "job_company_location_street_address": "455 market street",
      "job_company_location_address_line_2": "suite 1670",
      "job_company_location_postal_code": "94105",
      "job_company_location_country": "united states",
      "job_company_location_continent": "north america",
      "job_last_updated": "2020-12-01",
      "job_start_date": "2015-03",
      "location_name": "san francisco, california, united states",
      "location_locality": "san francisco",
      "location_metro": "san francisco, california",
      "location_region": "california",
      "location_country": "united states",
      "location_continent": "north america",
      "location_street_address": null,
      "location_address_line_2": null,
      "location_postal_code": null,
      "location_geo": "37.77,-122.41",
      "location_last_updated": "2020-12-01",
      "phone_numbers": [
        "+14155688415"
      ],
      "emails": [
        {
          "address": "[email protected]",
          "type": null
        },
        {
          "address": "[email protected]",
          "type": "professional"
        },
        {
          "address": "[email protected]",
          "type": "professional"
        },
        {
          "address": "[email protected]",
          "type": "professional"
        },
        {
          "address": "[email protected]",
          "type": "current_professional"
        },
        {
          "address": "[email protected]",
          "type": "current_professional"
        },
        {
          "address": "[email protected]",
          "type": "current_professional"
        }
      ],
      "interests": [
        "location based services",
        "mobile",
        "social media",
        "colleges",
        "university students",
        "consumer internet",
        "college campuses"
      ],
      "skills": [
        "entrepreneurship",
        "start ups",
        "management",
        "public speaking",
        "strategic partnerships",
        "strategy",
        "fundraising",
        "saas",
        "enterprise technology sales",
        "social networking"
      ],
      "location_names": [
        "san francisco, california, united states",
        "albany, california, united states",
        "portland, oregon, united states"
      ],
      "regions": [
        "california, united states",
        "oregon, united states"
      ],
      "countries": [
        "united states"
      ],
      "street_addresses": [],
      "experience": [
        {
          "company": {
            "name": "hallspot",
            "size": "1-10",
            "id": "hallspot",
            "founded": "2013",
            "industry": "computer software",
            "location": {
              "name": "portland, oregon, united states",
              "locality": "portland",
              "region": "oregon",
              "metro": "portland, oregon",
              "country": "united states",
              "continent": "north america",
              "street_address": "1231 northwest hoyt street",
              "address_line_2": "suite 202",
              "postal_code": "97209",
              "geo": "45.52,-122.67"
            },
            "linkedin_url": "linkedin.com/company/hallspot",
            "linkedin_id": "3019184",
            "facebook_url": null,
            "twitter_url": "twitter.com/hallspot",
            "website": "hallspot.com"
          },
          "location_names": [],
          "end_date": "2015-02",
          "start_date": "2012-08",
          "title": {
            "name": "co-founder",
            "role": null,
            "sub_role": null,
            "levels": [
              "owner"
            ]
          },
          "is_primary": false
        },
        {
          "company": {
            "name": "people data labs",
            "size": "11-50",
            "id": "peopledatalabs",
            "founded": "2015",
            "industry": "computer software",
            "location": {
              "name": "san francisco, california, united states",
              "locality": "san francisco",
              "region": "california",
              "metro": "san francisco, california",
              "country": "united states",
              "continent": "north america",
              "street_address": "455 market street",
              "address_line_2": "suite 1670",
              "postal_code": "94105",
              "geo": "37.77,-122.41"
            },
            "linkedin_url": "linkedin.com/company/peopledatalabs",
            "linkedin_id": "18170482",
            "facebook_url": "facebook.com/peopledatalabs",
            "twitter_url": "twitter.com/peopledatalabs",
            "website": "peopledatalabs.com"
          },
          "location_names": [],
          "end_date": null,
          "start_date": "2015-03",
          "title": {
            "name": "co-founder and chief executive officer",
            "role": null,
            "sub_role": null,
            "levels": [
              "owner",
              "cxo"
            ]
          },
          "is_primary": true
        }
      ],
      "education": [
        {
          "school": {
            "name": "university of oregon",
            "type": "post-secondary institution",
            "id": "64LkgfdwWYkCC2TjbldMDQ_0",
            "location": {
              "name": "eugene, oregon, united states",
              "locality": "eugene",
              "region": "oregon",
              "country": "united states",
              "continent": "north america"
            },
            "linkedin_url": "linkedin.com/school/university-of-oregon",
            "facebook_url": "facebook.com/universityoforegon",
            "twitter_url": "twitter.com/uoregon",
            "linkedin_id": "19207",
            "website": "uoregon.edu",
            "domain": "uoregon.edu"
          },
          "end_date": "2014",
          "start_date": "2010",
          "gpa": null,
          "degrees": [],
          "majors": [
            "entrepreneurship"
          ],
          "minors": []
        }
      ],
      "profiles": [
        {
          "network": "linkedin",
          "id": "145991517",
          "url": "linkedin.com/in/seanthorne",
          "username": "seanthorne"
        },
        {
          "network": "facebook",
          "id": "1089351304",
          "url": "facebook.com/deseanthorne",
          "username": "deseanthorne"
        },
        {
          "network": "twitter",
          "id": null,
          "url": "twitter.com/seanthorne5",
          "username": "seanthorne5"
        },
        {
          "network": "linkedin",
          "id": null,
          "url": "linkedin.com/in/sean-thorne-9b9a8540",
          "username": "sean-thorne-9b9a8540"
        },
        {
          "network": "angellist",
          "id": null,
          "url": "angel.co/deseanthorne",
          "username": "deseanthorne"
        },
        {
          "network": "gravatar",
          "id": null,
          "url": "gravatar.com/seanthorne5",
          "username": "seanthorne5"
        },
        {
          "network": "klout",
          "id": null,
          "url": "klout.com/seanthorne5",
          "username": "seanthorne5"
        },
        {
          "network": "aboutme",
          "id": null,
          "url": "about.me/sean_thorne",
          "username": "sean_thorne"
        }
      ]
    }
  ],
"scroll_token": "1117$12.176522"  
"total": 94
}

If you don't get this response, check out our errors page for more information.



Did this page help you?