Crates.io | peopledatalabs |
lib.rs | peopledatalabs |
version | 2.2.0 |
source | src |
created_at | 2023-09-13 21:58:31.882299 |
updated_at | 2024-09-17 15:28:32.569336 |
description | A Rust client for the People Data Labs API |
homepage | https://www.peopledatalabs.com |
repository | https://github.com/peopledatalabs/peopledatalabs-rust |
max_upload_size | |
id | 971994 |
size | 135,168 |
Official Rust client for the People Data Labs API.
cargo add peopledatalabs
First, create the PeopleDataLabs client:
let api_key = std::env::var("PDL_API_KEY").unwrap();
let client = PDL::new(&api_key);
Then, send requests to any PDL API Endpoint.
let mut person_params = PersonParams::default();
person_params.name = Some(vec!["josh finnie".to_string()]);
person_params.location = Some(vec!["washington, dc".to_string()]);
let mut enrich_params = EnrichPersonParams::default();
enrich_params.person_params = person_params.clone();
let results = client.person.enrich(enrich_params);
let mut person_params = PersonParams::default();
person_params.name = Some(vec!["josh finnie".to_string()]);
person_params.location = Some(vec!["washington, dc".to_string()]);
let request = BulkEnrichSinglePersonParams {
params: person_params.clone(),
metadata: None,
};
let bulk_enrich_params = BulkEnrichPersonParams {
requests: vec![request],
};
let results = client.person.bulk_enrich(bulk_enrich_params);
let mut search_base_params = SearchBaseParams::default();
search_base_params.query = Some(serde_json::value::Value::String(
"{'bool':{'must': [{'term': {'job_title_role': 'health'}},]}}".to_string(),
));
let mut search_params = SearchParams::default();
search_params.search_base_params = search_base_params;
let search_results = client.person.search(search_params);
let query = r#"
SELECT * FROM person
WHERE location_country='mexico'
AND job_title_role='health'
AND phone_numbers IS NOT NULL;
"#.to_string();
let mut search_base_params = SeachBaseParams::default();
search_base_params.sql = query;
let mut seach_params = SearchParams::default();
search_params.search_base_params = search_base_params;
let search_results = client.person.searach(seach_params);
PDL_ID
(Retrieve API)let retrieve_person_params = RetrievePersonParams {
base_params: None,
person_id: "82MYIGZzMttzdyKiQBv4ZQ_0000".to_string(),
};
let retrieve_results = client.person.retrieve(retrieve_person_params);
let retrieve_request = BulkRetrieveSinglePersonParams {
id: "82MYIGZzMttzdyKiQBv4ZQ_0000".to_string(),
metadata: None,
};
let mut bulk_retrieve_params = BulkRetrievePersonParams::default();
bulk_retrieve_params.requests = vec![retrieve_request];
let bulk_retrieve_results = client.person.bulk_retrieve(bulk_retrieve_params);
let mut person_params = PersonParams::default();
person_params.name = Some(vec!["josh finnie".to_string()]);
person_params.location = Some(vec!["washington, dc".to_string()]);
let mut identify_params = IdentifyPersonParams::default();
identify_params.person_params = person_params.clone();
let identify_results = client.person.identify(identify_params);
let mut company_params = CompanyParams::default();
company_params.name = Some("google".to_string());
let enrich_params = EnrichCompanyParams {
base_params: None,
company_params,
additional_params: None,
};
let enrich_request = client.company.enrich(enrich_params);
let mut search_base_params = SearchBaseParams::default();
search_base_params.query = Some(serde_json::value::Value::String(
r#"{'query': {'bool': {'must': {
{"term": {"tags": "bigdata"}},
{"term": {"industry": "financial services"}},
{"term": {"location.country": "united states"}},
},},},
}"#.to_string(),
));
let mut search_params = SearchParams::default();
search_params.search_base_params = search_base_params;
let search_results = client.company.search(search_params);
let mut search_base_params = SearchBaseParams::default();
search_base_params.sql = Some("SELECT * FROM company WHERE website='google.com';".to_string());
let search_params = SearchParams {
base_params: None,
search_base_params,
additional_params: None,
};
let search_results = client.company.search(search_params);
let autocomplete_base_params = AutocompleteBaseParams{
field: "text".to_string(),
text: Some("full".to_string())
};
let autocomplete_params = AutocompleteParams {
base_params: None,
autocomplete_base_params,
};
let request = client.autocomplete.autocomplete(autocomplete_params);
let mut clean_params = CleanCompanyParams::default();
clean_params.name = Some("google".to_string());
let clean_results = client.company.clean(clean_params);
let base_params = BaseParams::default();
let location_params = LocationParams {
location: Some("New York, NY".to_string()),
};
let params = CleanLocationParams {
base_params: None,
location_params,
additional_params: None,
};
let results = client.location.clean(params);
let mut school_params = SchoolParams::default();
school_params.name = Some("UConn".to_string());
let params = CleanSchoolParams {
base_params: None,
school_params,
additional_params: None,
};
let results = client.school.clean(params);
let job_title_base_params = JobTitleBaseParams {
job_title: Some("software engineer".to_string()),
};
let params = JobTitleParams {
base_params: None,
job_title_base_params,
};
let results = client.job_title.get(params);
let skill_base_params = SkillBaseParams {
skill: Some("python".to_string()),
};
let params = SkillParams {
base_params: None,
skill_base_params,
};
let results = client.skill.get(params);
let mut ip_base_params = IPBaseParams::default();
ip_base_params.ip = Some("72.212.42.169".to_string());
let params = IPParams {
base_params: None,
ip_base_params,
};
let results = client.ip.get(params);
// To enable sandbox usage, pass in the following options to the PDLClient before building
let api_key = std::env::var("PDL_API_KEY").unwrap();
let mut client_options = PDLCLientOptions::default();
client_options.sandbox = true;
let client = PDLClient::new(&api_key).options(client_options).build();
Person Endpoints
API Endpoint | SDK Function |
---|---|
Person Enrichment API | client.person.enrich(params) |
Person Bulk Enrichment API | client.person.bulk_enrich(params) |
Person Search API | client.person.search(params) |
Person Retrieve API | client.person.retrieve(params) |
Person Bulk Retrieve API | client.person.bulk_retrieve(params) |
Person Identify API | client.person.identify(params) |
Company Endpoints
API Endpoint | SDK Function |
---|---|
Company Enrichment API | client.company.enrich(params) |
Company Search API | client.company.search(params) |
Supporting Endpoints
API Endpoint | SDK Function |
---|---|
Autocomplete API | client.autocomplete.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.job_title.enrich(params) |
Skill Enrichment API | client.skill.enrich(params) |
IP Enrichment API | client.ip.enrich(params) |
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.