Examples - Skill Enrichment API

Code examples and walkthroughs using the Skill 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 skill that I have."

import requests

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

query_string = {"skill": "pyspark"}

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/skill/enrich' \
  -H 'X-Api-Key: YOUR API KEY' \
  --data-urlencode 'skill=pyspark'

Person Searching Using Skill Data

"I want to search for people with similar skills."

import requests, json

API_KEY = # YOUR API KEY

PDL_SKILL_ENRICH_URL = "https://api.peopledatalabs.com/v5/skill/enrich"
PDL_PERSON_SEARCH_URL = "https://api.peopledatalabs.com/v5/person/search"

MAX_NUM_PEOPLE = 100

# Skill Enrichment
skill = "ai"
query_string = {"skill": skill}

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

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

if response.status_code == 200:
  enriched_skill = response.json()
  # Build list of skills
  skills = enriched_skill["data"]["similar_skills"]
  skills.insert(0, skill)
else:
  enriched_job_title = {}
  print(f"Skill Enrichment Error for [{skill}]: {response.text}")
                                                      
# Person Search
employee_matches = {}

if enriched_skill:
  ES_QUERY = {
    "query": {
        "bool": {
            "must": [
                {"term": {"location_region": "utah"}},
                {"terms": {"skills": skills}},
            ]
        }
    }
  }

  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 [{skill}]: {response.text}")

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

API_KEY = # YOUR API KEY

PDL_SKILL_ENRICH_URL = "https://api.peopledatalabs.com/v5/skill/enrich"
PDL_PERSON_SEARCH_URL = "https://api.peopledatalabs.com/v5/person/search"

MAX_NUM_PEOPLE = 100

# Skill Enrichment
skill = "ai"
query_string = {"skill": skill}

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

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

if response.status_code == 200:
  enriched_skill = response.json()
  # Build list of skills
  skills = enriched_skill["data"]["similar_skills"]
  skills.insert(0, skill)
  skills_string_rep = ", ".join(
    (f"'{skl}'" for skl in skills)
  )

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

if enriched_skill:
  SQL_QUERY = f"""
  SELECT * FROM person
  WHERE location_region='utah'
  AND skills IN ({skills_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 [{skill}]: {response.text}")

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

Did this page help you?