Address
Phone
Email Address
Social Profiles
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
67
68
69
70
71
72
73
74
75
"""
I want to find employment history and social profiles for people in my existing list of identities (containing name, email and current address)
"""
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 identities (containing names, emails, and current addresses)
existing_identities_list = "my_existing_identities.csv" # Enter path to your identities csv file here
existing_identities = pd.read_csv(existing_identities_list, header=0)
# Send an enrichment request for each the profiles in our existing identities list
enriched_identities = []
num_successful_responses = 0
for idx, existing_profile in existing_identities.iterrows():
# Set Person Enrichment API parameters
# We want to find work experience and profiles given a name, email and address
params = {
"api_key": API_KEY,
"first_name": [ existing_profile['first_name'] ], # e.g. Jennifer
"last_name": [ existing_profile['last_name'] ], # e.g. Jackson
"email": [ existing_profile['email'] ], # e.g. sean@peopledatalabs.com
"street_address" : [ existing_profile['street_address'] ], # e.g. 1234 Main Street
"locality": [ existing_profile['city'] ], # e.g. Boise
"region": [ existing_profile['state'] ], # e.g. Idaho
"postal_code": [ existing_profile['zip_code'] ], # e.g. 83701
"required": "experience AND profiles" # 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 work experience and social profiles
# 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_identities.append(enriched_profile)
# Print Summary:
print(f"Total Number of Responses Received {len(enriched_identities)}")
print(f"Number of Successful Matches: {num_successful_responses}")
# Write enrichment results to csv
enriched_identities_dataframe = pd.DataFrame(enriched_identities)
enriched_identities_dataframe.to_csv("my_enriched_identities.csv", index=False)