Examples - Autocomplete API

Illustrative examples for the Autocomplete API

On this page, you'll find a collection of running code examples that illustrate various aspects of Autocomplete API functionality.

Examples here are shown using Python3, cURL, Ruby, and JavaScript.

Company Autocomplete Example

Give me 10 suggestions for companies starting with "ama".

import json

# See https://github.com/peopledatalabs/peopledatalabs-python
from peopledatalabs import PDLPY

# Create a client, specifying an API key
client = PDLPY(
    api_key="YOUR API KEY",
)

params = {
    "field": "company",
    "text": "ama",
    "pretty": True
}

json_response = client.autocomplete(**params).json()

print(json_response)
curl -X GET -G \
  'https://api.peopledatalabs.com/v5/autocomplete'\
  -H 'X-Api-Key: xxxx' \
  --data-urlencode 'field=company'\
  --data-urlencode 'text=ama'
// See https://github.com/peopledatalabs/peopledatalabs-js
import PDLJS from 'peopledatalabs';

const PDLJSClient = new PDLJS({ apiKey: "YOUR API KEY" });

const params = {
    "field": "company",
    "text": "ama",
    "pretty": true
}

PDLJSClient.autocomplete(params).then((data) => {
    console.log(data);
}).catch((error) => {
    console.log(error);
});
# See https://github.com/peopledatalabs/peopledatalabs-ruby
require 'peopledatalabs'

Peopledatalabs.api_key = 'YOUR API KEY'

response = Peopledatalabs::Autocomplete.retrieve(field: "company", text: "ama", pretty: true)

puts response
import requests, json

API_KEY = # ENTER YOUR API KEY

pdl_url = "https://api.peopledatalabs.com/v5/autocomplete"

params = {
    "api_key": API_KEY,
    "field": "company",
    "text": "ama",
    "pretty": True
}

json_response = requests.get(pdl_url,  params=params).json()
print(json_response)

Job Title Autocomplete Example

*Give me 20 suggestions for job titles starting with the prefix "data".

import json

# See https://github.com/peopledatalabs/peopledatalabs-python
from peopledatalabs import PDLPY

# Create a client, specifying an API key
client = PDLPY(
    api_key="YOUR API KEY",
)

params = {
    "field": "title",
    "text": "data",
    "size": 20,
    "pretty": True
}

json_response = client.autocomplete(**params).json()

print(json_response)
curl -X GET -G \
  'https://api.peopledatalabs.com/v5/autocomplete'\
  -H 'X-Api-Key: xxxx' \
  --data-urlencode 'field=title'\
  --data-urlencode 'text=data'\
  --data-urlencode 'size=20'
// See https://github.com/peopledatalabs/peopledatalabs-js
import PDLJS from 'peopledatalabs';

const PDLJSClient = new PDLJS({ apiKey: "YOUR API KEY" });

const params = {
    "field": "title",
    "text": "data",
    "size": 20,
    "pretty": true
}

PDLJSClient.autocomplete(params).then((data) => {
    console.log(data);
}).catch((error) => {
    console.log(error);
});
# See https://github.com/peopledatalabs/peopledatalabs-ruby
require 'peopledatalabs'

Peopledatalabs.api_key = 'YOUR API KEY'

response = Peopledatalabs::Autocomplete.retrieve(field: "title", text: "data", size: 20, pretty: true)

puts response
import requests, json

API_KEY = # ENTER YOUR API KEY

pdl_url = "https://api.peopledatalabs.com/v5/autocomplete"

params = {
    "api_key": API_KEY,
    "field": "title",
    "text": "data",
    "size": 20,
    "pretty": True
}

json_response = requests.get(pdl_url,  params=params).json()
print(json_response)

Did this page help you?