peopledatalabs / peopledatalabs-go

A Go client for the People Data Labs API
https://docs.peopledatalabs.com/docs/go-sdk
MIT License
7 stars 0 forks source link
api company-enrichment company-search contact-data data-enrichment enrichment go go-sdk peopledatalabs person-data person-enrichment person-search sdk search

People Data Labs Logo

People Data Labs Go Client

Official Go client for the People Data Labs API.

Repo Status   Go 3.2.0   Tests Status

Table of Contents

πŸ”§ Installation

  1. To use peopledatalabs-go SDK in your project initialize go modules then run:
    go get github.com/peopledatalabs/peopledatalabs-go/v3
  2. Sign up for a free PDL API key.
  3. Set your API key as a environment variable.

πŸš€ Usage

First, create the PeopleDataLabs client:

package main

import (
    pdl "github.com/peopledatalabs/peopledatalabs-go/v3"
    pdlmodel "github.com/peopledatalabs/peopledatalabs-go/v3/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/v3"
    "github.com/peopledatalabs/peopledatalabs-go/v3/api"
    pdlmodel "github.com/peopledatalabs/peopledatalabs-go/v3/model"
)

client := pdl.New(apiKey, api.ClientOptions(func(c *api.Client) {
    c.Sandbox = true
}))

🌐 Endpoints

Person Endpoints

API Endpoint SDK Function
Person Enrichment API client.Person.Enrich(params)
Person Bulk Enrichment API client.Person.BulkEnrich(params)
Person Search API client.Person.Search(params)
Person Retrieve API client.Person.Retrieve(params)
Person Bulk Retrieve API client.Person.BulkRetrieve(params)
Person Identify API client.Person.Identify(params)

Company Endpoints

API Endpoint SDK Function
Company Enrichment API client.Company.Enrich(params)
Company Bulk Enrichment API client.Company.BulkEnrich(params)
Company Search API client.Company.Search(params)

Supporting Endpoints

API Endpoint SDK Function
Autocomplete API client.Autocomplete(params)
Company Cleaner API client.Company.Clean(params)
Location Cleaner API client.Location.Clean(params)
School Cleaner API client.School.Clean(params)
Job Title Enrichment API client.JobTitle(params)
Skill Enrichment API client.Skill(params)
IP Enrichment API client.IP(params)

πŸ“˜ 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.