> ## Documentation Index
> Fetch the complete documentation index at: https://docs.peopledatalabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Examples - Sandbox APIs

We've provided code samples in Python, Ruby, Go and JavaScript.

> [!TIP]
>
> **We want your feedback!**
>
> Do you see a bug? Is there an example you'd like to see that's not listed here?
>
> Head over to the public roadmap and submit a [bug ticket](https://peopledatalabs.canny.io/bugs) or a [feature request](https://peopledatalabs.canny.io/feature-requests) and receive automatic notifications as your bug is resolved or your request is implemented.

## Sandbox Person Enrichment API

To use the Sandbox Person Enrichment API in URL, set `https://sandbox.api.peopledatalabs.com/v5/person/enrich` as the URL and then use the Person Enrichment API as usual.

To use the Sandbox Person Enrichment API with our SDKs, see [SDK usage](https://docs.peopledatalabs.com/docs/sandbox-apis-reference.md#sdk-usage).

After implementing one of the two mechanisms above, you can make use of any of the [examples for the Person Enrichment API](https://docs.peopledatalabs.com/docs/examples-person-enrichment-api.md).

> [!WARNING]
>
> **Enrichment Limitations**
>
> The Sandbox APIs only use the [Sandbox Datasets](https://docs.peopledatalabs.com/docs/sandbox-apis-reference.md#sandbox-dataset).
>
> **This means that you can only enrich profiles from that dataset**.
>
> To find out which profiles you can enrich on, you can either:
>
> <ul><li>Check the [Sandbox Dataset](https://docs.peopledatalabs.com/docs/sandbox-apis-reference.md#sandbox-dataset)</li>
> <li>Run a search query on the [Sandbox Person Search API](https://docs.peopledatalabs.com/docs/sandbox-apis-examples.md#sandbox-person-search-api) to find out which profiles are available to enrich.</li></ul>

### Basic Usage

```python Python3 SDK expandable theme={null}
import json

# See https://github.com/peopledatalabs/peopledatalabs-python
from peopledatalabs import PDLPY

# Create a client, specifying your API key
CLIENT = PDLPY(
    api_key="YOUR API KEY",
    # Use Sandbox API
    sandbox=True,
)

# Create a parameters JSON object
PARAMS = {
    "profile": ["linkedin.com/in/samantha_mccall"],
    "min_likelihood": 6
}

# Pass the parameters object to the Person Enrichment API
json_response = CLIENT.person.enrichment(**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)
```

```javascript JavaScript expandable theme={null}
// See https://github.com/peopledatalabs/peopledatalabs-js
import PDLJS from 'peopledatalabs';

import fs from 'fs';

// Create a client, specifying your API key
const PDLJSClient = new PDLJS({ apiKey: "YOUR API KEY" });

// Create a parameters JSON object
const params = {
  profile: "linkedin.com/in/samantha_mccall",
  min_likelihood: 6,
  // Use Sandbox API
  sandbox: true
}

// Pass the parameters object to the Person Enrichment API
PDLJSClient.person.enrichment(params).then((data) => {
    var record = data.data
    
    // Print selected fields
    console.log(
        record["work_email"],
        record["full_name"],
        record["job_title"],
        record["job_company_name"],
        )
        
    console.log("Successfully enriched profile with PDL data.")
    
    // Save enrichment data to JSON file
    fs.writeFile("my_pdl_enrichment.jsonl", Buffer.from(JSON.stringify(record)), (err) => {
        if (err) throw err;
    });
}).catch((error) => {
    console.log("Enrichment unsuccessful. See error and try again.")
    console.log(error);
});
```

```ruby Ruby expandable theme={null}
require 'json'

# See https://github.com/peopledatalabs/peopledatalabs-ruby
require 'peopledatalabs'

# Set your API key
Peopledatalabs.api_key = 'YOUR API KEY'

# Use Sandbox API
Peopledatalabs.sandbox = true

# Create a parameters JSON object
PARAMS = {
    "profile": ["linkedin.com/in/samantha_mccall"],
    "min_likelihood": 6
}

# Pass the parameters object to the Person Enrichment API
json_response = Peopledatalabs::Enrichment.person(params: PARAMS)

# Check for successful response
if json_response['status'] == 200
    record = json_response['data']
    
    # Print selected fields
    puts \
        "#{record['work_email']}\
        #{record['full_name']}\
        #{record['job_title']}\
        #{record['job_company_name']}"
    
    puts "Successfully enriched profile with PDL data."
    
    # Save enrichment data to JSON file
    File.open("my_pdl_enrichment.jsonl", "w") do |out|
        out.write(JSON.dump(record) + "\n")
    end
else
    puts "Enrichment unsuccessful. See error and try again."
    puts "error: #{json_response}"
end
```

```go Go expandable theme={null}
package main

import (
    "fmt"
    "os"
    "encoding/json"
    "context"
)

// See https://github.com/peopledatalabs/peopledatalabs-go
import (
    pdl "github.com/peopledatalabs/peopledatalabs-go"
    "github.com/peopledatalabs/peopledatalabs-go/api"
    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 and sandbox usage
    client := pdl.New(apiKey,
                      api.ClientOptions(func(c *api.Client) {
                                    c.Sandbox = true
                      }))
    
    // Create a parameters JSON object
    params := pdlmodel.EnrichPersonParams {
        PersonParams: pdlmodel.PersonParams {
            Profile:  []string{"linkedin.com/in/samantha_mccall"},
        },
         AdditionalParams: pdlmodel.AdditionalParams {
            MinLikelihood: 6,
        },
    }
    
    // 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)
    }
}
```

```python Python3 expandable theme={null}
import requests, json

# Set your API key
API_KEY = "YOUR API KEY"

# Set the Person Enrichment API URL
PDL_URL = "https://sandbox.api.peopledatalabs.com/v5/person/enrich" # Sandbox Person Enrichment API

# Create a parameters JSON object
PARAMS = {
    "api_key": API_KEY,
    "profile": ["linkedin.com/in/samantha_mccall"],
    "min_likelihood": 6
}

# Pass the parameters object to the Sandbox 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)
```

See [Examples - Person Enrichment API](https://docs.peopledatalabs.com/docs/examples-person-enrichment-api.md) for additonal examples.

## Sandbox Bulk Person Enrichment API

To use the Sandbox Bulk Person Enrichment API in URL, set `https://sandbox.api.peopledatalabs.com/v5/person/bulk` as the URL and then use the Bulk Person Enrichment API as usual.

To use the Sandbox Bulk Person Enrichment API with our SDKs, see [SDK usage](https://docs.peopledatalabs.com/docs/sandbox-apis-reference.md#sdk-usage).

After implementing one of the two mechanisms above, you can make use of any of the [examples for the Bulk Person Enrichment API](https://docs.peopledatalabs.com/docs/bulk-enrichment-api.md).

> [!WARNING]
>
> **Enrichment Limitations**
>
> The Sandbox APIs only use the [Sandbox Datasets](https://docs.peopledatalabs.com/docs/sandbox-apis-reference.md#sandbox-dataset).
>
> **This means that you can only enrich profiles from that dataset**.
>
> To find out which profiles you can enrich on, you can either:
>
> <ul><li>Check the [Sandbox Dataset](https://docs.peopledatalabs.com/docs/sandbox-apis-reference.md#sandbox-dataset)</li>
> <li>Run a search query on the [Sandbox Person Search API](https://docs.peopledatalabs.com/docs/sandbox-apis-examples.md#sandbox-person-search-api) to find out which profiles are available to enrich.</li></ul>

### Basic Usage

```python Python3 SDK expandable theme={null}
import json

# See https://github.com/peopledatalabs/peopledatalabs-python
from peopledatalabs import PDLPY

# Create a client, specifying your API key
CLIENT = PDLPY(
    api_key="YOUR API KEY",
    # Use Sandbox API
    sandbox=True,
)

# Create an array of parameters JSON objects
DATA = {
   "requests": [
       {
           "params": {
               "profile": ["linkedin.com/in/samantha_mccall"]
           }
       },
       {
           "params": {
               "profile": ["linkedin.com/in/andrew_williams"]
           }
       }
   ]
}

# Pass the bulk parameters object to the Bulk Person Enrichment API
json_responses = CLIENT.person.bulk(**DATA).json()

# Iterate through the array of API responses
for response in json_responses:
  # Check for successful response
  if response['status'] == 200:
    record = 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.")
  else:
    print("Enrichment unsuccessful. See error and try again.")
    print("error:", response)
```

```javascript JavaScript expandable theme={null}
// 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 an array of parameters JSON objects
const records = {
  // Use Sandbox API
  sandbox: true,
  requests: [
    {
      params: {
        profile: ['linkedin.com/in/samantha_mccall']
      }
    },
    {
      params: {
        profile: ['linkedin.com/in/andrew_williams']
      }
    }
  ]
};

// Pass the parameters object to the Bulk Person Enrichment API
PDLJSClient.person.bulk(records).then((data) => {
    // Iterate through the array of API responses
    for (let response of data) {
        // Check for successful response
        if (response.status == 200) {
            const record = response.data

            // Print selected fields
            console.log(
                record["work_email"],
                record["full_name"],
                record["job_title"],
                record["job_company_name"],
            )

            console.log("Successfully enriched profile with PDL data.")
        } else {
            console.log("Enrichment unsuccessful. See error and try again.")
            console.log(response);
        }
    }
}).catch((error) => {
    console.log("Enrichment unsuccessful. See error and try again.")
    console.log(error);
});
```

```ruby Ruby expandable theme={null}
require 'json'

# See https://github.com/peopledatalabs/peopledatalabs-ruby
require 'peopledatalabs'

# Set your API key
Peopledatalabs.api_key = 'YOUR API KEY'

# Use Sandbox API
Peopledatalabs.sandbox = true

# Create an array of parameters JSON objects
DATA = {
   "requests": [
       {
           "params": {
               "profile": ["linkedin.com/in/samantha_mccall"]
           }
       },
       {
           "params": {
               "profile": ["linkedin.com/in/andrew_williams"]
           }
       }
   ]
}

# Pass the bulk parameters object to the Bulk Person Enrichment API
json_response = Peopledatalabs::Bulk.person(params: DATA)
items = json_response['items']

# Iterate through the array of API responses
items.each do |response|
    # Check for successful response
    if response['status'] == 200
        record = response['data']

        # Print selected fields
        puts \
            "#{record['work_email']} \
             #{record['full_name']} \
             #{record['job_title']} \
             #{record['job_company_name']}"

        puts "Successfully enriched profile with PDL data."
    else
        puts "Enrichment unsuccessful. See error and try again."
        puts "error: #{json_response}"
    end
end
```

```go Go expandable theme={null}
package main

import (
    "fmt"
    "encoding/json"
    "context"
)

// See https://github.com/peopledatalabs/peopledatalabs-go
import (
    pdl "github.com/peopledatalabs/peopledatalabs-go"
    "github.com/peopledatalabs/peopledatalabs-go/api"
    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 and sandbox usage
    client := pdl.New(apiKey,
                      api.ClientOptions(func(c *api.Client) {
                                    c.Sandbox = true
                      }))

    // Create an array of parameters JSON objects
    params := pdlmodel.BulkEnrichPersonParams {
        Requests: []pdlmodel.BulkEnrichSinglePersonParams {
            {
                Params: pdlmodel.PersonParams {
                    Profile:  []string{"linkedin.com/in/samantha_mccall"},
                },
            },
            {
                Params: pdlmodel.PersonParams {
                    Profile:  []string{"linkedin.com/in/andrew_williams"},
                },
           },
        },
    }

    // Pass the parameters object to the Bulk Person Enrichment API
    responses, err := client.Person.BulkEnrich(context.Background(), params)

    // Iterate through the array of API responses
    for _, response := range responses {
        // 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.")
            }
   	    } else {
            fmt.Println("Enrichment unsuccessful. See error and try again.")
            fmt.Println("error:", err)
        }
    }
}
```

```python Python3 expandable theme={null}
import requests, json

# Set your API key
API_KEY = "YOUR API KEY"

# Set the Bulk Person Enrichment API URL
PDL_URL = "https://sandbox.api.peopledatalabs.com/v5/person/bulk" # Sandbox Bulk Person Enrichment API

# Pass your API key in header
HEADERS = {
   'X-Api-Key': API_KEY,
   'Content-Type': 'application/json',
}

# Create an array of parameters JSON objects
DATA = {
   "requests": [
       {
           "params": {
               "profile": ["linkedin.com/in/samantha_mccall"]
           }
       },
       {
           "params": {
               "profile": ["linkedin.com/in/andrew_williams"]
           }
       }
   ]
}

# Pass the bulk parameters object to the Sandbox Bulk Person Enrichment API
json_responses = requests.post(PDL_URL, headers=HEADERS, json=DATA).json()

# Iterate through the array of API responses
for response in json_responses:
  if response["status"] == 200:
    record = 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.")
  else:
    print("Enrichment unsuccessful. See error and try again.")
    print("error:", response)
```

See [Bulk Person Enrichment API](https://docs.peopledatalabs.com/docs/bulk-enrichment-api.md) for additional examples.

## Sandbox Person Search API

To use the Sandbox Person Search API in URL, set `https://sandbox.api.peopledatalabs.com/v5/person/search` as the URL and then use the Person Search API as usual.

To use the Sandbox Person Search API with our SDKs, see [SDK usage](https://docs.peopledatalabs.com/docs/sandbox-apis-reference.md#sdk-usage).

After implementing one of the two mechanisms above, you can make use of any of the [examples for the Person Search API](https://docs.peopledatalabs.com/docs/examples-person-search-api.md). **However, since the Sandbox APIs only use the[Sandbox Dataset](https://docs.peopledatalabs.com/docs/sandbox-apis-reference.md#sandbox-dataset), you can only search for profiles from that dataset**. For example, here is how to perform a simple query following the [Basic Usage example](https://docs.peopledatalabs.com/docs/examples-person-search-api.md#basic-usage):

### Basic Usage

```python Python3 SDK (Elasticsearch) expandable theme={null}
import json

# See https://github.com/peopledatalabs/peopledatalabs-python
from peopledatalabs import PDLPY

# Create a client, specifying your API key
CLIENT = PDLPY(
    api_key="YOUR API KEY",
    # Use Sandbox API
    sandbox=True,
)

# Create an Elasticsearch query
ES_QUERY = {
  "query": {
    "bool": {
        "must": [
            {"term": {"location_country": "united states"}},
            {"exists": {"field": "emails"}}
      ]
    }
  }
}

# Create a parameters JSON object
PARAMS = {
  'query': ES_QUERY,
  'size': 10,
  'pretty': True
}

# Pass the parameters object to the Person Search API
response = CLIENT.person.search(**PARAMS).json()

# Check for successful response
if response["status"] == 200:
  data = response['data']
  # Write out each profile found to file
  with open("my_pdl_search.jsonl", "w") as out:
    for record in data:
      out.write(json.dumps(record) + "\n")
  print(f"Successfully grabbed {len(data)} records from PDL.")
  print(f"{response['total']} total PDL records exist matching this query.")
else:
  print("NOTE: The carrier pigeons lost motivation in flight. See error and try again.")
  print("Error:", response)
```

```javascript JavaScript (Elasticsearch) expandable theme={null}
// See https://github.com/peopledatalabs/peopledatalabs-js
import PDLJS from 'peopledatalabs';

import fs from 'fs';

// Create a client, specifying your API key
const PDLJSClient = new PDLJS({ apiKey: "YOUR API KEY" });

// Create an Elasticsearch query
const esQuery = {
  query: {
    bool: {
      must:[
        {term: {location_country: "united states"}}, 
        {exists: {field: "emails"}}
      ]
    }
  }
}

// Create a parameters JSON object
const params = {
  searchQuery: esQuery, 
  size: 10,
  pretty: true,
  // Use Sandbox API
  sandbox: true
}

// Pass the parameters object to the Person Search API
PDLJSClient.person.search.elastic(params).then((data) => {
    // Write out all profiles found to file
    fs.writeFile("my_pdl_search.jsonl", Buffer.from(JSON.stringify(data.data)), (err) => {
        if (err) throw err;
    });
    console.log(`Successfully grabbed ${data.data.length} records from PDL.`);
    console.log(`${data["total"]} total PDL records exist matching this query.`)
}).catch((error) => {
    console.log("NOTE: The carrier pigeons lost motivation in flight. See error and try again.")
    console.log(error);
});
```

```ruby Ruby (Elasticsearch) expandable theme={null}
require 'json'

# See https://github.com/peopledatalabs/peopledatalabs-ruby
require 'peopledatalabs'

# Set your API key
Peopledatalabs.api_key = 'YOUR API KEY'

# Use Sandbox API
Peopledatalabs.sandbox = true

# Create an Elasticsearch query
ES_QUERY = {
  "query": {
    "bool": {
        "must": [
            {"term": {"location_country": "united states"}},
           {"exists": {"field": "emails"}}
      ]
    }
  }
}

# Pass parameters to the Person Search API
response = Peopledatalabs::Search.person(searchType: 'elastic', query: ES_QUERY, size: 10, pretty: true)

# Check for successful response
if response['status'] == 200
    data = response['data']
    # Write out each profile found to file
    File.open("my_pdl_search.jsonl", "w") do |out|
        data.each { |record| out.write(JSON.dump(record) + "\n") }
    end
    puts "Successfully grabbed #{data.length()} records from PDL."
    puts "#{response['total']} total PDL records exist matching this query."
else
    puts "NOTE: The carrier pigeons lost motivation in flight. See error and try again."
    puts "Error: #{response}"
end
```

```go Go (Elasticsearch) expandable theme={null}
package main

import (
    "fmt"
    "os"
    "encoding/json"
    "context"
)

// See https://github.com/peopledatalabs/peopledatalabs-go
import (
    pdl "github.com/peopledatalabs/peopledatalabs-go"
    "github.com/peopledatalabs/peopledatalabs-go/api"
    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 and sandbox usage
    client := pdl.New(apiKey,
                      api.ClientOptions(func(c *api.Client) {
                                    c.Sandbox = true
                      }))

    // Create an Elasticsearch query
    elasticSearchQuery := map[string]interface{} {
        "query": map[string]interface{} {
            "bool": map[string]interface{} {
                "must": []map[string]interface{} {
                    {"term": map[string]interface{}{"location_country": "united states"}},
                    {"exists": map[string]interface{}{"field": "emails"}},
                },
            },
        },
    }

    // Create a parameters JSON object
    params := pdlmodel.SearchParams {
        BaseParams: pdlmodel.BaseParams {
            Size: 10,
            Pretty: true,
        },
        SearchBaseParams: pdlmodel.SearchBaseParams {
            Query: elasticSearchQuery,
        },
    }
    
    // Pass the parameters object to the Person Search API
    response, err := client.Person.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)
    } 
}
```

```python Python3 (Elasticsearch) expandable theme={null}
import requests, json

# Set your API key
API_KEY = "YOUR API KEY"

# Set the Person Search API URL
PDL_URL = "https://sandbox.api.peopledatalabs.com/v5/person/search" # Sandbox Person Search API
# PDL_URL = "https://api.peopledatalabs.com/v5/person/search" # Production Person Search API

# Set headers
HEADERS = {
  'Content-Type': "application/json",
  'X-api-key': API_KEY
}

# Create an Elasticsearch query
ES_QUERY = {
  "query": {
    "bool": {
        "must": [
            {"term": {"location_country": "united states"}},
            {"exists": {"field": "emails"}}
      ]
    }
  }
}

# Create a parameters JSON object
PARAMS = {
  'query': json.dumps(ES_QUERY),
  'size': 10,
  'pretty': True
}

# Pass the parameters object to the Sandbox Person Search API
response = requests.get(
  PDL_URL,
  headers=HEADERS,
  params=PARAMS
).json()

# Check for successful response
if response["status"] == 200:
  data = response['data']
  # Write out each profile found to file
  with open("my_pdl_search.jsonl", "w") as out:
    for record in data:
      out.write(json.dumps(record) + "\n")
  print(f"Successfully grabbed {len(data)} records from PDL.")
  print(f"{response['total']} total PDL records exist matching this query.")
else:
  print("NOTE: The carrier pigeons lost motivation in flight. See error and try again.")
  print("Error:", response)
```

See [Examples - Person Search API](https://docs.peopledatalabs.com/docs/examples-person-search-api.md) for additional examples.

## Sandbox Person Identify API

To use the Sandbox Person Identify API in URL, set `https://sandbox.api.peopledatalabs.com/v5/person/identify` as the URL and then use the Person Identify API as usual.

To use the Sandbox Person Identify API with our SDKs, see [SDK usage](https://docs.peopledatalabs.com/docs/sandbox-apis-reference.md#sdk-usage).

After implementing one of the two mechanisms above, you can make use of any of the [examples for the Person Identify API](https://docs.peopledatalabs.com/docs/identify-api-examples.md).

> [!WARNING]
>
> **Matching Limitations**
>
> The Sandbox APIs only use the [Sandbox Datasets](https://docs.peopledatalabs.com/docs/sandbox-apis-reference.md#sandbox-dataset).
>
> **This means that you can only match profiles from that dataset**.
>
> To find out which profiles you can match on, you can either:
>
> <ul><li>Check the [Sandbox Dataset](https://docs.peopledatalabs.com/docs/sandbox-apis-reference.md#sandbox-dataset)</li>
> <li>Run a search query on the [Sandbox Person Search API](https://docs.peopledatalabs.com/docs/sandbox-apis-examples.md#sandbox-person-search-api) to find out which profiles are available to match.</li></ul>

> [!NOTE]
>
> **Include more than just `company`**
>
> The production [Basic Usage example](https://docs.peopledatalabs.com/docs/identify-api-examples.md#basic-usage) identifies matches using `company` alone, which works well against a company with many employees (like Walmart). Because the Sandbox Dataset only contains a small sample of records per company, pair `company` with at least one more field (like `name`) to reliably get a match in the sandbox.

### Basic Usage

```python Python3 SDK theme={null}
import json

# See https://github.com/peopledatalabs/peopledatalabs-python
from peopledatalabs import PDLPY

# Create a client, specifying your API key
CLIENT = PDLPY(
    api_key="YOUR API KEY",
    # Use Sandbox API
    sandbox=True,
)

# Create a parameters JSON object
PARAMS = {
 "company": "wade inc",
 "name": "craig james gonzalez",
 "pretty": True
}

# Pass the parameters object to the Person Identify API
response_data = CLIENT.person.identify(**PARAMS).json()

# Create a list of matches
identities = response_data['matches']

# Print the matches in JSON format
print(identities)
print(f"Found {len(identities)} identities!")
```

```javascript JavaScript theme={null}
// 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 = {
  company: "wade inc",
  name: "craig james gonzalez",
  pretty: true,
  // Use Sandbox API
  sandbox: true
}

// Pass the parameters object to the Person Identify API
PDLJSClient.person.identify(params).then((data) => {
  // Create a list of matches
  var identities = data["matches"]
  
  // Print the matches in JSON format
  console.log(identities);
  console.log(`Found ${identities.length} identities!`)
}).catch((error) => {
  console.log(error);
});
```

```ruby Ruby theme={null}
# See https://github.com/peopledatalabs/peopledatalabs-ruby
require 'peopledatalabs'

# Set your API key
Peopledatalabs.api_key = 'YOUR API KEY'

# Use Sandbox API
Peopledatalabs.sandbox = true

# Create a parameters JSON object
PARAMS = {
 "company": "wade inc",
 "name": "craig james gonzalez",
 "pretty": true
}

# Pass the parameters object to the Person Identify API
response = Peopledatalabs::Identify.person(params: PARAMS)

# Create a list of matches
identities = response['matches']

# Print the matches in JSON format
puts identities
puts "Found #{identities.length()} identities!"
```

```go Go expandable theme={null}
package main

import (
    "fmt"
    "encoding/json"
    "context"
)

// See https://github.com/peopledatalabs/peopledatalabs-go
import (
    pdl "github.com/peopledatalabs/peopledatalabs-go"
    "github.com/peopledatalabs/peopledatalabs-go/api"
    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 and sandbox usage
    client := pdl.New(apiKey,
                      api.ClientOptions(func(c *api.Client) {
                                    c.Sandbox = true
                      }))
    
    // Create a parameters JSON object
    params := pdlmodel.IdentifyPersonParams {
        BaseParams: pdlmodel.BaseParams {
            Pretty: true,
        },
        PersonParams: pdlmodel.PersonParams {
             Company: []string{"wade inc"},
             Name: []string{"craig james gonzalez"},
        },
    }
    
    // Pass the parameters object to the Person Identify API
    response, err := client.Person.Identify(context.Background(), params)
    // Check for successful response
    if err == nil {
        // Create a list of matches
        identities := response.Matches
        // Convert the matches to JSON
        jsonResponse, jsonErr := json.Marshal(identities)
        // Print the matches
        if (jsonErr == nil) {
            fmt.Println(string(jsonResponse))
        }
        
        fmt.Printf("Found %d identities!\n", len(identities))
    } else {
        fmt.Println(err)
    }
}
```

```python Python3 theme={null}
import requests

# Set your API key
API_KEY = "YOUR API KEY"

# Set the Person Identify API URL
PDL_URL = "https://sandbox.api.peopledatalabs.com/v5/person/identify" # Sandbox Identify API

# Create a parameters JSON object
PARAMS = {
  "company": "wade inc",
  "name": "craig james gonzalez",
  "pretty": True,
  "api_key": API_KEY
}

# Pass the parameters object to the Sandbox Person Identify API
response = requests.request("GET", PDL_URL, params=PARAMS)

response_data = response.json()

# Create a list of matches
identities = response_data['matches']

# Print the matches in JSON format
print(identities)
print(f"Found {len(identities)} identities!")
```

See [Examples - Person Identify API](https://docs.peopledatalabs.com/docs/identify-api) for additional examples.

## Sandbox Company Enrichment API

To use the Sandbox Company Enrichment API in URL, set `https://sandbox.api.peopledatalabs.com/v5/company/enrich` as the URL and then use the Company Enrichment API as usual.

To use the Sandbox Company Enrichment API with our SDKs, see [SDK usage](https://docs.peopledatalabs.com/docs/sandbox-apis-reference.md#sdk-usage).

After implementing one of the two mechanisms above, you can make use of any of the [examples for the Company Enrichment API](https://docs.peopledatalabs.com/docs/examples-company-enrichment-api.md).

> [!WARNING]
>
> **Enrichment Limitations**
>
> The Sandbox APIs only use the [Sandbox Datasets](https://docs.peopledatalabs.com/docs/sandbox-apis-reference.md#sandbox-dataset).
>
> **This means that you can only enrich companies from that dataset**.
>
> To find out which companies you can enrich on, you can either:
>
> <ul><li>Check the [Sandbox Dataset](https://docs.peopledatalabs.com/docs/sandbox-apis-reference.md#sandbox-dataset)</li>
> <li>Run a search query on the [Sandbox Company Search API](https://docs.peopledatalabs.com/docs/sandbox-apis-examples.md#sandbox-company-search-api) to find out which companies are available to enrich.</li></ul>

### Basic Usage

```python Python3 SDK theme={null}
# See https://github.com/peopledatalabs/peopledatalabs-python
from peopledatalabs import PDLPY

# Create a client, specifying your API key
CLIENT = PDLPY(
    api_key="YOUR API KEY",
    # Use Sandbox API
    sandbox=True,
)

# Create a parameters JSON object
QUERY_STRING = {"website": "adecco.com.pe"}

# Pass the parameters object to the Company Enrichment API
response = CLIENT.company.enrichment(**QUERY_STRING)

# Print the API response
print(response.text)
```

```javascript JavaScript theme={null}
// 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 queryString = {
  website: "adecco.com.pe",
  // Use Sandbox API
  sandbox: true
}

// Pass the parameters object to the Company Enrichment API
PDLJSClient.company.enrichment(queryString).then((data) => {
    // Print the API response
    console.log(data);
}).catch((error) => {
    console.log(error);
});
```

```ruby Ruby theme={null}
# See https://github.com/peopledatalabs/peopledatalabs-ruby
require 'peopledatalabs'

# Set your API key
Peopledatalabs.api_key = 'YOUR API KEY'

# Use Sandbox API
Peopledatalabs.sandbox = true

# Create a parameters JSON object
QUERY_STRING = {"website": "adecco.com.pe"}

# Pass the parameters object to the Company Enrichment API
response = Peopledatalabs::Enrichment.company(params: QUERY_STRING)

# Print the API response
puts response
```

```go Go expandable theme={null}
package main

import (
    "fmt"
    "context"
)

// See https://github.com/peopledatalabs/peopledatalabs-go
import (
    pdl "github.com/peopledatalabs/peopledatalabs-go"
    "github.com/peopledatalabs/peopledatalabs-go/api"
    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 and sandbox usage
    client := pdl.New(apiKey,
                      api.ClientOptions(func(c *api.Client) {
                                    c.Sandbox = true
                      }))

    // Create a parameters JSON object
    queryString := pdlmodel.CompanyParams{Website: "adecco.com.pe"}

    params := pdlmodel.EnrichCompanyParams{
        CompanyParams: queryString,
    }

    // Pass the parameters object to the Company Enrichment API
    response, err := client.Company.Enrich(context.Background(), params)
    // Check for successful response
    if err == nil {
        // Print the API response
        fmt.Println(response)
    }
}
```

```python Python3 theme={null}
import requests

# Set your API key
API_KEY = "YOUR API KEY"

# Set the Company Enrichment API URL
PDL_URL = "https://sandbox.api.peopledatalabs.com/v5/company/enrich" # Sandbox Company Enrichment API

# Create a parameters JSON object
QUERY_STRING = {"website": "adecco.com.pe"}

# Set headers
HEADERS = {
    'accept': "application/json",
    'content-type': "application/json",
    'x-api-key': API_KEY
    }

# Pass the parameters object to the Sandbox Company Enrichment API
response = requests.request("GET", PDL_URL, headers=HEADERS, params=QUERY_STRING)

# Print the API response
print(response.text)
```

See [Examples - Company Enrichment API](https://docs.peopledatalabs.com/docs/examples-company-enrichment-api.md) for additional examples.

## Sandbox Company Search API

To use the Sandbox Company Search API in URL, set `https://sandbox.api.peopledatalabs.com/v5/company/search` as the URL and then use the Company Search API as usual.

To use the Sandbox Company Search API with our SDKs, see [SDK usage](https://docs.peopledatalabs.com/docs/sandbox-apis-reference.md#sdk-usage).

After implementing one of the two mechanisms above, you can make use of any of the [examples for the Company Search API](https://docs.peopledatalabs.com/docs/examples-company-search-api.md). **However, since the Sandbox APIs only use the [Sandbox Dataset](https://docs.peopledatalabs.com/docs/sandbox-apis-reference.md#datasets), you can only search for companies from that dataset**. For example, here is how to perform a simple query following the [Basic Usage example](https://docs.peopledatalabs.com/docs/examples-company-search-api.md#basic-usage):

### Basic Usage

```python Python3 SDK (Elasticsearch) expandable theme={null}
import json

# See https://github.com/peopledatalabs/peopledatalabs-python
from peopledatalabs import PDLPY

# Create a client, specifying your API key
CLIENT = PDLPY(
    api_key="YOUR API KEY",
    # Use Sandbox API
    sandbox=True,
)

# Create an Elasticsearch query
ES_QUERY = {
  "query": {
    "bool": {
      "must": [
        {"exists": {"field": "website"}}
      ]
    }
  }
}

# Create a parameters JSON object
PARAMS = {
  'query': ES_QUERY,
  'size': 10,
  'pretty': True
}

# Pass the parameters object to the Company Search API
response = CLIENT.company.search(**PARAMS).json()

# Check for successful response
if response["status"] == 200:
  data = response['data']
  # Write out each profile found to file
  with open("my_pdl_search.jsonl", "w") as out:
    for record in data:
      out.write(json.dumps(record) + "\n")
  print(f"Successfully grabbed {len(data)} records from PDL.")
  print(f"{response['total']} total PDL records exist matching this query.")
else:
  print("NOTE: The carrier pigeons lost motivation in flight. See error and try again.")
  print("Error:", response)
```

```javascript JavaScript (Elasticsearch) expandable theme={null}
// See https://github.com/peopledatalabs/peopledatalabs-js
import PDLJS from 'peopledatalabs';

import fs from 'fs';

// Create a client, specifying your API key
const PDLJSClient = new PDLJS({ apiKey: "YOUR API KEY" });

// Create an Elasticsearch query
const esQuery = {
  query: {
    bool: {
      must:[
        {"exists": {"field": "website"}}
      ]
    }
  }
}

// Create a parameters JSON object
const params = {
  searchQuery: esQuery,
  size: 10,
  pretty: true,
  // Use Sandbox API
  sandbox: true
}

// Pass the parameters object to the Company Search API
PDLJSClient.company.search.elastic(params).then((data) => {
    // Write out all profiles found to file
    fs.writeFile("my_pdl_search.jsonl", Buffer.from(JSON.stringify(data.data)), (err) => {
        if (err) throw err;
    });
    console.log(`Successfully grabbed ${data.data.length} records from PDL.`);
    console.log(`${data["total"]} total PDL records exist matching this query.`)
}).catch((error) => {
    console.log("NOTE: The carrier pigeons lost motivation in flight. See error and try again.")
    console.log(error);
});
```

```ruby Ruby (Elasticsearch) expandable theme={null}
require 'json'

# See https://github.com/peopledatalabs/peopledatalabs-ruby
require 'peopledatalabs'

# Set your API key
Peopledatalabs.api_key = 'YOUR API KEY'

# Use Sandbox API
Peopledatalabs.sandbox = true

# Create an Elasticsearch query
ES_QUERY = {
  "query": {
    "bool": {
      "must": [
        {"exists": {"field": "website"}},
      ]
    }
  }
}

# Pass parameters to the Company Search API
response = Peopledatalabs::Search.company(searchType: 'elastic', query: ES_QUERY, size: 10, pretty: true)

# Check for successful response
if response['status'] == 200
    data = response['data']
    # Write out each profile found to file
    File.open("my_pdl_search.jsonl", "w") do |out|
        data.each { |record| out.write(JSON.dump(record) + "\n") }
    end
    puts "Successfully grabbed #{data.length()} records from PDL."
    puts "#{response['total']} total PDL records exist matching this query."
else
    puts "NOTE: The carrier pigeons lost motivation in flight. See error and try again."
    puts "Error: #{response}"
end
```

```go Go (Elasticsearch) expandable theme={null}
package main

import(
    "fmt"
    "os"
    "encoding/json"
    "context"
)

// See https://github.com/peopledatalabs/peopledatalabs-go
import (
    pdl "github.com/peopledatalabs/peopledatalabs-go"
    "github.com/peopledatalabs/peopledatalabs-go/api"
    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 and sandbox usage
    client := pdl.New(apiKey,
                      api.ClientOptions(func(c *api.Client) {
                                    c.Sandbox = true
                      }))

    // Create an Elasticsearch query
    elasticSearchQuery := map[string]interface{} {
        "query": map[string]interface{} {
            "bool": map[string]interface{} {
                "must": []map[string]interface{} {
                    {"exists": map[string]interface{}{"field": "website"}},
                },
            },
        },
    }

    // Create a parameters JSON object
    params := pdlmodel.SearchParams {
        BaseParams: pdlmodel.BaseParams {
            Size: 10,
            Pretty: true,
        },
        SearchBaseParams: pdlmodel.SearchBaseParams {
            Query: elasticSearchQuery,
        },
    }

    // 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)
    }
}
```

```python Python3 (Elasticsearch) expandable theme={null}
import requests, json

# Set your API key
API_KEY = "YOUR API KEY"

# Set the Company Search API URL
PDL_URL = "https://sandbox.api.peopledatalabs.com/v5/company/search" # Sandbox Company Search API
# PDL_URL = "https://api.peopledatalabs.com/v5/company/search" # Production Company Search API

# Set headers
HEADERS = {
  'Content-Type': "application/json",
  'X-api-key': API_KEY
}

# Create an Elasticsearch query
ES_QUERY = {
  "query": {
    "bool": {
      "must": [
        {"exists": {"field": "website"}}
      ]
    }
  }
}

# Create a parameters JSON object
PARAMS = {
  'query': json.dumps(ES_QUERY),
  'size': 10,
  'pretty': True
}

# Pass the parameters object to the Sandbox Company Search API
response = requests.get(
  PDL_URL,
  headers=HEADERS,
  params=PARAMS
).json()

# Check for successful response
if response["status"] == 200:
  data = response['data']
  # Write out each profile found to file
  with open("my_pdl_search.jsonl", "w") as out:
    for record in data:
      out.write(json.dumps(record) + "\n")
  print(f"Successfully grabbed {len(data)} records from PDL.")
  print(f"{response['total']} total PDL records exist matching this query.")
else:
  print("NOTE: The carrier pigeons lost motivation in flight. See error and try again.")
  print("Error:", response)
```

See [Examples - Company Search API](https://docs.peopledatalabs.com/docs/examples-company-search-api.md) for additional examples.

## Sandbox Job Posting Search API

To use the Sandbox Job Posting Search API, set `https://sandbox.api.peopledatalabs.com/v5/job_posting/search` as the URL and then use the Job Posting Search API as usual.

After implementing this, you can make use of any of the [examples for the Job Posting Search API](https://docs.peopledatalabs.com/docs/examples-job-posting-search-api.md).

> [!NOTE]
>
> You can only search job postings from the [Sandbox Dataset](https://docs.peopledatalabs.com/docs/sandbox-apis-reference.md#datasets) with the Sandbox API.

For example, here is how to perform a simple query following the [Basic Search example](https://docs.peopledatalabs.com/docs/examples-job-posting-search-api.md#basic-search-company--title):

### Basic Usage

```python Python theme={null}
import requests

API_KEY = "YOUR API KEY"

# Set the Job Posting Search API URL
PDL_URL = "https://sandbox.api.peopledatalabs.com/v5/job_posting/search" # Sandbox Job Posting Search API
# PDL_URL = "https://api.peopledatalabs.com/v5/job_posting/search" # Production Job Posting Search API

payload = {
    "company_website": "hackajob.com",
    "title_role": "engineering",
    "size": 3,
    "pretty": True,
    "api_key": API_KEY
}

response = requests.post(PDL_URL, json=payload)
print(response.text)
```

```bash cURL theme={null}
curl -X POST "https://sandbox.api.peopledatalabs.com/v5/job_posting/search" \
  -H "Content-Type: application/json" \
  -d '{
    "company_website": "hackajob.com",
    "title_role": "engineering",
    "size": 3,
    "pretty": true,
    "api_key": "YOUR API KEY"
  }'
```

See [Examples - Job Posting Search API](https://docs.peopledatalabs.com/docs/examples-job-posting-search-api.md) for additional examples.


## Related topics

- [Reference - Sandbox APIs](https://docs.peopledatalabs.com/docs/sandbox-apis-reference.md)
- [Examples - Cleaner APIs](https://docs.peopledatalabs.com/docs/examples-cleaner-apis.md)
- [July 2022 Release Notes](https://docs.peopledatalabs.com/changelog/july-2022-release-notes-v19.md)
- [Sandbox API Endpoints](https://docs.peopledatalabs.com/docs/sandbox-apis.md)
- [Building API workflows with an AI assistant](https://docs.peopledatalabs.com/docs/api-workflows-with-an-ai-assistant.md)
