peopledatalabs_go

package module
v1.4.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2024 License: MIT Imports: 4 Imported by: 0

README ยถ

People Data Labs Logo

People Data Labs Go Client

Official Go client for the People Data Labs API.

Repo Status ย  Go 1.4.4 ย  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
    
  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"
    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

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.

Documentation ยถ

Index ยถ

Constants ยถ

View Source
const Version = "1.4.4"

Variables ยถ

This section is empty.

Functions ยถ

func New ยถ

func New(apiKey string, opts ...api.ClientOptions) *pld

New returns a new People Data Labs Client All interactions with the API must be done using this client

You must provide an API KEY. Get your API key by creating a free account at https://www.peopledatalabs.com/signup. You can provide api.ClientOptions to customize client behaviour

func WithHTTPClient ยถ

func WithHTTPClient(httpCli *http.Client) api.ClientOptions

WithHTTPClient sets a custom HTTP Client that will be used to make API requests for the library

func WithLogLevel ยถ

func WithLogLevel(level logger.Level) api.ClientOptions

WithLogLevel sets the level at which the library will log Default behaviour is to log at logger.DefaultLevel

func WithLogger ยถ

func WithLogger(logger logger.Logger) api.ClientOptions

WithLogger sets a custom logger for the library

func WithTimeout ยถ

func WithTimeout(timeout time.Duration) api.ClientOptions

WithTimeout sets the timeout the API client uses Default timeout is api.DefaultTimeout

Types ยถ

This section is empty.

Directories ยถ

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL