Skip to content

Commit c8a3332

Browse files
Add customSearchUrl parameter
1 parent 4289d36 commit c8a3332

File tree

5 files changed

+114
-3
lines changed

5 files changed

+114
-3
lines changed

examples/search-companies.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ async function searchCompaniesExample(): Promise<void> {
1010
console.log('🚀 Linked API searchCompanies example starting...');
1111

1212
await standardExample(linkedapi);
13+
await standardExampleWithCustomSearchUrl(linkedapi);
1314
await salesNavigatorExample(linkedapi);
15+
await salesNavigatorWithCustomUrlExample(linkedapi);
1416

1517
} catch (error) {
1618
if (error instanceof LinkedApiError) {
@@ -54,6 +56,31 @@ async function standardExample(linkedapi: LinkedApi): Promise<void> {
5456
}
5557
}
5658

59+
async function standardExampleWithCustomSearchUrl(linkedapi: LinkedApi): Promise<void> {
60+
const searchParams = {
61+
customSearchUrl: 'https://www.linkedin.com/search/results/companies/?companySize=%5B%22B%22%5D&keywords=Linked%20API',
62+
};
63+
64+
console.log('🔍 Searching companies with custom search URL...');
65+
const workflowId = await linkedapi.searchCompanies.execute(searchParams);
66+
console.log('🔍 Workflow started:', workflowId);
67+
const result = await linkedapi.searchCompanies.result(workflowId);
68+
if (result.data) {
69+
const results = result.data;
70+
console.log('✅ Company search completed');
71+
console.log(`📊 Found ${results.length} companies`);
72+
results.forEach((company, index) => {
73+
console.log(` ${index + 1}. ${company.name}`);
74+
console.log(` Industry: ${company.industry}`);
75+
console.log(` Location: ${company.location}`);
76+
console.log(` URL: ${company.publicUrl}`);
77+
});
78+
}
79+
if (result.errors.length > 0) {
80+
console.error('🚨 Errors:', JSON.stringify(result.errors, null, 2));
81+
}
82+
}
83+
5784
async function salesNavigatorExample(linkedapi: LinkedApi): Promise<void> {
5885
const nvSearchParams = {
5986
term: 'fintech',
@@ -90,6 +117,32 @@ async function salesNavigatorExample(linkedapi: LinkedApi): Promise<void> {
90117
}
91118
}
92119

120+
async function salesNavigatorWithCustomUrlExample(linkedapi: LinkedApi): Promise<void> {
121+
const nvSearchParams = {
122+
customSearchUrl: "https://www.linkedin.com/sales/search/company?query=(spellCorrectionEnabled%3Atrue%2Ckeywords%3ALinked%2520API)",
123+
};
124+
125+
console.log('\n🎯 Searching companies with Sales Navigator custom search URL...');
126+
const workflowId = await linkedapi.nvSearchCompanies.execute(nvSearchParams);
127+
console.log('🔍 Sales Navigator workflow started:', workflowId);
128+
const nvResults = await linkedapi.nvSearchCompanies.result(workflowId);
129+
130+
if (nvResults.data) {
131+
const results = nvResults.data;
132+
console.log('✅ Sales Navigator company search completed');
133+
console.log(`📊 Found ${results.length} companies`);
134+
results.forEach((company, index) => {
135+
console.log(` ${index + 1}. ${company.name}`);
136+
console.log(` Industry: ${company.industry}`);
137+
console.log(` Employees: ${company.employeesCount}`);
138+
console.log(` URL: ${company.hashedUrl}`);
139+
});
140+
}
141+
if (nvResults.errors.length > 0) {
142+
console.error('🚨 Errors:', JSON.stringify(nvResults.errors, null, 2));
143+
}
144+
}
145+
93146
if (require.main === module) {
94147
searchCompaniesExample();
95148
}

examples/search-people.ts

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ async function searchPeopleExample(): Promise<void> {
99
try {
1010
console.log('🚀 Linked API searchPeople example starting...');
1111
await standardExample(linkedapi);
12+
await standardExampleWithCustomSearchUrlExample(linkedapi);
1213
await salesNavigatorExample(linkedapi);
13-
14+
await salesNavigatorWithCustomSearchUrlExample(linkedapi);
1415
} catch (error) {
1516
if (error instanceof LinkedApiError) {
1617
console.error('🚨 Linked API Error:', error.message);
@@ -56,6 +57,33 @@ async function standardExample(linkedapi: LinkedApi): Promise<void> {
5657
}
5758
}
5859

60+
61+
async function standardExampleWithCustomSearchUrlExample(linkedapi: LinkedApi): Promise<void> {
62+
const searchParams = {
63+
customSearchUrl: "https://www.linkedin.com/search/results/people/?geoUrn=%5B%22103644278%22%5D&keywords=Bill%20Gates",
64+
};
65+
66+
console.log('🔍 Searching people with custom search URL...');
67+
const workflowId = await linkedapi.searchPeople.execute(searchParams);
68+
console.log('🔍 Workflow started:', workflowId);
69+
const searchResult = await linkedapi.searchPeople.result(workflowId);
70+
71+
if (searchResult.data) {
72+
const results = searchResult.data;
73+
console.log('✅ People search completed');
74+
console.log(`📊 Found ${results.length} people`);
75+
results.forEach((person, index) => {
76+
console.log(` ${index + 1}. ${person.name}`);
77+
console.log(` Headline: ${person.headline}`);
78+
console.log(` Location: ${person.location}`);
79+
console.log(` URL: ${person.publicUrl}`);
80+
});
81+
}
82+
if (searchResult.errors.length > 0) {
83+
console.error('🚨 Errors:', JSON.stringify(searchResult.errors, null, 2));
84+
}
85+
}
86+
5987
async function salesNavigatorExample(linkedapi: LinkedApi): Promise<void> {
6088
const nvSearchParams = {
6189
term: 'product manager',
@@ -69,7 +97,7 @@ async function salesNavigatorExample(linkedapi: LinkedApi): Promise<void> {
6997
},
7098
};
7199

72-
console.log('\n🎯 Searching people with Sales Navigator...');
100+
console.log('\n🎯 Searching people with Sales Navigator custom search URL...');
73101
const workflowId = await linkedapi.nvSearchPeople.execute(nvSearchParams);
74102
console.log('🔍 Sales Navigator workflow started:', workflowId);
75103
const nvResults = await linkedapi.nvSearchPeople.result(workflowId);
@@ -90,6 +118,32 @@ async function salesNavigatorExample(linkedapi: LinkedApi): Promise<void> {
90118
}
91119
}
92120

121+
async function salesNavigatorWithCustomSearchUrlExample(linkedapi: LinkedApi): Promise<void> {
122+
const nvSearchParams = {
123+
customSearchUrl: "https://www.linkedin.com/sales/search/people?query=(recentSearchParam%3A(doLogHistory%3Atrue)%2CspellCorrectionEnabled%3Atrue%2Ckeywords%3ABill%2520Gates)",
124+
};
125+
126+
console.log('\n🎯 Searching people with Sales Navigator...');
127+
const workflowId = await linkedapi.nvSearchPeople.execute(nvSearchParams);
128+
console.log('🔍 Sales Navigator workflow started:', workflowId);
129+
const nvResults = await linkedapi.nvSearchPeople.result(workflowId);
130+
131+
if (nvResults.data) {
132+
const results = nvResults.data;
133+
console.log('✅ Sales Navigator people search completed');
134+
console.log(`📊 Found ${results.length} people`);
135+
results.forEach((person, index) => {
136+
console.log(` ${index + 1}. ${person.name}`);
137+
console.log(` Position: ${person.position}`);
138+
console.log(` Location: ${person.location}`);
139+
console.log(` URL: ${person.hashedUrl}`);
140+
});
141+
}
142+
if (nvResults.errors.length > 0) {
143+
console.error('🚨 Errors:', JSON.stringify(nvResults.errors, null, 2));
144+
}
145+
}
146+
93147
if (require.main === module) {
94148
searchPeopleExample();
95149
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "linkedapi-node",
3-
"version": "1.2.4",
3+
"version": "1.2.5",
44
"description": "Official TypeScript SDK for Linked API",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/types/actions/search-companies.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface TSearchCompaniesParams extends TBaseActionParams {
88
locations?: string[];
99
industries?: string[];
1010
};
11+
customSearchUrl?: string;
1112
}
1213

1314
export const SEARCH_COMPANY_SIZE = {
@@ -41,6 +42,7 @@ export interface TNvSearchCompaniesParams extends TBaseActionParams {
4142
max: TMaxAnnualRevenue;
4243
};
4344
};
45+
customSearchUrl?: string;
4446
}
4547

4648
export const MIN_ANNUAL_REVENUE = {

src/types/actions/search-people.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export interface TSearchPeopleParams extends TBaseActionParams {
1515
previousCompanies?: string[];
1616
schools?: string[];
1717
};
18+
customSearchUrl?: string;
1819
}
1920

2021
export interface TSearchPeopleResult {
@@ -38,6 +39,7 @@ export interface TNvSearchPeopleParams extends TBaseActionParams {
3839
schools?: string[];
3940
yearsOfExperience?: TYearsOfExperience[];
4041
};
42+
customSearchUrl?: string;
4143
}
4244

4345
export interface TNvSearchPeopleResult {

0 commit comments

Comments
 (0)