Name + Company -> Email
Name + School -> Email
LinkedIn URL -> Email
LinkedIn URL-> Phone Number
Email->Phone Number
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 find emails and phone numbers for my list of candidates with linkedin profiles
"""
import requests, json
import pandas as pd
API_KEY = "####" # Enter your api key here
PDL_URL = "https://api.peopledatalabs.com/v5/person/enrich"
# Load in existing candidates (containing linkedin profiles)
existing_candidates_list = "my_existing_candidates.csv" # Enter path to your candidates csv file here
existing_candidates = pd.read_csv(existing_candidates_list, header=0)
# Send an enrichment request for each the profiles in our existing candidates list
enriched_candidates = []
num_successful_responses = 0
for idx, existing_profile in existing_candidates.iterrows():
# Set Person Enrichment API parameters
# We want to find emails or phone numbers given a linkedin profile
params = {
"api_key": API_KEY,
"profile": [ existing_profile['linkedin_url'] ], # e.g. "linkedin.com/in/seanthorne"
"required": "emails OR phone_numbers" # requirement for successful match
}
# Send a single API request
api_response = requests.get(PDL_URL, params=params).json()
# Parse the enrichment from the response
if api_response['status'] == 200:
# enriched_profile is a single profile object
# Successful matches are guaranteed to contain phone numbers and emails
# See the full schema for all available fields at: https://docs.peopledatalabs.com/docs/fields
enriched_profile = api_response['data']
num_successful_responses += 1
elif api_response['status'] == 404:
# If no profile match is found then, response will have a 404 status
enriched_profile = {}
else:
# Print if we get some other error
error = api_response['error']
print(f"Request was unsuccessful with status {api_response['status']}")
print(f"Error:
Type: {error['type']}
Message: {error['message']}")
enriched_profile = {}
enriched_candidates.append(enriched_profile)
# Print Summary:
print(f"Total Number of Responses Received {len(enriched_candidates)}")
print(f"Number of Successful Matches: {num_successful_responses}")
# Write enrichment results to csv
enriched_candidates_dataframe = pd.DataFrame(enriched_candidates)
enriched_candidates_dataframe.to_csv("my_enriched_candidates.csv", index=False)