Let’s say that you are interested in getting all schools that begin with “harv.” The Autocomplete API is the perfect tool for doing this, as it allows you to find multiple schools using a small set of input characteristics.The list of supported inputs includes the field that you’re seeking and the text that you want to complete. In this example, we’ll use the following parameters:Input Parameters
Using this information, you can now query the Autocomplete API to find schools beginning with “harv”:
import json# See https://github.com/peopledatalabs/peopledatalabs-pythonfrom peopledatalabs import PDLPY# Create a client, specifying your API keyCLIENT = PDLPY( api_key="YOUR API KEY",)# Create a parameters JSON objectPARAMS = { "field": "school", "text": "harv", "size": 10, "titlecase": True, "pretty": True}# Pass the parameters object to the Autocomplete APIjson_response = CLIENT.autocomplete(**PARAMS).json()# Print the API response in JSON formatprint(json_response)
// See https://github.com/peopledatalabs/peopledatalabs-jsimport PDLJS from 'peopledatalabs';// Create a client, specifying your API keyconst PDLJSClient = new PDLJS({ apiKey: "YOUR API KEY" });// Create a parameters JSON objectconst params = { "field": "school", "text": "harv", "size": 10, "titlecase"; true, "pretty": true}// Pass the parameters object to the Autocomplete APIPDLJSClient.autocomplete(params).then((data) => { // Print the API response in JSON format console.log(data);}).catch((error) => { console.log(error);});
# See https://github.com/peopledatalabs/peopledatalabs-rubyrequire 'peopledatalabs'# Set your API keyPeopledatalabs.api_key = 'YOUR API KEY'# Pass parameters to the Autocomplete APIjson_response = Peopledatalabs::Autocomplete.retrieve(field: "school", text: "harv", size: 10, titlecase: true, pretty: true)# Print the API response in JSON formatputs JSON.dump(json_response)
package mainimport ( "fmt" "encoding/json" "context")// See https://github.com/peopledatalabs/peopledatalabs-goimport ( pdl "github.com/peopledatalabs/peopledatalabs-go" pdlmodel "github.com/peopledatalabs/peopledatalabs-go/model")func main() { // Set your API key apiKey := "YOUR API KEY" // Set API key as environmental variable // apiKey := os.Getenv("API_KEY") // Create a client, specifying your API key client := pdl.New(apiKey) // Create a parameters JSON object params := pdlmodel.AutocompleteParams { BaseParams: pdlmodel.BaseParams { Size: 10, Titlecase: true Pretty: true, }, AutocompleteBaseParams: pdlmodel.AutocompleteBaseParams { Field: "school", Text: "harv", }, AdditionalParams: pdlmodel.AdditionalParams { TitleCase: true, }, } // Pass the parameters object to the Autocomplete API response, err := client.Autocomplete(context.Background(), params) // Check for successful response if err == nil { // Convert the API response to JSON jsonResponse, jsonErr := json.Marshal(response) // Print the API response if (jsonErr == nil) { fmt.Println(string(jsonResponse)) } }}
import requests, json# Set your API keyAPI_KEY = "YOUR API KEY"# Set the Autocomplete API URLPDL_URL = "https://api.peopledatalabs.com/v5/autocomplete"# Create a parameters JSON objectPARAMS = { "api_key": API_KEY, "field": "school", "text": "harv", "size": 10, "titlecase": True, "pretty": True}# Pass the parameters object to the Autocomplete APIjson_response = requests.get(PDL_URL, params=PARAMS).json()# Print the API response in JSON formatprint(json_response)