Request Parameters
There are two primary ways to pass parameters in an API request:
- Set the parameters directly in the URL of the API request.
- Set the parameters through a parameters JSON object.
We recommend that you pass parameters through a JSON object, though you may also pass parameters in the URL if you'd like. Anything that we find in a JSON object will take precedence over parameters that we find in the URL.
Here is an example of using parameters with our Person Enrichment API for reference:
In URL
import requests
url = "https://api.peopledatalabs.com/v5/person/enrich?api_key={YOUR API KEY}&company=People Data Labs&profile=linkedin.com/in/linfluencer"
response = requests.get(url)
print(response.text)
curl -X GET -G \
'https://api.peopledatalabs.com/v5/person/enrich'\
-H 'X-Api-Key: YOUR API KEY' \
--data-urlencode 'company=People Data Labs'\
--data-urlencode 'profile=linkedin.com/in/linfluencer'
// Complete URL with parameters
const url = 'https://api.peopledatalabs.com/v5/person/enrich?api_key={YOUR API KEY}&company=People Data Labs&profile=linkedin.com/in/linfluencer';
// Send GET request
fetch(url)
.then(response => {
if (!response.ok) {
throw new Error('There was an error.');
}
return response.json();
})
.then(data => {
console.log('Data:', data);
})
.catch(error => {
console.error('There was a problem with the fetch operation:', error);
});
require 'net/http'
require 'uri'
# Base URL of the API
url = URI('https://api.peopledatalabs.com/v5/person/enrich?api_key={YOUR API KEY}&company=People Data Labs&profile=linkedin.com/in/linfluencer')
# Send GET request
response = Net::HTTP.get(url)
# Handle the response
if response
puts "Response: #{response}"
else
puts "Error: Unable to get data"
end
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main() {
// Base URL of the API
URL := "https://api.peopledatalabs.com/v5/person/enrich?api_key={YOUR API KEY}&company=People Data Labs&profile=linkedin.com/in/linfluencer"
// Send GET request
resp, err := http.Get(URL)
if err != nil {
fmt.Println("Error:", err)
return
}
defer resp.Body.Close()
// Read and print the response
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response:", err)
return
}
fmt.Println("Response:", string(body))
}
In a JSON Object
# 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",
)
# Create a parameters JSON object
PARAMS = {
"company": "People Data Labs",
"email": "[email protected]".
"profile": "linkedin.com/in/linfluencer"
}
# Pass the parameters object to the Person Enrichment API
json_response = CLIENT.person.enrichment(**PARAMS).json()
# Print the API response in JSON format
print(json_response)
// 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: "Hallspot",
company: "People Data Labs",
email: "[email protected]"
}
// Pass the parameters object to the Person Enrichment API
PDLJSClient.person.enrichment(params).then((jsonResponse) => {
// Print the API response in JSON format
console.log(jsonResponse);
}).catch((error) => {
console.log(error);
});
require 'json'
# See https://github.com/peopledatalabs/peopledatalabs-ruby
require 'peopledatalabs'
# Set your API key
Peopledatalabs.api_key = 'YOUR API KEY'
# Create a parameters JSON object
PARAMS = {
"company": ["Hallspot", "People Data Labs"],
"email": ["[email protected]"]
}
# Pass the parameters object to the Person Enrichment API
json_response = JSON.dump(Peopledatalabs::Enrichment.person(params: PARAMS))
# Print the API response in JSON format
puts json_response
package main
import (
"fmt"
"encoding/json"
"context"
)
// See https://github.com/peopledatalabs/peopledatalabs-go
import (
pdl "github.com/peopledatalabs/peopledatalabs-go"
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
client := pdl.New(apiKey)
// Create a parameters JSON object
params := pdlmodel.EnrichPersonParams {
PersonParams: pdlmodel.PersonParams {
Company: []string{"Hallspot", "People Data Labs"},
Email: []string{"[email protected]"},
},
}
// 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)
// Print the API response
if (jsonErr == nil) {
fmt.Println(string(jsonResponse))
}
}
}
import requests
# Set your API key
API_KEY = "YOUR API KEY"
# Set the Person Enrichment API URL
PDL_URL = "https://api.peopledatalabs.com/v5/person/enrich"
# Create a parameters JSON object
PARAMS = {
"api_key": API_KEY,
"company": ["Hallspot", "People Data Labs"],
"email": ["[email protected]"]
}
# Pass the parameters object to the Person Enrichment API
json_response = requests.get(PDL_URL, params=PARAMS).json()
# Print the API response in JSON format
print(json_response)
Updated 3 months ago