Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
370 changes: 81 additions & 289 deletions README.md

Large diffs are not rendered by default.

34 changes: 12 additions & 22 deletions examples/connections.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import LinkedApi from 'linkedapi-node';
import LinkedApi, { LinkedApiError, LinkedApiWorkflowError } from 'linkedapi-node';

async function connectionsExample(): Promise<void> {

const linkedapi = new LinkedApi({
accountApiToken: process.env.ACCOUNT_API_TOKEN,
identificationToken: process.env.IDENTIFICATION_TOKEN,
dataApiToken: process.env.DATA_API_TOKEN,
apiToken: process.env.API_TOKEN!,
identificationToken: process.env.IDENTIFICATION_TOKEN!,
});

try {
Expand All @@ -22,10 +21,10 @@ async function connectionsExample(): Promise<void> {
await removeConnection(linkedapi, targetPersonUrl2);

} catch (error) {
if (error instanceof LinkedApi.LinkedApiError) {
if (error instanceof LinkedApiError) {
console.error('🚨 Linked API Error:', error.message);
console.error('📝 Details:', error.details);
} else if (error instanceof LinkedApi.LinkedApiWorkflowError) {
} else if (error instanceof LinkedApiWorkflowError) {
console.error('🚨 Linked API Workflow Error:', error.message);
console.error('🔍 Reason:', error.reason);
} else {
Expand All @@ -41,7 +40,7 @@ async function checkConnectionStatus(linkedapi: LinkedApi, personUrl: string): P
personUrl: personUrl,
};

const statusWorkflow = await linkedapi.account.checkConnectionStatus(statusParams);
const statusWorkflow = await linkedapi.checkConnectionStatus(statusParams);
console.log('🔍 Connection status workflow started:', statusWorkflow.workflowId);

const statusResult = await statusWorkflow.result();
Expand All @@ -58,7 +57,7 @@ async function sendConnectionRequest(linkedapi: LinkedApi, personUrl: string): P
email: 'example@gmail.com',
};

const requestWorkflow = await linkedapi.account.sendConnectionRequest(requestParams);
const requestWorkflow = await linkedapi.sendConnectionRequest(requestParams);
console.log('📤 Send connection request workflow started:', requestWorkflow.workflowId);

await requestWorkflow.result();
Expand All @@ -69,7 +68,7 @@ async function sendConnectionRequest(linkedapi: LinkedApi, personUrl: string): P
async function retrievePendingRequests(linkedapi: LinkedApi): Promise<void> {
console.log('\n📋 Retrieving pending connection requests...');

const pendingWorkflow = await linkedapi.account.retrievePendingRequests();
const pendingWorkflow = await linkedapi.retrievePendingRequests();
console.log('📋 Retrieve pending requests workflow started:', pendingWorkflow.workflowId);

const pendingResults = await pendingWorkflow.result();
Expand All @@ -91,7 +90,7 @@ async function withdrawConnectionRequest(linkedapi: LinkedApi, personUrl: string
unfollow: true,
};

const withdrawWorkflow = await linkedapi.account.withdrawConnectionRequest(withdrawParams);
const withdrawWorkflow = await linkedapi.withdrawConnectionRequest(withdrawParams);
console.log('🔙 Withdraw connection request workflow started:', withdrawWorkflow.workflowId);

await withdrawWorkflow.result();
Expand All @@ -110,7 +109,7 @@ async function retrieveConnections(linkedapi: LinkedApi): Promise<void> {
},
};

const connectionsWorkflow = await linkedapi.account.retrieveConnections(connectionsParams);
const connectionsWorkflow = await linkedapi.retrieveConnections(connectionsParams);
console.log('👥 Retrieve connections workflow started:', connectionsWorkflow.workflowId);

const connectionsResults = await connectionsWorkflow.result();
Expand All @@ -132,23 +131,14 @@ async function removeConnection(linkedapi: LinkedApi, personUrl: string): Promis
personUrl: personUrl,
};

const removeWorkflow = await linkedapi.account.removeConnection(removeParams);
const removeWorkflow = await linkedapi.removeConnection(removeParams);
console.log('❌ Remove connection workflow started:', removeWorkflow.workflowId);

await removeWorkflow.result();
console.log('✅ Connection removed successfully');
console.log(' 🔗 No longer connected with this person');
}

async function runExample(): Promise<void> {
try {
await connectionsExample();
} catch (error) {
console.error('💥 Example failed:', error);
process.exit(1);
}
}

if (require.main === module) {
runExample();
connectionsExample();
}
59 changes: 27 additions & 32 deletions examples/custom-workflow.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,41 @@
import LinkedApi from 'linkedapi-node';
import LinkedApi, { LinkedApiError, LinkedApiWorkflowError } from 'linkedapi-node';

async function customWorkflowExample(): Promise<void> {

const linkedapi = new LinkedApi({
accountApiToken: process.env.ACCOUNT_API_TOKEN,
identificationToken: process.env.IDENTIFICATION_TOKEN,
dataApiToken: process.env.DATA_API_TOKEN,
apiToken: process.env.API_TOKEN!,
identificationToken: process.env.IDENTIFICATION_TOKEN!,
});

try {
console.log('🚀 Linked API custom workflow example starting...');
await accountApiExample(linkedapi);
const customWorkflow = await linkedapi.executeCustomWorkflow({
actionType: 'st.searchPeople',
limit: 5,
filter: {
locations: ["San Francisco"],
},
then: {
actionType: 'st.doForPeople',
then: {
actionType: 'st.openPersonPage',
basicInfo: true,
then: {
actionType: 'st.retrievePersonSkills',
}
}
}
});
console.log('🔍 Workflow started: ', customWorkflow.workflowId);
const result = await customWorkflow.result();

console.log('✅ Custom workflow executed successfully');
console.log('🔍 Result: ', result.completion);
} catch (error) {
if (error instanceof LinkedApi.LinkedApiError) {
if (error instanceof LinkedApiError) {
console.error('🚨 Linked API Error:', error.message);
console.error('📝 Details:', error.details);
} else if (error instanceof LinkedApi.LinkedApiWorkflowError) {
} else if (error instanceof LinkedApiWorkflowError) {
console.error('🚨 Linked API Workflow Error:', error.message);
console.error('🔍 Reason:', error.reason);
} else {
Expand All @@ -24,31 +44,6 @@ async function customWorkflowExample(): Promise<void> {
}
}

async function accountApiExample(linkedapi: LinkedApi): Promise<void> {
const customWorkflow = await linkedapi.account.executeCustomWorkflow({
actionType: 'st.searchPeople',
limit: 5,
filter: {
locations: ["San Francisco"],
},
then: {
actionType: 'st.doForPeople',
then: {
actionType: 'st.openPersonPage',
basicInfo: true,
then: {
actionType: 'st.retrievePersonSkills',
}
}
}
});
console.log('🔍 Workflow started: ', customWorkflow.workflowId);
const result = await customWorkflow.result();

console.log('✅ Custom workflow executed successfully');
console.log('🔍 Result: ', result.completion);
}

if (require.main === module) {
customWorkflowExample();
}
68 changes: 12 additions & 56 deletions examples/fetch-company.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import LinkedApi from 'linkedapi-node';
import LinkedApi, { LinkedApiError, LinkedApiWorkflowError } from 'linkedapi-node';

async function fetchCompanyExample(): Promise<void> {
const linkedapi = new LinkedApi({
accountApiToken: process.env.ACCOUNT_API_TOKEN,
identificationToken: process.env.IDENTIFICATION_TOKEN,
dataApiToken: process.env.DATA_API_TOKEN,
apiToken: process.env.API_TOKEN!,
identificationToken: process.env.IDENTIFICATION_TOKEN!,
});

try {
console.log('🚀 TypeScript Linked API example starting...');
await accountApiExample(linkedapi);
await accountApiSalesNavigatorExample(linkedapi);
await dataApiExample(linkedapi);
await standardExample(linkedapi);
await salesNavigatorExample(linkedapi);

} catch (error) {
if (error instanceof LinkedApi.LinkedApiError) {
if (error instanceof LinkedApiError) {
console.error('🚨 Linked API Error:', error.message);
console.error('📝 Details:', error.details);
} else if (error instanceof LinkedApi.LinkedApiWorkflowError) {
} else if (error instanceof LinkedApiWorkflowError) {
console.error('🚨 Linked API Workflow Error:', error.message);
console.error('🔍 Reason:', error.reason);
} else {
Expand All @@ -26,8 +24,8 @@ async function fetchCompanyExample(): Promise<void> {
}
}

async function accountApiExample(linkedapi: LinkedApi): Promise<void> {
const fetchCompanyWorkflow = await linkedapi.account.fetchCompany({
async function standardExample(linkedapi: LinkedApi): Promise<void> {
const fetchCompanyWorkflow = await linkedapi.fetchCompany({
companyUrl: 'https://www.linkedin.com/company/linkedin/',
retrieveEmployees: true,
retrieveDms: true,
Expand Down Expand Up @@ -62,8 +60,8 @@ async function accountApiExample(linkedapi: LinkedApi): Promise<void> {
console.log(`📝 Posts Retrieved: ${company.posts?.length || 0}`);
}

async function accountApiSalesNavigatorExample(linkedapi: LinkedApi): Promise<void> {
const nvCompanyResult = await linkedapi.account.salesNavigatorFetchCompany({
async function salesNavigatorExample(linkedapi: LinkedApi): Promise<void> {
const nvCompanyResult = await linkedapi.salesNavigatorFetchCompany({
companyHashedUrl: 'https://www.linkedin.com/sales/company/1035',
retrieveEmployees: true,
retrieveDms: true,
Expand Down Expand Up @@ -93,48 +91,6 @@ async function accountApiSalesNavigatorExample(linkedapi: LinkedApi): Promise<vo
console.log(`🎯 Decision Makers Retrieved: ${nvCompany.dms?.length || 0}`);
}

async function dataApiExample(linkedapi: LinkedApi): Promise<void> {
const dataCompanyResult = await linkedapi.data.fetchCompany({
companyUrl: 'https://www.linkedin.com/sales/company/1337',
retrieveEmployees: true,
retrieveDms: true,
employeeRetrievalConfig: {
limit: 10,
filter: {
position: 'engineer',
locations: ['United States'],
industries: ['Technology', 'Software'],
schools: ['Stanford University', 'MIT'],
yearsOfExperiences: ['threeToFive', 'sixToTen'],
},
},
dmRetrievalConfig: {
limit: 2,
},
});

console.log('🔍 Data API company workflow started: ', dataCompanyResult.workflowId);
const dataCompany = await dataCompanyResult.result();

console.log('✅ Data API company page opened successfully');
console.log(`🏢 Company: ${dataCompany.name}`);
console.log(`📖 Description: ${dataCompany.description}`);
console.log(`📍 Location: ${dataCompany.location}`);
console.log(`🏭 Industry: ${dataCompany.industry}`);
console.log(`👥 Employee Count: ${dataCompany.employeeCount}`);
console.log(`📅 Founded: ${dataCompany.yearFounded}`);
console.log(`👨‍💼 Employees Retrieved: ${dataCompany.employees?.length || 0}`);
}

async function runExample(): Promise<void> {
try {
await fetchCompanyExample();
} catch (error) {
console.error('💥 Example failed:', error);
process.exit(1);
}
}

if (require.main === module) {
runExample();
fetchCompanyExample();
}
69 changes: 13 additions & 56 deletions examples/fetch-person.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
import LinkedApi from 'linkedapi-node';
import LinkedApi, { LinkedApiError, LinkedApiWorkflowError } from 'linkedapi-node';

async function fetchPersonExample(): Promise<void> {

const linkedapi = new LinkedApi({
accountApiToken: process.env.ACCOUNT_API_TOKEN,
identificationToken: process.env.IDENTIFICATION_TOKEN,
dataApiToken: process.env.DATA_API_TOKEN,
apiToken: process.env.API_TOKEN!,
identificationToken: process.env.IDENTIFICATION_TOKEN!,
});

try {
console.log('🚀 Linked API fetchPerson example starting...');

await accountApiExample(linkedapi);
await salesNavigatorAccountApiExample(linkedapi);
await dataApiExample(linkedapi);
await standardExample(linkedapi);
await salesNavigatorExample(linkedapi);
} catch (error) {
if (error instanceof LinkedApi.LinkedApiError) {
if (error instanceof LinkedApiError) {
console.error('🚨 Linked API Error:', error.message);
console.error('📝 Details:', error.details);
} else if (error instanceof LinkedApi.LinkedApiWorkflowError) {
} else if (error instanceof LinkedApiWorkflowError) {
console.error('🚨 Linked API Workflow Error:', error.message);
console.error('🔍 Reason:', error.reason);
} else {
Expand All @@ -27,8 +25,8 @@ async function fetchPersonExample(): Promise<void> {
}
}

async function accountApiExample(linkedapi: LinkedApi): Promise<void> {
const personResult = await linkedapi.account.fetchPerson({
async function standardExample(linkedapi: LinkedApi): Promise<void> {
const personResult = await linkedapi.fetchPerson({
personUrl: 'https://www.linkedin.com/in/example-person/',
retrieveExperience: true,
retrieveEducation: true,
Expand Down Expand Up @@ -59,12 +57,12 @@ async function accountApiExample(linkedapi: LinkedApi): Promise<void> {
console.log(`💼 Experiences: ${person.experiences}`);
}

async function salesNavigatorAccountApiExample(linkedapi: LinkedApi): Promise<void> {
async function salesNavigatorExample(linkedapi: LinkedApi): Promise<void> {
const fetchParams = {
personHashedUrl: 'https://www.linkedin.com/in/abc123',
};

const personResult = await linkedapi.account.salesNavigatorFetchPerson(fetchParams);
const personResult = await linkedapi.salesNavigatorFetchPerson(fetchParams);
console.log('🔍 Workflow started: ', personResult.workflowId);
const person = await personResult.result();

Expand All @@ -74,47 +72,6 @@ async function salesNavigatorAccountApiExample(linkedapi: LinkedApi): Promise<vo
console.log(`📍 Location: ${person.location}`);
}

async function dataApiExample(linkedapi: LinkedApi): Promise<void> {
const personResult = await linkedapi.data.fetchPerson({
personUrl: 'https://www.linkedin.com/in/example-person/',
retrieveExperience: true,
retrieveEducation: true,
retrieveLanguages: true,
retrieveSkills: true,
retrievePosts: true,
retrieveComments: true,
retrieveReactions: true,
postsRetrievalConfig: {
limit: 5,
since: '2024-01-01',
},
commentRetrievalConfig: {
limit: 5,
},
reactionRetrievalConfig: {
limit: 5,
},
});
console.log('🔍 Workflow started: ', personResult.workflowId);
const person = await personResult.result();

console.log('✅ Person page opened successfully');
console.log(`👤 Name: ${person.name}`);
console.log(`💼 Position: ${person.position} at ${person.companyName}`);
console.log(`📍 Location: ${person.location}`);
console.log(`🌐 Skills: ${person.skills}`);
console.log(`💼 Experiences: ${person.experiences}`);
}

async function runExample(): Promise<void> {
try {
await fetchPersonExample();
} catch (error) {
console.error('💥 Example failed:', error);
process.exit(1);
}
}

if (require.main === module) {
runExample();
}
fetchPersonExample();
}
Loading