Current Job Title
Work History
Skills
Personal Email and Cell Phone
LinkedIn URL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
"""
I want to get the contact information for vice presidents of internet technology companies with 50-200 people located in San Francisco, CA
"""
import requests, json
API_KEY = "####" # Enter your api key here
PDL_URL = "https://api.peopledatalabs.com/v5/person/search"
REQUEST_HEADER = {
'Content-Type': "application/json",
'X-api-key': API_KEY
}
# Define our query for the Person Search API
# We're looking for vice presidents of mid-sized internet companies located in San Francisco
ES_QUERY = {
"query": {
"bool": {
"must": [
{"match_phrase" : {"job_title": "vice president"}},
{"term" : {"location_metro": "san francisco, california"}},
{"term" : {"job_company_industry": "internet"}},
{"term" : {"job_company_size": "51-200"}},
{"exists" : {"field": "work_email"}},
{"exists" : {"field": "phone_numbers"}}
]
}
}
}
# Build the request and define how many matches we want returned
# We'll ask for 100 matches
REQUEST_PARAMS = {
"query": json.dumps(ES_QUERY),
"size": 100,
"pretty": True
}
# Send the API request
response = requests.get(PDL_URL, params=REQUEST_PARAMS, headers=REQUEST_HEADER).json()
# Parse the response
if response['status'] == 200:
# leads_outreach is an array of people matches
# Each match is guaranteed to contain a work email and phone number
# See the full schema for all available fields at: https://docs.peopledatalabs.com/docs/fields
leads_outreach = response['data']
# Write matches out to json
with open("my_leads_outreach.json", 'w') as file_handle:
json.dump(leads_outreach, file_handle, indent=2)
print(f"Generated {len(leads_outreach)} leads")
else:
error = response['error']
print(f"Request was unsuccessful with status {response['status']}")
print(f"Error:
Type: {error['type']}
Message: {error['message']}")