### Install People Data Labs Go Client Source: https://github.com/peopledatalabs/peopledatalabs-go/blob/main/README.md Installs the People Data Labs Go SDK using the go get command. Ensure you have Go modules initialized in your project. After installation, sign up for a PDL API key and set it as an environment variable. ```bash go get github.com/peopledatalabs/peopledatalabs-go/v6 ``` -------------------------------- ### Clean Company Data using Go Client Source: https://context7.com/peopledatalabs/peopledatalabs-go/llms.txt Shows how to clean and normalize raw company name strings or website URLs into canonical company records using the PDL Go client. It requires an API key and returns details like canonical name, website, industry, and LinkedIn URL. The example demonstrates cleaning by name and by website. ```go package main import ( "context" "fmt" "os" pdl "github.com/peopledatalabs/peopledatalabs-go/v6" pdlmodel "github.com/peopledatalabs/peopledatalabs-go/v6/model" ) func main() { client := pdl.New(os.Getenv("PDL_API_KEY")) ctx := context.Background() params := pdlmodel.CleanCompanyParams{ Name: "peOple DaTa LabS", } result, err := client.Company.Clean(ctx, params) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Status: %d\n", result.Status) fmt.Printf("Fuzzy Match: %t\n", result.FuzzyMatch) fmt.Printf("Score: %.2f\n", result.Score) fmt.Printf("Canonical Name: %s\n", result.DisplayName) fmt.Printf("Website: %s\n", result.Website) fmt.Printf("Industry: %s\n", result.Industry) fmt.Printf("LinkedIn: %s\n", result.LinkedinUrl) // Clean by website params2 := pdlmodel.CleanCompanyParams{ Website: "apple.com", } result2, err := client.Company.Clean(ctx, params2) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("\nCleaned Website -> %s\n", result2.DisplayName) } ``` -------------------------------- ### Get Autocomplete Suggestions (Go) Source: https://github.com/peopledatalabs/peopledatalabs-go/blob/main/README.md Retrieves autocomplete suggestions for a given field and text input. Useful for implementing typeahead search functionalities. Requires specifying size, field, and text. ```go params := pdlmodel.AutocompleteParams{ BaseParams: pdlmodel.BaseParams{Size: 10}, AutocompleteBaseParams: pdlmodel.AutocompleteBaseParams{Field: "title", Text: "full"}, } result, err := client.Autocomplete(ctx, params) ``` -------------------------------- ### Autocomplete API Source: https://github.com/peopledatalabs/peopledatalabs-go/blob/main/README.md Get autocomplete suggestions for a given field and text input. ```APIDOC ## Autocomplete API ### Description Provides autocomplete suggestions based on a field and partial text input. ### Method GET ### Endpoint /autocomplete ### Parameters #### Query Parameters - **field** (string) - Required - The field to get suggestions for (e.g., 'title', 'name'). - **text** (string) - Required - The partial text to search for. - **size** (integer) - Optional - The number of suggestions to return. ### Request Example ``` GET /autocomplete?field=title&text=full&size=10 ``` ### Response #### Success Response (200) - **data** (array) - A list of autocomplete suggestions. #### Response Example ```json { "data": [ "Full Stack Developer", "Full Time Employee" ] } ``` ``` -------------------------------- ### Get Person Changelog (Go) Source: https://github.com/peopledatalabs/peopledatalabs-go/blob/main/README.md Retrieves changelog information for persons based on version and change type. Requires specifying current and origin versions, and the type of change. ```go currentVersion := "31.0" originVersion := "30.2" changeType := "updated" params := model.ChangelogPersonParams{ CurrentVersion: currentVersion, OriginVersion: originVersion, Type: changeType, } resp, err := client.person.Changelog(ctx, params) ``` -------------------------------- ### Initialize People Data Labs Go Client Source: https://github.com/peopledatalabs/peopledatalabs-go/blob/main/README.md Demonstrates how to create a new People Data Labs client instance in Go. It requires your API key, which can be hardcoded or preferably fetched from environment variables. ```go package main import ( pdl "github.com/peopledatalabs/peopledatalabs-go/v6" pdlmodel "github.com/peopledatalabs/peopledatalabs-go/v6/model" ) func main() { apiKey := "YOUR_API_KEY_HERE" // Set API KEY as env variable // apiKey := os.Getenv("API_KEY") client := pdl.New(apiKey) } ``` -------------------------------- ### Initialize PDL Client in Go Source: https://context7.com/peopledatalabs/peopledatalabs-go/llms.txt Demonstrates how to initialize the People Data Labs client in Go. It shows basic initialization with an API key, and advanced configurations like custom timeouts, custom HTTP clients, and enabling sandbox mode for testing. ```go package main import ( "context" "fmt" "net/http" "os" "time" pdl "github.com/peopledatalabs/peopledatalabs-go/v6" "github.com/peopledatalabs/peopledatalabs-go/v6/api" pdlmodel "github.com/peopledatalabs/peopledatalabs-go/v6/model" ) func main() { // Basic initialization apiKey := os.Getenv("PDL_API_KEY") client := pdl.New(apiKey) // With custom timeout (default is 10 seconds) clientWithTimeout := pdl.New(apiKey, pdl.WithTimeout(30*time.Second)) // With custom HTTP client customHTTPClient := &http.Client{Timeout: 60 * time.Second} clientWithHTTP := pdl.New(apiKey, pdl.WithHTTPClient(customHTTPClient)) // With sandbox mode for testing sandboxClient := pdl.New(apiKey, api.ClientOptions(func(c *api.Client) { c.Sandbox = true })) ctx := context.Background() // Use client for API calls... _ = client _ = clientWithTimeout _ = clientWithHTTP _ = sandboxClient _ = ctx } ``` -------------------------------- ### Client Initialization Source: https://context7.com/peopledatalabs/peopledatalabs-go/llms.txt Initialize the PDL client with your API key. Supports custom configurations for timeouts, HTTP clients, logging, and sandbox mode. ```APIDOC ## Client Initialization Initialize the PDL client with your API key to access all API endpoints. The client supports optional configuration for custom HTTP clients, timeouts, logging, and sandbox mode. ```go package main import ( "context" "fmt" "net/http" "os" "time" pdl "github.com/peopledatalabs/peopledatalabs-go/v6" "github.com/peopledatalabs-go/v6/api" pdlmodel "github.com/peopledatalabs/peopledatalabs-go/v6/model" ) func main() { // Basic initialization apiKey := os.Getenv("PDL_API_KEY") client := pdl.New(apiKey) // With custom timeout (default is 10 seconds) clientWithTimeout := pdl.New(apiKey, pdl.WithTimeout(30*time.Second)) // With custom HTTP client customHTTPClient := &http.Client{Timeout: 60 * time.Second} clientWithHTTP := pdl.New(apiKey, pdl.WithHTTPClient(customHTTPClient)) // With sandbox mode for testing sandboxClient := pdl.New(apiKey, api.ClientOptions(func(c *api.Client) { c.Sandbox = true })) ctx := context.Background() // Use client for API calls... _ = client _ = clientWithTimeout _ = clientWithHTTP _ = sandboxClient _ = ctx } ``` ``` -------------------------------- ### Search Companies using SQL Syntax in Go Source: https://context7.com/peopledatalabs/peopledatalabs-go/llms.txt Demonstrates how to search the PDL company database using SQL syntax with the Go client. It requires an API key and allows specifying search conditions directly in a SQL query. The output includes the total number of companies found and their display name, industry, and employee count. ```go package main import ( "context" "fmt" "os" pdl "github.com/peopledatalabs/peopledatalabs-go/v6" pdlmodel "github.com/peopledatalabs/peopledatalabs-go/v6/model" ) func main() { client := pdl.New(os.Getenv("PDL_API_KEY")) ctx := context.Background() sqlQuery := `SELECT * FROM company WHERE tags='big data' AND industry='financial services' AND location.country='united states'` params := pdlmodel.SearchParams{ BaseParams: pdlmodel.BaseParams{Size: 10}, SearchBaseParams: pdlmodel.SearchBaseParams{SQL: sqlQuery}, } result, err := client.Company.Search(ctx, params) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Found %d companies\n", result.Total) for _, company := range result.Data { fmt.Printf("- %s (%s) - %d employees\n", company.DisplayName, company.Industry, company.EmployeeCount) } } ``` -------------------------------- ### Enable Sandbox Usage for People Data Labs Go Client (Go) Source: https://github.com/peopledatalabs/peopledatalabs-go/blob/main/README.md Configures the People Data Labs Go client to use the sandbox environment. This is achieved by setting the 'Sandbox' option to true during client initialization. ```go # To enable sandbox usage, use the following import ( pdl "github.com/peopledatalabs/peopledatalabs-go/v6" "github.com/peopledatalabs/peopledatalabs-go/v6/api" pdlmodel "github.com/peopledatalabs/peopledatalabs-go/v6/model" ) client := pdl.New(apiKey, api.ClientOptions(func(c *api.Client) { c.Sandbox = true })) ``` -------------------------------- ### Search Companies using Elasticsearch DSL in Go Source: https://context7.com/peopledatalabs/peopledatalabs-go/llms.txt Demonstrates how to search the PDL company database using Elasticsearch query DSL with the Go client. It requires an API key and specifies search criteria like tags, industry, and location. The output includes total companies found and details for each company. ```go package main import ( "context" "fmt" "os" pdl "github.com/peopledatalabs/peopledatalabs-go/v6" pdlmodel "github.com/peopledatalabs/peopledatalabs-go/v6/model" ) func main() { client := pdl.New(os.Getenv("PDL_API_KEY")) ctx := context.Background() // Search for big data companies in financial services in the US elasticSearchQuery := map[string]interface{}{ "query": map[string]interface{}{ "bool": map[string]interface{}{ "must": []map[string]interface{}{ {"term": map[string]interface{}{"tags": "big data"}}, {"term": map[string]interface{}{"industry": "financial services"}}, {"term": map[string]interface{}{"location.country": "united states"}}, }, }, }, } params := pdlmodel.SearchParams{ BaseParams: pdlmodel.BaseParams{Size: 10}, SearchBaseParams: pdlmodel.SearchBaseParams{Query: elasticSearchQuery}, } result, err := client.Company.Search(ctx, params) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Total companies found: %d\n", result.Total) for i, company := range result.Data { fmt.Printf("\n%d. %s\n", i+1, company.DisplayName) fmt.Printf(" Industry: %s\n", company.Industry) fmt.Printf(" Size: %s (%d employees)\n", company.Size, company.EmployeeCount) fmt.Printf(" Location: %s\n", company.Location.Name) fmt.Printf(" Website: %s\n", company.Website) fmt.Printf(" Tags: %v\n", company.Tags) } } ``` -------------------------------- ### Search People with SQL using Go Source: https://context7.com/peopledatalabs/peopledatalabs-go/llms.txt Demonstrates how to search the PDL person database using SQL syntax with the People Data Labs Go SDK. It supports standard SQL WHERE clauses and allows filtering by various person attributes. Requires a PDL API key. ```go package main import ( "context" "fmt" "os" pdl "github.com/peopledatalabs/peopledatalabs-go/v6" pdlmodel "github.com/peopledatalabs/peopledatalabs-go/v6/model" ) func main() { client := pdl.New(os.Getenv("PDL_API_KEY")) ctx := context.Background() // SQL query for healthcare professionals in Mexico with phone numbers 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, }, SearchBaseParams: pdlmodel.SearchBaseParams{ SQL: sqlQuery, Dataset: "phone,mobile_phone", }, } result, err := client.Person.Search(ctx, params) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Total matches: %d\n", result.Total) for _, person := range result.Data { fmt.Printf("- %s (%s) - %v\n", person.FullName, person.JobTitle, person.PhoneNumbers) } // More complex SQL query complexSQL := `SELECT * FROM person WHERE job_company_industry='computer software' AND job_title_levels='director' AND location_country='united states' AND inferred_years_experience >= 10` params2 := pdlmodel.SearchParams{ BaseParams: pdlmodel.BaseParams{Size: 5}, SearchBaseParams: pdlmodel.SearchBaseParams{SQL: complexSQL}, } result2, err := client.Person.Search(ctx, params2) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("\nExperienced Directors in Software: %d total\n", result2.Total) for _, person := range result2.Data { fmt.Printf("- %s, %s at %s\n", person.FullName, person.JobTitle, person.JobCompanyName) } } ``` -------------------------------- ### Sandbox Usage Source: https://github.com/peopledatalabs/peopledatalabs-go/blob/main/README.md Configuration for enabling sandbox usage in the People Data Labs Go SDK. ```APIDOC ## Sandbox Usage ### Description To enable sandbox usage, you need to configure the client options when initializing the SDK. ### Usage ```go import ( pdl "github.com/peopledatalabs/peopledatalabs-go/v6" "github.com/peopledatalabs/peopledatalabs-go/v6/api" ) apiKey := "YOUR_API_KEY" client := pdl.New(apiKey, api.ClientOptions(func(c *api.Client) { c.Sandbox = true })) ``` ### Parameters - **apiKey** (string) - Your People Data Labs API key. - **api.ClientOptions** - A function that allows modifying client options. - **c.Sandbox** (bool) - Set to `true` to enable sandbox mode. ``` -------------------------------- ### Search Person Data using SQL Query with Go Source: https://github.com/peopledatalabs/peopledatalabs-go/blob/main/README.md Searches for person data using a SQL query with the Go client. The SQL query is provided as a string, allowing for complex filtering and selection. The dataset to search can also be specified. ```go 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, }, SearchBaseParams: pdlmodel.SearchBaseParams{ SQL: sqlQuery, Dataset: "phone,mobile_phone", }, } result, err := client.Person.Search(ctx, params) ``` -------------------------------- ### Supporting Data SDK Functions (Go) Source: https://github.com/peopledatalabs/peopledatalabs-go/blob/main/README.md Includes SDK functions for supporting data operations such as Autocomplete and data cleaning for various entities. These functions map to specific People Data Labs API endpoints, with parameters defined in the API documentation. ```go client.Autocomplete(params) client.Company.Clean(params) client.Location.Clean(params) client.School.Clean(params) client.JobTitle(params) client.IP(params) ``` -------------------------------- ### Bulk Retrieve Person Records by IDs using Go Source: https://context7.com/peopledatalabs/peopledatalabs-go/llms.txt Demonstrates how to retrieve up to 100 person records simultaneously using their PDL IDs with the People Data Labs Go SDK. This method is efficient for batch processing and allows for associating metadata with each request. Requires a PDL API key. ```go package main import ( "context" "fmt" "os" pdl "github.com/peopledatalabs/peopledatalabs-go/v6" pdlmodel "github.com/peopledatalabs/peopledatalabs-go/v6/model" ) func main() { client := pdl.New(os.Getenv("PDL_API_KEY")) ctx := context.Background() params := pdlmodel.BulkRetrievePersonParams{ Requests: []pdlmodel.BulkRetrieveSinglePersonParams{ { ID: "qEnOZ5Oh0poWnQ1luFBfVw_0000", Metadata: pdlmodel.PersonMetadata{"source": "crm", "record_id": "123"}, }, { ID: "PzFD15NINdBWNULBBkwlig_0000", Metadata: pdlmodel.PersonMetadata{"source": "crm", "record_id": "456"}, }, }, } results, err := client.Person.BulkRetrieve(ctx, params) if err != nil { fmt.Printf("Error: %v\n", err) return } for _, result := range results { fmt.Printf("Record ID: %s\n", result.Metadata["record_id"]) fmt.Printf(" Status: %d, Billed: %t\n", result.Status, result.Billed) fmt.Printf(" Name: %s\n", result.Data.FullName) fmt.Printf(" Current Role: %s at %s\n", result.Data.JobTitle, result.Data.JobCompanyName) fmt.Println() } } ``` -------------------------------- ### Autocomplete API Suggestions with Go Source: https://context7.com/peopledatalabs/peopledatalabs-go/llms.txt Fetches autocomplete suggestions for various field types like job titles, companies, and schools using the People Data Labs Go SDK. It requires an API key and returns suggestions with counts of matching records. ```go package main import ( "context" "fmt" "os" pdl "github.com/peopledatalabs/peopledatalabs-go/v6" pdlmodel "github.com/peopledatalabs/peopledatalabs-go/v6/model" ) func main() { client := pdl.New(os.Getenv("PDL_API_KEY")) ctx := context.Background() // Autocomplete for job titles starting with "full" params := pdlmodel.AutocompleteParams{ BaseParams: pdlmodel.BaseParams{Size: 10}, AutocompleteBaseParams: pdlmodel.AutocompleteBaseParams{ Field: pdlmodel.AutocompleteTypeTitle, Text: "full", }, } result, err := client.Autocomplete(ctx, params) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Status: %d\n", result.Status) fmt.Println("Job Title Suggestions:") for _, suggestion := range result.Data { fmt.Printf(" - %s (%d records)\n", suggestion.Name, suggestion.Count) } // Autocomplete for companies paramsCompany := pdlmodel.AutocompleteParams{ BaseParams: pdlmodel.BaseParams{Size: 5}, AutocompleteBaseParams: pdlmodel.AutocompleteBaseParams{ Field: pdlmodel.AutocompleteTypeCompany, Text: "goog", }, } result2, err := client.Autocomplete(ctx, paramsCompany) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Println("\nCompany Suggestions:") for _, suggestion := range result2.Data { fmt.Printf(" - %s (%d records)\n", suggestion.Name, suggestion.Count) } // Autocomplete for schools paramsSchool := pdlmodel.AutocompleteParams{ BaseParams: pdlmodel.BaseParams{Size: 5}, AutocompleteBaseParams: pdlmodel.AutocompleteBaseParams{ Field: pdlmodel.AutocompleteTypeSchool, Text: "stanf", }, } result3, err := client.Autocomplete(ctx, paramsSchool) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Println("\nSchool Suggestions:") for _, suggestion := range result3.Data { fmt.Printf(" - %s (%d records)\n", suggestion.Name, suggestion.Count) } // Available autocomplete field types: // - AutocompleteTypeTitle (job titles) // - AutocompleteTypeCompany (company names) // - AutocompleteTypeSchool (school names) // - AutocompleteTypeSkill (skills) // - AutocompleteTypeIndustry (industries) // - AutocompleteTypeRole (job roles) // - AutocompleteTypeSubRole (job sub-roles) // - AutocompleteTypeLocation (localities) // - AutocompleteTypeCountry (countries) // - AutocompleteTypeRegion (regions/states) // - AutocompleteTypeMajor (educational majors) } ``` -------------------------------- ### Search Company Data using SQL Query (Go) Source: https://github.com/peopledatalabs/peopledatalabs-go/blob/main/README.md Searches for company data using a raw SQL query. This method is useful for direct SQL-based searches. Requires specifying search parameters like size. ```go sqlQuery := "SELECT * FROM company" + " WHERE tags='big data'" + " AND industry='financial services'" + " AND location.country='united states';" params := pdlmodel.SearchParams{ BaseParams: pdlmodel.BaseParams{Size: 10}, SearchBaseParams: pdlmodel.SearchBaseParams{SQL: sqlQuery}, } result, err := client.Company.Search(ctx, params) ``` -------------------------------- ### Identify Person with People Data Labs Go SDK Source: https://context7.com/peopledatalabs/peopledatalabs-go/llms.txt Demonstrates how to use the Person Identify API to find potential matches for an identity with incomplete or uncertain input data. Requires a PDL_API_KEY environment variable. ```go package main import ( "context" "fmt" "os" pdl "github.com/peopledatalabs/peopledatalabs-go/v6" pdlmodel "github.com/peopledatalabs/peopledatalabs-go/v6/model" ) func main() { client := pdl.New(os.Getenv("PDL_API_KEY")) ctx := context.Background() params := pdlmodel.IdentifyPersonParams{ PersonParams: pdlmodel.PersonParams{ Name: []string{"sean thorne"}, }, } result, err := client.Person.Identify(ctx, params) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Status: %d\n", result.Status) fmt.Printf("Found %d potential matches\n", len(result.Matches)) for i, match := range result.Matches { fmt.Printf("\n%d. %s\n", i+1, match.Data.FullName) fmt.Printf(" Match Score: %d\n", match.MatchScore) fmt.Printf(" Matched On: %v\n", match.MatchedOn) fmt.Printf(" Title: %s at %s\n", match.Data.JobTitle, match.Data.JobCompanyName) fmt.Printf(" Location: %s\n", match.Data.LocationName) fmt.Printf(" LinkedIn: %s\n", match.Data.LinkedinUrl) } } ``` -------------------------------- ### Fuzzy Identify Person Data with Go Client Source: https://github.com/peopledatalabs/peopledatalabs-go/blob/main/README.md Identifies a person using fuzzy matching with the Go client. It takes a PersonParams struct with potentially incomplete or varied name information to find a matching record. ```go params := pdlmodel.IdentifyPersonParams{PersonParams: pdlmodel.PersonParams{Name: []string{"sean thorne"}}} result, err := client.Person.Identify(ctx, params) ``` -------------------------------- ### Company Search API (SQL) Source: https://context7.com/peopledatalabs/peopledatalabs-go/llms.txt Search the PDL company database using SQL syntax. This endpoint provides a familiar SQL interface for querying company data. ```APIDOC ## POST /companies/search ### Description Search the PDL company database using SQL syntax. This endpoint provides a familiar SQL interface for querying company data. ### Method POST ### Endpoint /companies/search ### Parameters #### Query Parameters - **api_key** (string) - Required - Your People Data Labs API key. - **size** (integer) - Optional - The number of results to return. #### Request Body - **sql** (string) - Required - A SQL query string. ### Request Example ```sql SELECT * FROM company WHERE tags='big data' AND industry='financial services' AND location.country='united states' ``` ### Response #### Success Response (200) - **total** (integer) - The total number of companies found. - **data** (array) - An array of company objects. - **displayName** (string) - The canonical name of the company. - **industry** (string) - The industry the company operates in. - **employeeCount** (integer) - The number of employees at the company. #### Response Example ```json { "total": 150, "data": [ { "displayName": "Example Corp", "industry": "Technology", "employeeCount": 5000 } ] } ``` ``` -------------------------------- ### Bulk Enrich Company Data (Go) Source: https://github.com/peopledatalabs/peopledatalabs-go/blob/main/README.md Performs bulk enrichment for multiple companies by providing a list of company profiles. Supports specifying base parameters like 'Pretty'. ```go params := pdlmodel.BulkEnrichCompanyParams{ BaseParams: model.BaseParams{Pretty: true}, Requests: []pdlmodel.BulkEnrichSingleCompanyParams{ { Params: pdlmodel.CompanyParams{ Profile: "linkedin.com/company/peopledatalabs", }, }, { Params: pdlmodel.CompanyParams{ Profile: "https://www.linkedin.com/company/apple/", }, }, }, } result, err := client.Company.BulkEnrich(ctx, params) ``` -------------------------------- ### Company Search API (SQL) Source: https://github.com/peopledatalabs/peopledatalabs-go/blob/main/README.md Search for companies using a SQL query. ```APIDOC ## Company Search API (SQL) ### Description Searches for companies using a standard SQL query. ### Method POST ### Endpoint /company/search ### Parameters #### Request Body - **sql** (string) - Required - The SQL query to execute. - **size** (integer) - Optional - The number of results to return per page. ### Request Example ```json { "sql": "SELECT * FROM company WHERE tags='big data' AND industry='financial services' AND location.country='united states';", "size": 10 } ``` ### Response #### Success Response (200) - **data** (array) - A list of company records matching the query. - **total** (integer) - The total number of matching records. #### Response Example ```json { "data": [ { "name": "Example Company", "location": {"country": "United States"} } ], "total": 50 } ``` ``` -------------------------------- ### Error Handling Source: https://context7.com/peopledatalabs/peopledatalabs-go/llms.txt Information on how the SDK handles various API error scenarios. ```APIDOC ## Error Handling The SDK provides structured error types for different API error scenarios including validation errors, not found errors, and REST API errors. ### Error Types - **ValidationError**: Indicates issues with the request parameters. - **NotFoundError**: Returned when a requested resource is not found. - **RestError**: A general error for REST API communication issues, including status codes and messages. ### Usage Example ```go package main import ( "context" "errors" "fmt" "os" pdl "github.com/peopledatalabs/peopledatalabs-go/v6" pdlmodel "github.com/peopledatalabs/peopledatalabs-go/v6/model" ) func main() { client := pdl.New(os.Getenv("PDL_API_KEY")) ctx := context.Background() // Example: Validation error (missing required fields) invalidParams := pdlmodel.EnrichPersonParams{ PersonParams: pdlmodel.PersonParams{ // No identifiers provided - will fail validation }, } _, err := client.Person.Enrich(ctx, invalidParams) if err != nil { fmt.Printf("Validation Error: %v\n", err) } // Example: Not found error params := pdlmodel.RetrievePersonParams{ PersonID: "nonexistent_id_12345", } _, err = client.Person.Retrieve(ctx, params) if err != nil { var notFoundErr pdlmodel.NotFoundError if errors.As(err, ¬FoundErr) { fmt.Printf("Not Found: %s\n", notFoundErr.Error.Message) } var restErr pdlmodel.RestError if errors.As(err, &restErr) { fmt.Printf("REST Error: Status %d - %s\n", restErr.Status, restErr.Error.Message) } } // Example: Search validation error (must provide query OR sql, not both) invalidSearch := pdlmodel.SearchParams{ SearchBaseParams: pdlmodel.SearchBaseParams{ Query: map[string]interface{}{"match_all": map[string]interface{}{}}, SQL: "SELECT * FROM person", }, } _, err = client.Person.Search(ctx, invalidSearch) if err != nil { fmt.Printf("Search Validation Error: %v\n", err) } } ``` ``` -------------------------------- ### Clean Raw Company Strings (Go) Source: https://github.com/peopledatalabs/peopledatalabs-go/blob/main/README.md Cleans raw company name strings to standardize them. Takes a company name as input and returns a cleaned version. ```go params := pdlmodel.CleanCompanyParams{Name: "peOple DaTa LabS"} result, err := client.Company.Clean(ctx, params) ``` -------------------------------- ### Clean Raw School Strings (Go) Source: https://github.com/peopledatalabs/peopledatalabs-go/blob/main/README.md Cleans raw school name strings to standardize them. Takes a school name as input and returns a cleaned version. ```go params := pdlmodel.CleanSchoolParams{ SchoolParams: pdlmodel.SchoolParams{Name: "university of oregon"}, } result, err := client.School.Clean(ctx, params) ``` -------------------------------- ### Track Person Record Changes with People Data Labs Go SDK Source: https://context7.com/peopledatalabs/peopledatalabs-go/llms.txt Shows how to use the Person Changelog API to track changes in person records between dataset versions. Useful for monitoring data updates and maintaining data freshness. Requires a PDL_API_KEY environment variable. ```go package main import ( "context" "fmt" "os" pdl "github.com/peopledatalabs/peopledatalabs-go/v6" pdlmodel "github.com/peopledatalabs/peopledatalabs-go/v6/model" ) func main() { client := pdl.New(os.Getenv("PDL_API_KEY")) ctx := context.Background() params := pdlmodel.ChangelogPersonParams{ CurrentVersion: "31.0", OriginVersion: "30.2", Type: "updated", FieldsUpdated: []string{"job_title", "job_company_name"}, } result, err := client.Person.Changelog(ctx, params) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Status: %d\n", result.Status) fmt.Printf("Type: %s\n", result.Data.Type) fmt.Printf("Origin Version: %s\n", result.Data.OriginVersion) fmt.Printf("Current Version: %s\n", result.Data.CurrentVersion) fmt.Printf("\nUpdated Records: %d\n", len(result.Data.Updated)) for _, updated := range result.Data.Updated { fmt.Printf(" - ID: %s, Fields: %v\n", updated.ID, updated.AdditionalMetadata.FieldsUpdated) } fmt.Printf("\nAdded Records: %d\n", len(result.Data.Added)) fmt.Printf("Deleted Records: %d\n", len(result.Data.Deleted)) fmt.Printf("Merged Records: %d\n", len(result.Data.Merged)) // Pagination if result.Data.ScrollToken != "" { fmt.Printf("\nScroll Token for next page: %s\n", result.Data.ScrollToken) } } ``` -------------------------------- ### Enrich IP Address Information with Go Source: https://context7.com/peopledatalabs/peopledatalabs-go/llms.txt This Go code snippet demonstrates how to enrich an IP address to retrieve associated company and location information. It utilizes the People Data Labs Go SDK and requires an API key. The function takes an IP address as input and returns detailed metadata, location, and associated company data. ```go package main import ( "context" "fmt" "os" pdl "github.com/peopledatalabs/peopledatalabs-go/v6" pdlmodel "github.com/peopledatalabs/peopledatalabs-go/v6/model" ) func main() { client := pdl.New(os.Getenv("PDL_API_KEY")) ctx := context.Background() params := pdlmodel.IPParams{ BaseParams: pdlmodel.BaseParams{Pretty: true}, IPBaseParams: pdlmodel.IPBaseParams{ IP: "72.212.42.228", ReturnIPLocation: true, ReturnIPMetadata: true, ReturnPerson: true, }, } result, err := client.IP(ctx, params) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Status: %d\n", result.Status) fmt.Printf("IP Address: %s\n", result.Data.IP.Address) // IP Metadata fmt.Println("\nIP Metadata:") fmt.Printf(" Version: %d\n", result.Data.IP.Metadata.Version) fmt.Printf(" Mobile: %t\n", result.Data.IP.Metadata.Mobile) fmt.Printf(" VPN: %t\n", result.Data.IP.Metadata.VPN) fmt.Printf(" Proxy: %t\n", result.Data.IP.Metadata.Proxy) fmt.Printf(" Hosting: %t\n", result.Data.IP.Metadata.Hosting) // IP Location fmt.Println("\nIP Location:") fmt.Printf(" Name: %s\n", result.Data.IP.Location.Name) fmt.Printf(" Locality: %s\n", result.Data.IP.Location.Locality) fmt.Printf(" Region: %s\n", result.Data.IP.Location.Region) fmt.Printf(" Country: %s\n", result.Data.IP.Location.Country) fmt.Printf(" Timezone: %s\n", result.Data.IP.Location.Timezone) // Associated Company fmt.Println("\nAssociated Company:") fmt.Printf(" Confidence: %s\n", result.Data.Company.Confidence) fmt.Printf(" Name: %s\n", result.Data.Company.DisplayName) fmt.Printf(" Industry: %s\n", result.Data.Company.Industry) fmt.Printf(" Size: %s\n", result.Data.Company.Size) fmt.Printf(" Location: %s\n", result.Data.Company.Location.Name) } ``` -------------------------------- ### Search Company Data using Elasticsearch Query (Go) Source: https://github.com/peopledatalabs/peopledatalabs-go/blob/main/README.md Searches for company data using an Elasticsearch query. Allows complex filtering based on terms within various fields. Requires specifying search parameters like size. ```go elasticSearchQuery := map[string]interface{}{ "query": map[string]interface{}{ "bool": map[string]interface{}{ "must": []map[string]interface{}{ {"term": map[string]interface{}{"tags": "bigdata"}}, {"term": map[string]interface{}{"industry": "financial services"}}, {"term": map[string]interface{}{"location.country": "united states"}}, }, }, }, } params := pdlmodel.SearchParams{ BaseParams: pdlmodel.BaseParams{Size: 10}, SearchBaseParams: pdlmodel.SearchBaseParams{Query: elasticSearchQuery}, } result, err := client.Company.Search(ctx, params) ``` -------------------------------- ### Handle API Errors with Go SDK Source: https://context7.com/peopledatalabs/peopledatalabs-go/llms.txt This Go code demonstrates how to handle various API error scenarios using the People Data Labs Go SDK. It covers validation errors, not found errors, and general REST API errors by leveraging Go's `errors.As` for type checking. Proper error handling is crucial for robust application development. ```go package main import ( "context" "errors" "fmt" "os" pdl "github.com/peopledatalabs/peopledatalabs-go/v6" pdlmodel "github.com/peopledatalabs/peopledatalabs-go/v6/model" ) func main() { client := pdl.New(os.Getenv("PDL_API_KEY")) ctx := context.Background() // Example: Validation error (missing required fields) invalidParams := pdlmodel.EnrichPersonParams{ PersonParams: pdlmodel.PersonParams{ // No identifiers provided - will fail validation }, } _, err := client.Person.Enrich(ctx, invalidParams) if err != nil { fmt.Printf("Validation Error: %v\n", err) } // Example: Not found error params := pdlmodel.RetrievePersonParams{ PersonID: "nonexistent_id_12345", } _, err = client.Person.Retrieve(ctx, params) if err != nil { var notFoundErr pdlmodel.NotFoundError if errors.As(err, ¬FoundErr) { fmt.Printf("Not Found: %s\n", notFoundErr.Error.Message) } var restErr pdlmodel.RestError if errors.As(err, &restErr) { fmt.Printf("REST Error: Status %d - %s\n", restErr.Status, restErr.Error.Message) } } // Example: Search validation error (must provide query OR sql, not both) invalidSearch := pdlmodel.SearchParams{ SearchBaseParams: pdlmodel.SearchBaseParams{ Query: map[string]interface{}{"match_all": map[string]interface{}{}}, SQL: "SELECT * FROM person", }, } _, err = client.Person.Search(ctx, invalidSearch) if err != nil { fmt.Printf("Search Validation Error: %v\n", err) } } ``` -------------------------------- ### Person Enrichment using Go SDK Source: https://context7.com/peopledatalabs/peopledatalabs-go/llms.txt Shows how to enrich person data using the People Data Labs Go SDK. It covers enrichment by phone number, email with additional parameters, and LinkedIn profile URL. The code demonstrates handling API responses and errors. ```go package main import ( "context" "fmt" "os" pdl "github.com/peopledatalabs/peopledatalabs-go/v6" pdlmodel "github.com/peopledatalabs/peopledatalabs-go/v6/model" ) func main() { client := pdl.New(os.Getenv("PDL_API_KEY")) ctx := context.Background() // Enrich by phone number params := pdlmodel.EnrichPersonParams{ PersonParams: pdlmodel.PersonParams{ Phone: []string{"4155688415"}, }, } result, err := client.Person.Enrich(ctx, params) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Status: %d\n", result.Status) fmt.Printf("Likelihood: %d\n", result.Likelihood) fmt.Printf("Full Name: %s\n", result.Data.FullName) fmt.Printf("Job Title: %s\n", result.Data.JobTitle) fmt.Printf("Company: %s\n", result.Data.JobCompanyName) fmt.Printf("Location: %s\n", result.Data.LocationName) // Enrich by email with additional parameters paramsWithOptions := pdlmodel.EnrichPersonParams{ PersonParams: pdlmodel.PersonParams{ Email: []string{"sean@peopledatalabs.com"}, }, AdditionalParams: pdlmodel.AdditionalParams{ MinLikelihood: 6, Required: "full_name", IncludeIfMatched: true, }, } result2, err := client.Person.Enrich(ctx, paramsWithOptions) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Enriched: %s at %s\n", result2.Data.FullName, result2.Data.JobCompanyName) // Enrich by LinkedIn profile paramsLinkedIn := pdlmodel.EnrichPersonParams{ PersonParams: pdlmodel.PersonParams{ Profile: []string{"linkedin.com/in/seanthorne"}, }, } result3, err := client.Person.Enrich(ctx, paramsLinkedIn) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("LinkedIn Profile: %s\n", result3.Data.LinkedinUrl) } ``` -------------------------------- ### Person Data Search API (SQL) Source: https://github.com/peopledatalabs/peopledatalabs-go/blob/main/README.md Searches for person data using SQL query syntax. ```APIDOC ## POST /person/search ### Description Searches for person data using SQL query syntax, providing flexibility for structured data retrieval. ### Method POST ### Endpoint /person/search ### Parameters #### Query Parameters - **pretty** (boolean) - Optional - If true, returns JSON with indentation. - **api_key** (string) - Required - Your People Data Labs API key. #### Request Body - **sql** (string) - Required - The SQL query to execute. - **dataset** (string) - Required - The dataset to search (e.g., "phone,mobile_phone"). - **size** (integer) - Optional - The number of results to return. - **from** (integer) - Optional - The starting offset for results. ### Request Example ```json { "sql": "SELECT * FROM person WHERE location_country='mexico' AND job_title_role='health' AND phone_numbers IS NOT NULL;", "dataset": "phone,mobile_phone", "size": 10 } ``` ### Response #### Success Response (200) - **status** (integer) - The HTTP status code of the response. - **data** (array of objects) - Contains the search results. #### Response Example ```json { "status": 200, "data": [ { "full_name": "Carlos Rodriguez" } ] } ``` ``` -------------------------------- ### Clean School Data with People Data Labs Go SDK Source: https://context7.com/peopledatalabs/peopledatalabs-go/llms.txt Cleans and normalizes raw school name strings into canonical school records using the People Data Labs Go SDK. Requires a PDL_API_KEY environment variable. Takes a school name or website as input and outputs canonical school details. ```go package main import ( "context" "fmt" "os" pdl "github.com/peopledatalabs/peopledatalabs-go/v6" pdlmodel "github.com/peopledatalabs/peopledatalabs-go/v6/model" ) func main() { client := pdl.New(os.Getenv("PDL_API_KEY")) ctx := context.Background() params := pdlmodel.CleanSchoolParams{ SchoolParams: pdlmodel.SchoolParams{ Name: "university of oregon", }, } result, err := client.School.Clean(ctx, params) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Status: %d\n", result.Status) fmt.Printf("Canonical Name: %s\n", result.Name) fmt.Printf("Type: %s\n", result.Type) fmt.Printf("Website: %s\n", result.Website) fmt.Printf("Domain: %s\n", result.Domain) fmt.Printf("LinkedIn: %s\n", result.LinkedinUrl) fmt.Printf("Location: %s\n", result.Location.Name) // Clean by website params2 := pdlmodel.CleanSchoolParams{ SchoolParams: pdlmodel.SchoolParams{ Website: "stanford.edu", }, } result2, err := client.School.Clean(ctx, params2) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("\nstanford.edu -> %s\n", result2.Name) } ```