### Autocomplete API GET Request using Go Source: https://docs.peopledatalabs.com/docs/examples-autocomplete-api Illustrates how to use the peopledatalabs-go SDK to make an Autocomplete API GET request. This example shows client initialization, parameter construction, and handling the API response, including JSON marshaling. ```go package main import ( "fmt" "encoding/json" "context" ) // See https://github.com/peopledatalabs/peopledatalabs-go import ( 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: 20, Pretty: true, }, AutocompleteBaseParams: pdlmodel.AutocompleteBaseParams { Field: "title", Text: "data", }, } // 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)) } } } ``` -------------------------------- ### Embed Loom Setup Video Source: https://docs.peopledatalabs.com/docs/salesforce-integration-setup-installation-configuration Embeds a Loom video for a visual walkthrough of the Salesforce setup process. This is an optional resource for users who prefer video tutorials. ```html
``` -------------------------------- ### GET /v5/person/identify Source: https://docs.peopledatalabs.com/docs/quickstart-person-identify-api This endpoint accepts person-related parameters to search the database and return a list of matching profiles. ```APIDOC ## GET /v5/person/identify ### Description Matches input person data against the People Data Labs dataset to return potential profile matches. ### Method GET ### Endpoint https://api.peopledatalabs.com/v5/person/identify ### Parameters #### Query Parameters - **api_key** (string) - Required - Your API authentication key. - **first_name** (string) - Optional - The first name of the person. - **last_name** (string) - Optional - The last name of the person. - **company** (string) - Optional - The company name associated with the person. - **pretty** (boolean) - Optional - Whether to return formatted JSON. ### Request Example { "first_name": "sean", "last_name": "thorne", "company": "people data labs", "pretty": true } ### Response #### Success Response (200) - **status** (integer) - The HTTP status code. - **matches** (array) - A list of matching profile objects sorted by match strength. #### Response Example { "status": 200, "matches": [ { "data": {}, "match_score": 92, "matched_on": ["company", "name"] } ] } ``` -------------------------------- ### Identify Person Profiles via API Source: https://docs.peopledatalabs.com/docs/quickstart-person-identify-api Demonstrates how to query the Person Identify API using various programming languages. The examples show client initialization, parameter configuration, and handling the API response. ```python import json from peopledatalabs import PDLPY CLIENT = PDLPY(api_key="YOUR API KEY") PARAMS = { "first_name": "sean", "last_name": "thorne", "company": "people data labs", "pretty": True } response_data = CLIENT.person.identify(**PARAMS).json() if response_data["status"] == 200: identities = response_data['matches'] print(identities) print(f"Found {len(identities)} identities!") else: print("Identify unsuccessful. See error and try again.") print("error:", response_data) ``` ```shell API_KEY="ENTER YOUR API KEY HERE" curl -X GET -G \ "https://api.peopledatalabs.com/v5/person/identify"\ -H "X-Api-Key: ${API_KEY}" \ --data-urlencode 'first_name=sean'\ --data-urlencode 'last_name=thorne'\ --data-urlencode 'company="people data labs"'\ --data-urlencode 'pretty=True' ``` ```javascript import PDLJS from 'peopledatalabs'; const PDLJSClient = new PDLJS({ apiKey: "YOUR API KEY" }); const params = { first_name: "sean", last_name: "thorne", company: "people data labs", pretty: true, } PDLJSClient.person.identify(params).then((data) => { var identities = data["matches"] console.log(identities); console.log(`Found ${identities.length} identities!`) }).catch((error) => { console.log("Identify unsuccessful. See error and try again."); console.log(error); }); ``` ```ruby require 'peopledatalabs' Peopledatalabs.api_key = 'YOUR API KEY' PARAMS = { "first_name": "sean", "last_name": "thorne", "company": "people data labs", "pretty": true } response = Peopledatalabs::Identify.person(params: PARAMS) ``` -------------------------------- ### GET /v5/person/identify Source: https://docs.peopledatalabs.com/docs/quickstart-person-identify-api Finds profiles associated with specific input characteristics like first name, last name, and company. ```APIDOC ## GET /v5/person/identify ### Description Use this endpoint to identify and retrieve person profiles based on provided input parameters such as name, company, or email. ### Method GET ### Endpoint https://api.peopledatalabs.com/v5/person/identify ### Parameters #### Query Parameters - **first_name** (string) - Optional - The first name of the person. - **last_name** (string) - Optional - The last name of the person. - **company** (string) - Optional - The company name associated with the person. - **pretty** (boolean) - Optional - If true, returns the JSON response in a pretty-printed format. ### Request Example ``` curl -X GET -G \ "https://api.peopledatalabs.com/v5/person/identify"\ -H "X-Api-Key: YOUR_API_KEY" \ --data-urlencode 'first_name=sean'\ --data-urlencode 'last_name=thorne'\ --data-urlencode 'company="people data labs"'\ --data-urlencode 'pretty=True' ``` ### Response #### Success Response (200) - **matches** (array) - A list of identified person profiles. - **status** (integer) - The HTTP status code. #### Response Example { "status": 200, "matches": [ { "id": "q-12345", "first_name": "sean", "last_name": "thorne", "job_company_name": "people data labs" } ] } ``` -------------------------------- ### Autocomplete API GET Request using Python Source: https://docs.peopledatalabs.com/docs/examples-autocomplete-api Demonstrates making an Autocomplete API request using Python's 'requests' library. This example sets the API key and parameters, then sends a GET request to the API and prints the JSON response. ```python import requests, json # Set your API key API_KEY = "YOUR API KEY" # Set the Autocomplete API URL PDL_URL = "https://api.peopledatalabs.com/v5/autocomplete" # Create a parameters JSON object PARAMS = { "api_key": API_KEY, "field": "title", "text": "data", "size": 20, "pretty": True } # Pass the parameters object to the Autocomplete API json_response = requests.get(PDL_URL, params=PARAMS).json() # Print the API response in JSON format print(json_response) ``` -------------------------------- ### GET /v5/autocomplete Source: https://docs.peopledatalabs.com/docs/autocomplete-api-quickstart Retrieves auto-completed suggestions based on a specified field and partial text input. ```APIDOC ## GET /v5/autocomplete ### Description The Autocomplete API allows you to find multiple entities (such as schools, job titles, or locations) that begin with a specific string of text. ### Method GET ### Endpoint https://api.peopledatalabs.com/v5/autocomplete ### Parameters #### Query Parameters - **field** (string) - Required - The field to search (e.g., "school", "job_title", "location"). - **text** (string) - Required - The partial text to complete. - **size** (integer) - Optional - The number of results to return (default: 10). - **titlecase** (boolean) - Optional - Whether to return results in title case. - **pretty** (boolean) - Optional - Whether to return pretty-printed JSON. ### Request Example GET https://api.peopledatalabs.com/v5/autocomplete?field=school&text=harv&size=10&titlecase=true ### Response #### Success Response (200) - **data** (array) - A list of matching entities. #### Response Example { "data": [ "Harvard University", "Harvard Business School", "Harvard Medical School" ] } ``` -------------------------------- ### Query Autocomplete API with Python Source: https://docs.peopledatalabs.com/docs/autocomplete-api-quickstart This snippet uses the requests library to send a GET request to the Autocomplete API endpoint with parameters. It captures the JSON response and prints it to the console for verification. ```python import requests # Pass the parameters object to the Autocomplete API json_response = requests.get(PDL_URL, params=PARAMS).json() # Print the API response in JSON format print(json_response) ``` -------------------------------- ### Initialize Ruby PDL Client Source: https://docs.peopledatalabs.com/docs/examples-person-search-api Basic setup for the People Data Labs Ruby SDK, including API key configuration and library requirements. ```ruby require 'json' require 'peopledatalabs' Peopledatalabs.api_key = 'YOUR API KEY' PAGE_SIZE = 100 ``` -------------------------------- ### Get ASN Domain for IP Address (JSON Example) Source: https://docs.peopledatalabs.com/docs/ip-fields This example demonstrates how to get the domain associated with the ASN block for an IP address. If unknown, it returns null. ```json { "asn_domain": null } ``` -------------------------------- ### Clean Company Data using Cleaner API Source: https://docs.peopledatalabs.com/docs/quickstart-cleaner-apis Demonstrates how to clean company record data by providing a website parameter to the Company Cleaner API. Examples include official SDK implementations for Python, JavaScript, Ruby, and Go, as well as a raw HTTP request approach in Python. ```python from peopledatalabs import PDLPY CLIENT = PDLPY(api_key="YOUR API KEY") QUERY_STRING = {"website":"peopledatalabs.com"} response = CLIENT.company.cleaner(**QUERY_STRING) print(response.text) ``` ```javascript import PDLJS from 'peopledatalabs'; const PDLJSClient = new PDLJS({ apiKey: "YOUR API KEY" }); const queryString = { website: "peopledatalabs.com" }; PDLJSClient.company.cleaner(queryString).then((response) => { console.log(response); }).catch((error) => { console.log(error); }); ``` ```ruby require 'peopledatalabs' Peopledatalabs.api_key = 'YOUR API KEY' response = Peopledatalabs::Cleaner.company(kind: 'website', value: "peopledatalabs.com") puts response ``` ```go import ( "context" "fmt" pdl "github.com/peopledatalabs/peopledatalabs-go" pdlmodel "github.com/peopledatalabs/peopledatalabs-go/model" ) func main() { client := pdl.New("YOUR API KEY") queryString := pdlmodel.CleanCompanyParams{Website: "peopledatalabs.com"} response, err := client.Company.Clean(context.Background(), queryString) if err == nil { fmt.Println(response) } } ``` ```python (requests) import requests API_KEY = "YOUR API KEY" PDL_URL = "https://api.peopledatalabs.com/v5/company/clean" QUERY_STRING = {"website":"peopledatalabs.com"} HEADERS = {'accept': "application/json", 'content-type': "application/json", 'x-api-key': API_KEY} response = requests.request("GET", PDL_URL, headers=HEADERS, params=QUERY_STRING) ``` -------------------------------- ### Enrich Person Data using POST Request in Python Source: https://docs.peopledatalabs.com/docs/examples-person-enrichment-api This Python script shows how to enrich person data using the People Data Labs API with a POST request, suitable for queries with many parameters. It utilizes the `requests` library to send a JSON payload and handles the response similarly to the GET request example. The `requests` library must be installed. ```python import requests, json # Set your API key API_KEY = "YOUR API KEY" # Set the Person Enrichment API URL PDL_URL = "https://api.peopledatalabs.com/v5/person/enrich" # Create a parameters JSON object PAYLOAD = { "api_key": API_KEY, "name": ["Sean Thorne"], "profile": ["www.twitter.com/seanthorne5", "linkedin.com/in/seanthorne"] } # Pass the parameters object to the Person Enrichment API json_response = requests.post(PDL_URL, json=PAYLOAD).json() # Check for successful response if json_response["status"] == 200: record = json_response['data'] # Print selected fields print( record['work_email'], record['full_name'], record['job_title'], record['job_company_name'] ) print(f"Successfully enriched profile with PDL data.") # Save enrichment data to JSON file with open("my_pdl_enrichment.jsonl", "w") as out: out.write(json.dumps(record) + "\n") else: print("Enrichment unsuccessful. See error and try again.") print("error:", json_response) ``` -------------------------------- ### Install People Data Labs Go Helper Library Source: https://docs.peopledatalabs.com/docs/go-sdk Instructions for installing the People Data Labs Go Helper Library using the Go package manager. This command fetches the latest version of the library. ```shell go get github.com/peopledatalabs/peopledatalabs-go ``` -------------------------------- ### Enrich Person Data using GET Request in Python Source: https://docs.peopledatalabs.com/docs/examples-person-enrichment-api This Python script demonstrates how to enrich person data using the People Data Labs API with a GET request. It sets up the API key, URL, and parameters, sends the request using the `requests` library, and processes the JSON response to print selected fields and save the data to a file. Ensure the `requests` library is installed. ```python import requests import json # Set your API key API_KEY = "YOUR API KEY" # Set the Person Enrichment API URL PDL_URL = "https://api.peopledatalabs.com/v5/person/enrich" # Create a parameters JSON object PARAMS = { "api_key": API_KEY, "name": ["Sean Thorne"], "profile": ["www.twitter.com/seanthorne5", "linkedin.com/in/seanthorne"] } # Pass the parameters object to the Person Enrichment API json_response = requests.get(PDL_URL, params=PARAMS).json() # Check for successful response if json_response["status"] == 200: record = json_response['data'] # Print selected fields print( record['work_email'], record['full_name'], record['job_title'], record['job_company_name'] ) print(f"Successfully enriched profile with PDL data.") # Save enrichment data to JSON file with open("my_pdl_enrichment.jsonl", "w") as out: out.write(json.dumps(record) + "\n") else: print("Enrichment unsuccessful. See error and try again.") print("error:", json_response) ``` -------------------------------- ### SDK Usage for Sandbox Source: https://docs.peopledatalabs.com/docs/sandbox-apis-reference Examples demonstrating how to configure various SDKs to use the Sandbox API endpoints. ```APIDOC ## SDK Usage for Sandbox ### Description Examples of how to enable the sandbox environment for different People Data Labs SDKs. ### Python 3 SDK ```python # Set sandbox to True when creating a client CLIENT = PDLPY( api_key="YOUR API KEY", # Use Sandbox API sandbox=True, ) ``` ### JavaScript SDK ```javascript // Set sandbox to true in the parameters JSON object const params = { email: "irussell@example.org", min_likelihood: 6, // Use Sandbox API sandbox: true } ``` ### Ruby SDK ```ruby # Use Sandbox API Peopledatalabs.sandbox = true ``` ### Go SDK ```go // Include extra imports import ( pdl "github.com/peopledatalabs/peopledatalabs-go" "github.com/peopledatalabs/peopledatalabs-go/api" pdlmodel "github.com/peopledatalabs/peopledatalabs-go/model" ) // Set Sandbox to true in ClientOptions() when creating a client client := pdl.New(apiKey, api.ClientOptions(func(c *api.Client) { c.Sandbox = true })) ``` ``` -------------------------------- ### Configure Python3 SDK for Sandbox Source: https://docs.peopledatalabs.com/docs/sandbox-apis-reference Set the sandbox parameter to True during client initialization. ```python # Set sandbox to True when creating a client CLIENT = PDLPY( api_key="YOUR API KEY", # Use Sandbox API sandbox=True, ) ``` -------------------------------- ### Autocomplete API: Find Schools (cURL) Source: https://docs.peopledatalabs.com/docs/autocomplete-api-quickstart This cURL command demonstrates how to query the People Data Labs Autocomplete API directly from the command line. It uses GET request with URL-encoded parameters including 'field', 'text', 'titlecase', and 'size' to find schools starting with 'harv'. An API key is required. ```shell curl -X GET -G \ 'https://api.peopledatalabs.com/v5/autocomplete'\ -H 'X-Api-Key: xxxx' \ --data-urlencode 'field=school'\ --data-urlencode 'text=harv'\ --data-urlencode 'titlecase=true'\ --data-urlencode 'size=10' ``` -------------------------------- ### Identify Person via API Source: https://docs.peopledatalabs.com/docs/quickstart-person-identify-api Demonstrates how to send a request to the Person Identify API with specific search criteria and handle the resulting matches. The code includes error checking and output formatting for the returned identity records. ```Go package main import ( "fmt" "encoding/json" "context" ) import ( pdl "github.com/peopledatalabs/peopledatalabs-go" pdlmodel "github.com/peopledatalabs/peopledatalabs-go/model" ) func main() { apiKey := "YOUR API KEY" client := pdl.New(apiKey) params := pdlmodel.IdentifyPersonParams { BaseParams: pdlmodel.BaseParams { Pretty: true, }, PersonParams: pdlmodel.PersonParams { FirstName: []string{"sean"}, LastName: []string{"thorne"}, Company: []string{"people data labs"}, }, } response, err := client.Person.Identify(context.Background(), params) if err == nil { identities := response.Matches jsonResponse, jsonErr := json.Marshal(identities) if (jsonErr == nil) { fmt.Println(string(jsonResponse)) } fmt.Printf("Found %d identities!\n", len(identities)) } else { fmt.Println("Identify unsuccessful. See error and try again.") fmt.Println("error:", err) } } ``` ```Python import requests API_KEY = "YOUR API KEY" PDL_URL = "https://api.peopledatalabs.com/v5/person/identify" PARAMS = { "first_name": "sean", "last_name": "thorne", "company": "people data labs", "pretty": True, "api_key": API_KEY } json_response = requests.get(PDL_URL, params=PARAMS).json() if json_response['status'] == 200: identities = json_response['matches'] print(identities) print(f"Found {len(identities)} identities!") else: print("Identify unsuccessful. See error and try again.") print("error:", json_response) ``` ```Ruby if json_response['status'] == 200 identities = response['matches'] puts identities puts "Found #{identities.length()} identities!" else puts "Identify unsuccessful. See error and try again." puts "error: #{json_response}" end ``` -------------------------------- ### Enrich Person Data and Save to JSON (Python) Source: https://docs.peopledatalabs.com/docs/examples-person-enrichment-api This Python 3 snippet utilizes the `requests` library to call the People Data Labs Person Enrichment API. It demonstrates how to construct the request parameters, send a GET request, check the response status, print specific fields from the returned data, and write the enriched record to a JSON Lines file. Ensure the `requests` library is installed (`pip install requests`). ```python import requests, json # Set your API key API_KEY = "YOUR API KEY" # Set the Person Enrichment API URL PDL_URL = "https://api.peopledatalabs.com/v5/person/enrich" # Create a parameters JSON object PARAMS = { "api_key": API_KEY, "company": ["TalentIQ Technologies"], "first_name": ["Sean"], "last_name": ["Thorne"], "school": ["University of Oregon"] } # Pass the parameters object to the Person Enrichment API json_response = requests.get(PDL_URL, params=PARAMS).json() # Check for successful response if json_response["status"] == 200: record = json_response['data'] # Print selected fields print( record['work_email'], record['full_name'], record['job_title'], record['job_company_name'] ) print(f"Successfully enriched profile with PDL data.") # Save enrichment data to JSON file with open("my_pdl_enrichment.jsonl", "w") as out: out.write(json.dumps(record) + "\n") else: print("Enrichment unsuccessful. See error and try again.") print("error:", json_response) ``` -------------------------------- ### Search PDL API with Go Source: https://docs.peopledatalabs.com/docs/quickstart-person-search-api Shows how to configure the PDL Go client to perform searches using either Elasticsearch or SQL query syntax and save the output to a file. ```go // Elasticsearch Example client := pdl.New(apiKey) elasticSearchQuery := map[string]interface{} { "query": map[string]interface{} { "bool": map[string]interface{} { "must": []map[string]interface{} { {"term": map[string]interface{}{"location_country": "mexico"}}, {"term": map[string]interface{}{"job_title_role": "health"}}, {"exists": map[string]interface{}{"field": "phone_numbers"}}, }, }, }, } params := pdlmodel.SearchParams { BaseParams: pdlmodel.BaseParams { Size: 10, Pretty: true }, SearchBaseParams: pdlmodel.SearchBaseParams { Query: elasticSearchQuery } } response, err := client.Person.Search(context.Background(), params) ``` ```go // SQL Example client := pdl.New(apiKey) sqlQuery := "SELECT * FROM person WHERE location_country='mexico' AND job_title_role='health' AND phone_numbers IS NOT NULL;" params := pdlmodel.SearchParams { BaseParams: pdlmodel.BaseParams { Size: 10, Pretty: true }, SearchBaseParams: pdlmodel.SearchBaseParams { SQL: sqlQuery } } response, err := client.Person.Search(context.Background(), params) ``` -------------------------------- ### Get Service Name for IP Address (JSON Example) Source: https://docs.peopledatalabs.com/docs/ip-fields This example shows how to retrieve the service name associated with an IP address. If unknown, it returns null. ```json { "service": null } ``` -------------------------------- ### Initialize Company Search API Request in Python Source: https://docs.peopledatalabs.com/docs/quickstart-company-search-api Sets up the initial configuration for a Python-based request to the People Data Labs Company Search API, including API key definition and endpoint URL. ```python import requests, json # Set your API key API_KEY = "YOUR API KEY" # Set the Company Search API URL PDL_URL = "https://api.peopledatalabs.com/v5/company/search" ``` -------------------------------- ### Configure Go SDK for Sandbox Source: https://docs.peopledatalabs.com/docs/sandbox-apis-reference Enable sandbox mode by setting the Sandbox field within the ClientOptions function during client creation. ```go // Include extra imports import ( pdl "github.com/peopledatalabs/peopledatalabs-go" "github.com/peopledatalabs/peopledatalabs-go/api" pdlmodel "github.com/peopledatalabs/peopledatalabs-go/model" ) // Set Sandbox to true in ClientOptions() when creating a client client := pdl.New(apiKey, api.ClientOptions(func(c *api.Client) { c.Sandbox = true })) ``` -------------------------------- ### GET /top_previous_employers_by_role Source: https://docs.peopledatalabs.com/docs/company-fields Retrieves the top previous employers for a company based on employee roles and start dates. ```APIDOC ## GET /top_previous_employers_by_role ### Description Returns the top previous employers for a company, ranked by the number of current employees previously employed there. A previous employer is defined as a company where the employee had a start date before their start date at the queried company. ### Response #### Success Response (200) - **top_previous_employers_by_role** (Object) - A mapping of roles to company IDs and employee counts. #### Response Example { "top_previous_employers_by_role": { "all": { "aKCIYBNF9ey6o5CjHCCO4goHYKlf" : 573, "RjhjJnYUCiAfXFyxCHLDQQ5opPrK" : 498 }, "finance": { "RZOFiRjw26VpLObnwmYXGgRyn3aW" : 294, "BWiTKOBgRTsSttn62R7EBQvww4gF" : 112 } } } ``` -------------------------------- ### GET /v5/autocomplete Source: https://docs.peopledatalabs.com/docs/examples-autocomplete-api Retrieves autocomplete suggestions for a specified field using query parameters. ```APIDOC ## GET /v5/autocomplete ### Description Retrieves autocomplete suggestions for a specified field based on the provided text prefix. ### Method GET ### Endpoint https://api.peopledatalabs.com/v5/autocomplete ### Parameters #### Query Parameters - **field** (string) - Required - The field to autocomplete (e.g., 'title', 'skill'). - **text** (string) - Required - The text prefix to search for. - **size** (integer) - Optional - The number of results to return. - **pretty** (boolean) - Optional - Whether to format the JSON response. ### Request Example curl -X GET -G 'https://api.peopledatalabs.com/v5/autocomplete' -H 'X-Api-Key: your-api-key' --data-urlencode 'field=title' --data-urlencode 'text=data' --data-urlencode 'size=20' ### Response #### Success Response (200) - **data** (array) - List of suggested values. #### Response Example { "data": ["data scientist", "data analyst", "data engineer"] } ``` -------------------------------- ### Perform Preview Search with Elasticsearch and SQL Source: https://docs.peopledatalabs.com/docs/preview-search-api Demonstrates how to query the Preview Search API using either Elasticsearch or SQL syntax. The examples include setting the required API key, constructing the query parameters, and handling the JSON response to save preview data. ```python import requests, json API_KEY = "YOUR PREVIEW SEARCH ENABLED API KEY" PDL_URL = "https://api.peopledatalabs.com/v5/person/search" HEADERS = {"X-Api-Key": API_KEY} # Elasticsearch Query Example ES_QUERY = {"query": {"bool": {"must": [{"term": {"job_company_name": "people data labs"}}]}}} PARAMS = {'query': json.dumps(ES_QUERY), 'size': 10, 'pretty': True} json_response = requests.get(PDL_URL, headers=HEADERS, params=PARAMS).json() if json_response["status"] == 200: with open("my_pdl_search_preview.jsonl", "w") as out: out.write(json.dumps(json_response['data']) + "\n") ``` ```python import requests, json API_KEY = "YOUR PREVIEW SEARCH ENABLED API KEY" PDL_URL = "https://api.peopledatalabs.com/v5/person/search" HEADERS = {"X-Api-Key": API_KEY} # SQL Query Example SQL_QUERY = "SELECT * FROM person WHERE job_company_name='people data labs';" PARAMS = {'query': SQL_QUERY, 'size': 10, 'pretty': True} json_response = requests.get(PDL_URL, headers=HEADERS, params=PARAMS).json() if json_response["status"] == 200: with open("my_pdl_search_preview.jsonl", "w") as out: out.write(json.dumps(json_response['data']) + "\n") ``` ```curl # Elasticsearch curl -X GET 'https://api.peopledatalabs.com/v5/person/search' \ -H 'X-Api-Key: xxxx' \ --data-raw '{"size": 10, "query": {"bool": {"must": [{"term": {"job_company_name": "people data labs"}}]}}}' # SQL curl -X GET \ 'https://api.peopledatalabs.com/v5/person/search' \ -H 'X-Api-Key: xxxx' \ --data-raw '{"size": 10, "sql": "SELECT * FROM person WHERE job_company_name=\'people data labs\';"}' ``` -------------------------------- ### Search Companies using SQL Query (Go) Source: https://docs.peopledatalabs.com/docs/examples-company-search-api This Go program demonstrates how to search for companies using an SQL query with the People Data Labs API. It initializes the PDL client, constructs an SQL query to select companies with the website 'google.com', sets search parameters, and calls the Company Search API. Successful results are written to 'my_pdl_search.jsonl', and response details are printed. Error handling is included. ```go package main import( "fmt" "os" "encoding/json" "context" ) // See https://github.com/peopledatalabs/peopledatalabs-go import ( 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 an SQL query sqlQuery := "SELECT * FROM company" + " WHERE website='google.com';" // Create a parameters JSON object params := pdlmodel.SearchParams { BaseParams: pdlmodel.BaseParams { Size: 10, Pretty: true, }, SearchBaseParams: pdlmodel.SearchBaseParams { SQL: sqlQuery, }, } // Pass the parameters object to the Company Search API response, err := client.Company.Search(context.Background(), params) // Check for successful response if err == nil { data := response.Data // Create file out, outErr := os.Create("my_pdl_search.jsonl") defer out.Close() if (outErr == nil) { for i := range data { // Convert each profile found to JSON record, jsonErr := json.Marshal(data[i]) // Write out each profile to file if (jsonErr == nil) { out.WriteString(string(record) + "\n") } } out.Sync() } fmt.Printf("Successfully grabbed %d records from PDL.\n", len(data)) fmt.Printf("%d total PDL records exist matching this query.\n", response.Total) } else { fmt.Println("NOTE: The carrier pigeons lost motivation in flight. See error and try again.") fmt.Println("Error:", err) } } ``` -------------------------------- ### GET /v5/ip/enrich Source: https://docs.peopledatalabs.com/docs/examples-ip-enrichment-api Enriches a given IP address with associated data such as location and company information. ```APIDOC ## GET /v5/ip/enrich ### Description Retrieves enriched data for a specific IP address, including geographic and organizational details. ### Method GET ### Endpoint https://api.peopledatalabs.com/v5/ip/enrich ### Parameters #### Query Parameters - **ip** (string) - Required - The IP address to enrich. ### Request Example curl -X GET -G \ 'https://api.peopledatalabs.com/v5/ip/enrich'\ -H 'X-Api-Key: YOUR_API_KEY' \ --data-urlencode 'ip=72.212.42.169' ### Response #### Success Response (200) - **data** (object) - The enriched data object containing location and company details. #### Response Example { "status": 200, "data": { "ip": "72.212.42.169", "location": { "metro": "New York" }, "company": { "name": "Example Corp" } } } ``` -------------------------------- ### Search Companies with SQL Query using Go PDL Client Source: https://docs.peopledatalabs.com/docs/examples-company-search-api This Go program demonstrates how to use the People Data Labs Go client to search for companies using an SQL query. It handles API key authentication, sets search parameters including size and SQL query, and paginates through results using a scroll token. Dependencies include 'context', 'encoding/json', 'fmt', 'math', 'os', 'reflect', 'time', and the 'peopledatalabs-go' library. ```go package main import ( "fmt" "time" "os" "math" "reflect" "encoding/json" "encoding/csv" "context" ) // See https://github.com/peopledatalabs/peopledatalabs-go import ( 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) // Limit the number of records to pull (to prevent accidentally using // more credits than expected when testing out this code). const maxNumRecordsLimit = 150 // The maximum number of records to retrieve const useMaxNumRecordsLimit = true // Set to False to pull all available records // Create an SQL query sqlQuery := "SELECT * FROM company" + " WHERE industry = 'automotive'" + " AND location.metro='detroit, michigan';" // Create a parameters JSON object p := pdlmodel.SearchParams { BaseParams: pdlmodel.BaseParams { Size: 50, Pretty: true, }, SearchBaseParams: pdlmodel.SearchBaseParams { SQL: sqlQuery, }, } // Pull all results in multiple batches batch := 1 // Store all records retreived in an array var allRecords []pdlmodel.Company // Time the process startTime := time.Now() foundAllRecords := false continueScrolling := true var numRecordsToRequest int // While still scrolling through data and still records to be found for continueScrolling && !foundAllRecords { // Check if we reached the maximum number of records we want if useMaxNumRecordsLimit { numRecordsToRequest = maxNumRecordsLimit - len(allRecords) // Adjust size parameter p.BaseParams.Size = (int) (math.Max(0.0, math.Min(50.0, (float64) (numRecordsToRequest)))) // Check if MAX_NUM_RECORDS_LIMIT reached if numRecordsToRequest == 0 { fmt.Printf("Stopping - reached maximum number of records to pull " + "[MAX_NUM_RECORDS_LIMIT = %d).\n", maxNumRecordsLimit) break } } // Pass the parameters object to the Company Search API response, err := client.Company.Search(context.Background(), p) // Check for successful response if err == nil { fmt.Printf("Retrieved %d records in batch %d - %d records remaining.\n", len(response.Data), batch, response.Total - len(allRecords)) } else { fmt.Println("Error retrieving some records:\n\t", err) } // Convert response to JSON var data map[string]interface{} jsonResponse, jsonErr := json.Marshal(response) if jsonErr == nil { json.Unmarshal(jsonResponse, &data) // Get scroll_token from response if exists and store it in parameters object if scrollToken, ok := data["scroll_token"]; ok { p.SearchBaseParams.ScrollToken = fmt.Sprintf("%v", scrollToken) } else { continueScrolling = false fmt.Println("Unable to continue scrolling.") } // Add records retrieved to the records array allRecords = append(allRecords, response.Data...) } batch++ foundAllRecords = (len(allRecords) == response.Total) time.Sleep(6 * time.Second) // avoid hitting rate limit thresholds } // Calculate time required to process batches } ``` -------------------------------- ### GET /v5/company/enrich Source: https://docs.peopledatalabs.com/docs/examples-company-enrichment-api Enrich company data by providing a unique PDL ID or a company website domain. ```APIDOC ## GET /v5/company/enrich ### Description Retrieves detailed information about a company using either a PDL ID or a website domain. ### Method GET ### Endpoint https://api.peopledatalabs.com/v5/company/enrich ### Parameters #### Query Parameters - **pdl_id** (string) - Optional - The unique identifier for the company in the PDL database. - **website** (string) - Optional - The company website domain (e.g., google.com). ### Request Example { "pdl_id": "aKCIYBNF9ey6o5CjHCCO4goHYKlf" } ### Response #### Success Response (200) - **data** (object) - The enriched company profile information. #### Response Example { "status": 200, "data": { "name": "Google", "website": "google.com", "industry": "internet" } } ``` -------------------------------- ### Search People via API using Python Source: https://docs.peopledatalabs.com/docs/quickstart-person-search-api Demonstrates how to perform a person search against the PDL API. Includes examples for both Elasticsearch and SQL query formats, handling API responses, and writing results to a JSONL file. ```python import requests, json API_KEY = "YOUR API KEY" PDL_URL = "https://api.peopledatalabs.com/v5/person/search" HEADERS = {'Content-Type': "application/json", 'X-api-key': API_KEY} ES_QUERY = { 'query': { 'bool': { 'must': [ {'term': {'location_country': "mexico"}}, {'term': {'job_title_role': "health"}}, {'exists': {'field': "phone_numbers"}} ] } } } PARAMS = {'query': json.dumps(ES_QUERY), 'size': 10, 'pretty': True} response = requests.get(PDL_URL, headers=HEADERS, params=PARAMS).json() if response["status"] == 200: with open("my_pdl_search.jsonl", "w") as out: for record in response['data']: out.write(json.dumps(record) + "\n") ``` ```python import requests, json API_KEY = "YOUR API KEY" PDL_URL = "https://api.peopledatalabs.com/v5/person/search" HEADERS = {'Content-Type': "application/json", 'X-api-key': API_KEY} SQL_QUERY = "SELECT * FROM person WHERE location_country='mexico' AND job_title_role='health' AND phone_numbers IS NOT NULL;" PARAMS = {'sql': SQL_QUERY, 'size': 10, 'pretty': True} response = requests.get(PDL_URL, headers=HEADERS, params=PARAMS).json() if response["status"] == 200: with open("my_pdl_search.jsonl", "w") as out: for record in response['data']: out.write(json.dumps(record) + "\n") ``` -------------------------------- ### Autocomplete API GET Request using JavaScript Source: https://docs.peopledatalabs.com/docs/examples-autocomplete-api Shows how to use the peopledatalabs-js library to make an Autocomplete API request. This asynchronous example fetches suggestions for the 'title' field. It requires an API key and handles success and error responses. ```javascript // See https://github.com/peopledatalabs/peopledatalabs-js import PDLJS from 'peopledatalabs'; // Create a client, specifying your API key const PDLJSClient = new PDLJS({ apiKey: "YOUR API KEY" }); // Create a parameters JSON object const params = { "field": "title", "text": "data", "size": 20, "pretty": true } // Pass the parameters object to the Autocomplete API PDLJSClient.autocomplete(params).then((data) => { // Print the API response in JSON format console.log(data); }).catch((error) => { console.log(error); }); ``` -------------------------------- ### Search Companies using Elasticsearch and SQL in Go Source: https://docs.peopledatalabs.com/docs/quickstart-company-search-api Demonstrates how to use the official People Data Labs Go SDK to perform company searches. It supports both Elasticsearch query objects and SQL strings, followed by file persistence of the results. ```go // Elasticsearch Example params := pdlmodel.SearchParams { BaseParams: pdlmodel.BaseParams { Size: 10, Pretty: true }, SearchBaseParams: pdlmodel.SearchBaseParams { Query: elasticSearchQuery }, } response, err := client.Company.Search(context.Background(), params) ``` ```go // SQL Example params := pdlmodel.SearchParams { BaseParams: pdlmodel.BaseParams { Size: 10, Pretty: true }, SearchBaseParams: pdlmodel.SearchBaseParams { SQL: sqlQuery }, } response, err := client.Company.Search(context.Background(), params) ``` -------------------------------- ### Enrich Person Data and Save to JSON (Go) Source: https://docs.peopledatalabs.com/docs/examples-person-enrichment-api This Go program demonstrates how to use the People Data Labs Go SDK to enrich person data. It includes setting up the API client, defining enrichment parameters, making the enrichment request, handling potential errors, and saving the successful response data to a JSON Lines file. Ensure you have the SDK installed (`go get github.com/peopledatalabs/peopledatalabs-go`). ```go package main import ( "fmt" "os" "encoding/json" "context" ) // See https://github.com/peopledatalabs/peopledatalabs-go import ( 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.EnrichPersonParams { PersonParams: pdlmodel.PersonParams { Company: []string{"TalentIQ Technologies"}, FirstName: []string{"Sean"}, LastName: []string{"Thorne"}, School: []string{"University of Oregon"}, }, } // Pass the parameters object to the Person Enrichment API response, err := client.Person.Enrich(context.Background(), params) // Check for successful response if err == nil { // Convert the API response to JSON jsonResponse, jsonErr := json.Marshal(response.Data) if jsonErr == nil { var record map[string]interface{} json.Unmarshal(jsonResponse, &record) // Print selected fields fmt.Println( record["work_email"], record["full_name"], record["job_title"], record["job_company_name"]) fmt.Println("Successfully enriched profile with PDL data.") // Save enrichment data to JSON file out, outErr := os.Create("my_pdl_enrichment.jsonl") defer out.Close() if outErr == nil { out.WriteString(string(jsonResponse) + "\n") } out.Sync() } } } else { fmt.Println("Enrichment unsuccessful. See error and try again.") fmt.Println("error:", err) } } ```