Examples - Job Title Enrichment API

Code examples and walkthroughs using the Job Title Enrichment API

Code samples are provided in Python and cURL. If you aren't comfortable working in any of these languages, feel free to use this handy tool to convert from cURL to the language of your choice.

📘

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 this API endpoint that you'd like to see here.

Basic Usage

"I want to look up information for a job title that I have."

import requests

url = "https://api.peopledatalabs.com/v5/job_title/enrich"

query_string = {"job_title": "pastry chef"}

headers = {
    'accept': "application/json",
    'content-type': "application/json",
    'x-api-key': "YOUR_API_KEY"
    }

response = requests.request("GET", url, headers=headers, params=query_string)

print(response.text)
curl -X GET -G \
  'https://api.peopledatalabs.com/v5/job_title/enrich' \
  -H 'X-Api-Key: YOUR API KEY' \
  --data-urlencode 'job_title=pastry chef'

Person Searching Using Job Title Data

"I want to search for people with similar job titles."

import requests, json

API_KEY = # YOUR API KEY

PDL_JOB_TITLE_ENRICH_URL = "https://api.peopledatalabs.com/v5/job_title/enrich"
PDL_PERSON_SEARCH_URL = "https://api.peopledatalabs.com/v5/person/search"

MAX_NUM_PEOPLE = 100

# Job Title Enrichment
job_title = "supply manager"
query_string = {"job_title": job_title}

headers = {
  'accept': "application/json",
  'content-type': "application/json",
  'x-api-key': API_KEY
}

response = requests.request("GET", PDL_JOB_TITLE_ENRICH_URL, 
                            headers=headers, params=query_string)

if response.status_code == 200:
  enriched_job_title = response.json()
  # Build list of job titles
  job_titles = enriched_job_title["data"]["similar_job_titles"]
  job_titles.insert(0, job_title)
else:
  enriched_job_title = {}
  print(f"Job Title Enrichment Error for [{job_title}]: {response.text}")
                                                      
# Person Search
employee_matches = {}

if enriched_job_title:
  ES_QUERY = {
    "query": {
        "bool": {
            "must": [
                {"term": {"location_metro": "detroit, michigan"}},
                {'term': {'industry': "automotive"}},
                {"terms": {"job_title": job_titles}},
            ]
        }
    }
  }

  PARAMS = {
    'query': json.dumps(ES_QUERY),
    'size': MAX_NUM_PEOPLE
  }

  response = requests.get(PDL_PERSON_SEARCH_URL, headers=headers, params=PARAMS)

  if response.status_code == 200:
    employee_matches = response.json()["data"]
  else:
    employee_matches = {}
    print(f"Person Search Error for [{job_title}]: {response.text}")

  print(f"Found {len(employee_matches)} employee profiles for {job_title}")
import requests, json

API_KEY = # YOUR API KEY

PDL_JOB_TITLE_ENRICH_URL = "https://api.peopledatalabs.com/v5/job_title/enrich"
PDL_PERSON_SEARCH_URL = "https://api.peopledatalabs.com/v5/person/search"

MAX_NUM_PEOPLE = 100

# Job Title Enrichment
job_title = "supply manager"
query_string = {"job_title": job_title}

headers = {
  'accept': "application/json",
  'content-type': "application/json",
  'x-api-key': API_KEY
}

response = requests.request("GET", PDL_JOB_TITLE_ENRICH_URL, 
                            headers=headers, params=query_string)

if response.status_code == 200:
  enriched_job_title = response.json()
  # Build list of job titles
  job_titles = enriched_job_title["data"]["similar_job_titles"]
  job_titles.insert(0, job_title)
  job_titles_string_rep = ", ".join(
    (f"'{title}'" for title in job_titles)
  )

else:
  enriched_job_title = {}
  print(f"Job Title Enrichment Error for [{job_title}]: {response.text}")
                                                      
# Person Search
employee_matches = {}

if enriched_job_title:
  SQL_QUERY = f"""
  SELECT * FROM person
  WHERE location_metro='detroit, michigan'
  AND industry = 'automotive'
  AND job_title IN ({job_titles_string_rep});
  """
    
  PARAMS = {
    'sql': SQL_QUERY,
    'size': MAX_NUM_PEOPLE
  }

  response = requests.get(PDL_PERSON_SEARCH_URL, headers=headers, params=PARAMS)

  if response.status_code == 200:
    employee_matches = response.json()["data"]
  else:
    employee_matches = {}
    print(f"Person Search Error for [{job_title}]: {response.text}")

  print(f"Found {len(employee_matches)} employee profiles for {job_title}")

Did this page help you?