Package: peopledatalabs
People Data Labs Python ClientOfficial Python client for the People Data Labs API.Table of Contents🔧 Installation🚀 Usage🏝 Sandbox Usage🌐 Endpoints📘 DocumentationUpgrading to v2.X.XUpgrading to v3.X.X🔧 InstallationInstall from PyPi usingpip, a package manager for Python.pipinstallpeopledatalabsSign up for afree PDL API key.Set your API key in thePDL_API_KEYenvironment variable.🚀 UsageFirst, create the PDLPY client:frompeopledatalabsimportPDLPY# specifying an API keyclient=PDLPY(api_key="YOUR API KEY",)# or leave blank if you have PDL_API_KEY set in your environment or .env fileclient=PDLPY()Note:You can provide your API key directly in code, or alternatively set aPDL_API_KEYvariable in your environment or.envfile.Then, send requests to any PDL API Endpoint.Getting Person DataBy Enrichmentresult=client.person.enrichment(phone="4155688415",pretty=True,)ifresult.ok:print(result.text)else:print(f"Status:{result.status_code};"f"\nReason:{result.reason};"f"\nMessage:{result.json()['error']['message']};")By Bulk Enrichmentresult=client.person.bulk(required="emails AND profiles",requests=[{"metadata":{"user_id":"123"},"params":{"profile":["linkedin.com/in/seanthorne"],"location":["SF Bay Area"],"name":["Sean F. Thorne"],}},{"metadata":{"user_id":"345"},"params":{"profile":["https://www.linkedin.com/in/haydenconrad/"],"first_name":"Hayden","last_name":"Conrad",}}])ifresult.ok:print(result.text)else:print(f"Status:{result.status_code}"f"\nReason:{result.reason}"f"\nMessage:{result.json()['error']['message']}")By Search (Elasticsearch)es_query={"query":{"bool":{"must":[{"term":{"location_country":"mexico"}},{"term":{"job_title_role":"health"}},]}}}data={"query":es_query,"size":10,"pretty":True,"dataset":"phone, mobile_phone",}result=client.person.search(**data)ifresult.ok:print(result.text)else:print(f"Status:{result.status_code}"f"\nReason:{result.reason}"f"\nMessage:{result.json()['error']['message']}")By Search (SQL)sql_query=("SELECT * FROM person"" WHERE location_country='mexico'"" AND job_title_role='health'"" AND phone_numbers IS NOT NULL;")data={"sql":sql_query,"size":10,"pretty":True,"dataset":"phone, mobile_phone",}result=client.person.search(**data)ifresult.ok:print(result.text)else:print(f"Status:{result.status_code}"f"\nReason:{result.reason}"f"\nMessage:{result.json()['error']['message']}")ByPDL_ID(Retrieve API)result=client.person.retrieve(person_id="qEnOZ5Oh0poWnQ1luFBfVw_0000",)ifresult.ok:print(result.text)else:print(f"Status:{result.status_code}"f"\nReason:{result.reason}"f"\nMessage:{result.json()['error']['message']}")By Fuzzy Enrichment (Identify API)result=client.person.enrichment(name="sean thorne",pretty=True,)ifresult.ok:print(result.text)else:print(f"Status:{result.status_code}"f"\nReason:{result.reason}"f"\nMessage:{result.json()['error']['message']}")Getting Company DataBy Enrichmentresult=client.company.enrichment(website="peopledatalabs.com",pretty=True,)ifresult.ok:print(result.text)else:print(f"Status:{result.status_code}"f"\nReason:{result.reason}"f"\nMessage:{result.json()['error']['message']}")By Bulk Enrichmentresult=client.company.bulk(requests=[{"metadata":{"company_id":"123"},"params":{"profile":"linkedin.com/company/peopledatalabs",}},{"metadata":{"company_id":"345"},"params":{"profile":"https://www.linkedin.com/company/apple/",}}])ifresult.ok:print(result.text)else:print(f"Status:{result.status_code}"f"\nReason:{result.reason}"f"\nMessage:{result.json()['error']['message']}")By Search (Elasticsearch)es_query={"query":{"bool":{"must":[{"term":{"tags":"big data"}},{"term":{"industry":"financial services"}},{"term":{"location.country":"united states"}},]}}}data={"query":es_query,"size":10,"pretty":True,}result=client.company.search(**data)ifresult.ok:print(result.text)else:print(f"Status:{result.status_code}"f"\nReason:{result.reason}"f"\nMessage:{result.json()['error']['message']}")By Search (SQL)sql_query=("SELECT * FROM company"" WHERE tags='big data'"" AND industry='financial services'"" AND location.country='united states';")data={"sql":sql_query,"size":10,"pretty":True,}result=client.company.search(**data)ifresult.ok:print(result.text)else:print(f"Status:{result.status_code}"f"\nReason:{result.reason}"f"\nMessage:{result.json()['error']['message']}")Using supporting APIsGet Autocomplete Suggestionsresult=client.autocomplete(field="title",text="full",size=10,)ifresult.ok:print(result.text)else:print(f"Status:{result.status_code}"f"\nReason:{result.reason}"f"\nMessage:{result.json()['error']['message']}")Clean Raw Company Stringsresult=client.company.cleaner(name="peOple DaTa LabS",)ifresult.ok:print(result.text)else:print(f"Status:{result.status_code}"f"\nReason:{result.reason}"f"\nMessage:{result.json()['error']['message']}")Clean Raw Location Stringsresult=client.location.cleaner(location="455 Market Street, San Francisco, California 94105, US",)ifresult.ok:print(result.text)else:print(f"Status:{result.status_code}"f"\nReason:{result.reason}"f"\nMessage:{result.json()['error']['message']}")Clean Raw School Stringsresult=client.school.cleaner(name="university of oregon",)ifresult.ok:print(result.text)else:print(f"Status:{result.status_code}"f"\nReason:{result.reason}"f"\nMessage:{result.json()['error']['message']}")Get Job Title Enrichmentresult=client.job_title(job_title="data scientist",)ifresult.ok:print(result.text)else:print(f"Status:{result.status_code}"f"\nReason:{result.reason}"f"\nMessage:{result.json()['error']['message']}")Get Skill Enrichmentresult=client.skill(skill="c++",)ifresult.ok:print(result.text)else:print(f"Status:{result.status_code}"f"\nReason:{result.reason}"f"\nMessage:{result.json()['error']['message']}")Get IP Enrichmentresult=client.ip(ip="72.212.42.169",)ifresult.ok:print(result.text)else:print(f"Status:{result.status_code};"f"\nReason:{result.reason};"f"\nMessage:{result.json()['error']['message']};")🏝 Sandbox UsageTo enable sandbox usage, use the sandbox flag on PDLPYPDLPY(sandbox=True)🌐 EndpointsPerson EndpointsAPI EndpointPDLPY FunctionPerson Enrichment APIPDLPY.person.enrichment(**params)Person Bulk Enrichment APIPDLPY.person.bulk(**params)Person Search APIPDLPY.person.search(**params)Person Retrieve APIPDLPY.person.retrieve(**params)Person Identify APIPDLPY.person.identify(**params)Company EndpointsAPI EndpointPDLPY FunctionCompany Enrichment APIPDLPY.company.enrichment(**params)Company Bulk Enrichment APIPDLPY.company.bulk(**params)Company Search APIPDLPY.company.search(**params)Supporting EndpointsAPI EndpointPDLJS FunctionAutocomplete APIPDLPY.autocomplete(**params)Company Cleaner APIPDLPY.company.cleaner(**params)Location Cleaner APIPDLPY.location.cleaner(**params)School Cleaner APIPDLPY.school.cleaner(**params)Job Title Enrichment APIPDLPY.job_title(**params)Skill Enrichment APIPDLPY.skill(**params)IP Enrichment APIPDLPY.ip(**params)📘 DocumentationAll of our API endpoints are documented at:https://docs.peopledatalabs.com/These docs describe the supported input parameters, output responses and also provide additional technical context.As illustrated in theEndpointssection above, each of our API endpoints is mapped to a specific method in the PDLPY class.  For each of these class methods,all function inputs are mapped as input parameters to the respective API endpoint, meaning that you can use the API documentation linked above to determine the input parameters for each endpoint.As an example:The following isvalidbecausenameis asupported input parameter to the Person Identify API:PDLPY().person.identify({"name":"sean thorne"})Conversely, this would beinvalidbecausefake_parameteris not an input parameter to the Person Identify API:PDLPY().person.identify({"fake_parameter":"anything"})Upgrading to v2.X.XNOTE: When upgrading to v2.X.X from vX.X.X and below, the minimum required python version is now 3.8.Upgrading to v3.X.XNOTE: When upgrading to v3.X.X from vX.X.X and below, the minimum required pydantic version is now 2.