Current Job Title
Job Locations
Work History, including past job title and start/end dates
Education History
Location History
Skills
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
"""
I want to get education and employment history for my existing list of customer 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 customers (containing name, email, addresses)
existing_customers_list = "my_existing_customers.csv" # Enter path to your customers csv file here
existing_customers = pd.read_csv(existing_customers_list, header=0)
# Send an enrichment request for each the profiles in our existing customers list
enriched_customers = []
num_successful_responses = 0
for idx, existing_profile in existing_customers.iterrows():
# Set Person Enrichment API parameters
# We want to find education and work experience 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": "education AND experience" # 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 education and work histories
# 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_customers.append(enriched_profile)
# Print Summary:
print(f"Total Number of Responses Received {len(enriched_customers)}")
print(f"Number of Successful Matches: {num_successful_responses}")
# Write enrichment results to csv
enriched_customers_dataframe = pd.DataFrame(enriched_customers)
enriched_customers_dataframe.to_csv("my_enriched_customers.csv", index=False)