Examples - Sandbox APIs
Code examples and walkthroughs using the Sandbox APIs
Code samples are provided in Python.
See a Bug? Want To See a Specific Example?
Feel free to use the
Suggest Edits
button in the top right-hand corner of this page to point out any bugs or request any specific code examples for these API endpoints that you'd like to see here.
Sandbox Person Enrichment API
To use the Sandbox Person Enrichment API, set https://sandbox.api.peopledatalabs.com/v5/person/enrich
as the URL and then use the Person Enrichment API as usual.
After changing the URL as described, you can follow any of the examples for the Person Enrichment API. However, since the Sandbox APIs only use the Sandbox Dataset, you will only be able to successfully enrich the profiles from that dataset. For instance, here is how to perform enrichment on an email address from the Sandbox Dataset following the Email example:
LinkedIn URL
import requests, json
API_KEY = # YOUR API KEY
pdl_url = "https://sandbox.api.peopledatalabs.com/v5/person/enrich" # Sandbox Person Enrichment API
# pdl_url = "https://api.peopledatalabs.com/v5/person/enrich" # Production Person Enrichment API
params = {
"api_key": API_KEY,
"email": ["[email protected]"],
"min_likelihood": 6
}
json_response = requests.get(pdl_url, params=params).json()
if json_response["status"] == 200:
record = json_response['data']
print(
record['work_email'],
record['full_name'],
record['job_title'],
record['job_company_name']
)
print(f"successfully enriched profile with pdl data")
# Save enrichment data to json file
with open("my_pdl_enrichment.jsonl", "w") as out:
out.write(json.dumps(record) + "\n")
else:
print("Enrichment unsuccessful. See error and try again.")
print("error:", json_response)
See Examples - Person Enrichment API for additonal examples.
Sandbox Person Search API
To use the Sandbox Person Search API, set https://sandbox.api.peopledatalabs.com/v5/person/search
as the URL and then use the Person Search API as usual.
After changing the URL as described, you can follow any of the examples for the Person Search API. For instance, here is how to perform a simple query following the Basic Usage example:
Basic Usage
import requests, json
API_KEY = # YOUR API KEY
PDL_URL = "https://sandbox.api.peopledatalabs.com/v5/person/search" # Sandbox Person Search API
# PDL_URL = "https://api.peopledatalabs.com/v5/person/search" # Production Person Search API
HEADERS = {
'Content-Type': "application/json",
'X-api-key': API_KEY
}
ES_QUERY = {
"query": {
"bool": {
"must": [
{"term": {"location_country": "mexico"}},
{"exists": {"field": "emails"}}
]
}
}
}
PARAMS = {
'query': json.dumps(ES_QUERY),
'size': 10,
'pretty': True
}
response = requests.get(
PDL_URL,
headers=HEADERS,
params=PARAMS
).json()
if response["status"] == 200:
data = response['data']
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)
See Examples - Person Search API for additional examples.
Sandbox Person Identify API
To use the Sandbox Person Identify API, set https://sandbox.api.peopledatalabs.com/v5/person/identify
as the URL and then use the Person Identify API as usual.
By changing the URL as described, you can follow any of the examples for the Person Identify API. However, since the Sandbox APIs only use the Sandbox Dataset, you will only be able to successfully match the profiles from that dataset. For instance, here is how to perform a query following the Basic Usage example:
Basic Usage
import requests
API_KEY = "ENTER YOUR API KEY"
PDL_URL = "https://sandbox.api.peopledatalabs.com/v5/person/identify" # Sandbox Identify API
# PDL_URL = "https://api.peopledatalabs.com/v5/person/identify" # Production Identify API
PARAMS = {
"company": "walmart",
"pretty": True,
"api_key": API_KEY
}
response = requests.request("GET", PDL_URL, params=PARAMS)
print(response.text)
response_data = response.json()
matches = response_data['matches']
print(f"Found {len(matches)} matches")
See Examples - Person Identify API for additional examples.
Updated 6 days ago