People Data Labs Go Client
Official Go client for the People Data Labs API.
ย
ย
Table of Contents
๐ง Installation
- To use peopledatalabs-go SDK in your project initialize go modules then run:
go get github.com/peopledatalabs/peopledatalabs-go
- Sign up for a free PDL API key.
- Set your API key as a environment variable.
๐ Usage
First, create the PeopleDataLabs client:
package main
import (
pdl "github.com/peopledatalabs/peopledatalabs-go"
pdlmodel "github.com/peopledatalabs/peopledatalabs-go/model"
)
func main() {
apiKey := "YOUR_API_KEY_HERE"
// Set API KEY as env variable
// apiKey := os.Getenv("API_KEY")
client := pdl.New(apiKey)
}
Then, send requests to any PDL API Endpoint.
Person Data
Enrichment
params := pdlmodel.EnrichPersonParams{
PersonParams: pdlmodel.PersonParams{
Phone: []string{"4155688415"},
},
}
result, err := client.Person.Enrich(ctx, params)
if err == nil {
fmt.Printf("Status: %d, FullName: %s\n", result.Status, result.Data.FullName)
}
Bulk Enrichment
params := pdlmodel.BulkEnrichPersonParams{
BaseParams: model.BaseParams{Pretty: true},
AdditionalParams: model.AdditionalParams{MinLikelihood: 6, IncludeIfMatched: true, Required: "full_name"},
Requests: []pdlmodel.BulkEnrichSinglePersonParams{
{
Params: pdlmodel.PersonParams{
Profile: []string{"linkedin.com/in/seanthorne"},
Location: []string{"SF Bay Area"},
Name: []string{"Sean F. Thorne"},
},
},
{
Params: pdlmodel.PersonParams{
Profile: []string{"https://www.linkedin.com/in/haydenconrad/"},
FirstName: []string{"Hayden"},
LastName: []string{"Conrad"},
},
},
},
}
result, err := client.Person.BulkEnrich(ctx, params)
Search (Elasticsearch)
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"}},
},
},
},
}
params := pdlmodel.SearchParams{
BaseParams: pdlmodel.BaseParams{
Size: 10,
},
SearchBaseParams: pdlmodel.SearchBaseParams{
Query: elasticSearchQuery,
Dataset: "phone,mobile_phone",
},
}
result, err := client.Person.Search(ctx, params)
Search (SQL)
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)
PDL_ID
(Retrieve API)
params := pdlmodel.RetrievePersonParams{PersonID: "qEnOZ5Oh0poWnQ1luFBfVw_0000"}
result, err := client.Person.Retrieve(ctx, params)
Bulk Retrieve API
params := pdlmodel.BulkRetrievePersonParams{
Requests: []pdlmodel.BulkRetrieveSinglePersonParams{
{ID: "qEnOZ5Oh0poWnQ1luFBfVw_0000"},
{ID: "PzFD15NINdBWNULBBkwlig_0000"},
}
}
result, err := client.Person.BulkRetrieve(ctx, params)
Fuzzy Enrichment (Identify API)
params := pdlmodel.IdentifyPersonParams{PersonParams: pdlmodel.PersonParams{Name: []string{"sean thorne"}}}
result, err := client.Person.Identify(ctx, params)
Company Data
Enrichment
params := pdlmodel.EnrichCompanyParams{
CompanyParams: pdlmodel.CompanyParams{Website: "peopledatalabs.com"},
}
result, err := client.Company.Enrich(ctx, params)
Bulk Enrichment
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)
Search (Elasticsearch)
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)
Search (SQL)
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)
Supporting APIs
Get Autocomplete Suggestions
params := pdlmodel.AutocompleteParams{
BaseParams: pdlmodel.BaseParams{Size: 10},
AutocompleteBaseParams: pdlmodel.AutocompleteBaseParams{Field: "title", Text: "full"},
}
result, err := client.Autocomplete(ctx, params)
Clean Raw Company Strings
params := pdlmodel.CleanCompanyParams{Name: "peOple DaTa LabS"}
result, err := client.Company.Clean(ctx, params)
Clean Raw Location Strings
params := pdlmodel.CleanLocationParams{
LocationParams: pdlmodel.LocationParams{
Location: "455 Market Street, San Francisco, California 94105, US",
},
}
result, err := client.Location.Clean(ctx, params)
Clean Raw School Strings
params := pdlmodel.CleanSchoolParams{
SchoolParams: pdlmodel.SchoolParams{Name: "university of oregon"},
}
result, err := client.School.Clean(ctx, params)
Enrich Job Title
params := model.JobTitleParams{
BaseParams: model.BaseParams{Pretty: true},
JobTitleBaseParams: model.JobTitleBaseParams{JobTitle: "data scientist"},
}
result, err := client.JobTitle(ctx, params)
Enrich Skill
params := model.SkillParams{
BaseParams: model.BaseParams{Pretty: true},
SkillBaseParams: model.SkillBaseParams{Skill: "c++"},
}
result, err := client.Skill(ctx, params)
Enrich IP
params := model.IPParams{
BaseParams: model.BaseParams{Pretty: true},
IPBaseParams: model.IPBaseParams{IP: "72.212.42.169"},
}
result, err := client.IP(ctx, params)
๐ Sandbox Usage
# To enable sandbox usage, use the following
import (
pdl "github.com/peopledatalabs/peopledatalabs-go"
"github.com/peopledatalabs/peopledatalabs-go/api"
pdlmodel "github.com/peopledatalabs/peopledatalabs-go/model"
)
client := pdl.New(apiKey, api.ClientOptions(func(c *api.Client) {
c.Sandbox = true
}))
๐ Endpoints
Person Endpoints
Company Endpoints
Supporting Endpoints
๐ Documentation
All of our API endpoints are documented at: https://docs.peopledatalabs.com/
These docs describe the supported input parameters, output responses and also provide additional technical context.
As illustrated in the Endpoints section above, each of our API endpoints is mapped to a specific method in the API Client. For each of these class methods, all function inputs are mapped as input parameters to the respective API endpoint, meaning that you can use the API documentation linked above to determine the input parameters for each endpoint.