Predefined vs. custom workflows
There are two primary ways to execute operations with the SDKs: using predefined methods or building your own custom workflows.
Predefined workflows
Predefined workflows are the SDK's standard, ready-to-use methods, such as linkedApi.sendMessage()
or linkedApi.fetchPerson()
. Each of these helper methods automatically creates and runs a corresponding, pre-configured workflow.
When to use them
You should always start with predefined workflows. They are the fastest way to integrate Linked API because they are strongly typed.
Both the input parameters and the result objects have defined types, which provides auto-completion in your IDE and helps prevent errors. As long as a predefined method meets your needs, it's the recommended approach.
// Predefined method to send a message
const sendMessageHandler = await linkedapi.sendMessage({
personUrl: "https://www.linkedin.com/in/john-doe",
text: "Hello! I saw your post about AI and wanted to connect.",
});
const sendMessageResult = await sendMessageHandler.result()
// Predefined method to check connection status
const checkConnectionStatusHandler = await linkedapi.checkConnectionStatus({
personUrl: "https://www.linkedin.com/in/john-doe",
});
const checkConnectionStatusResult = await checkConnectionStatusHandler.result();
# Python SDK is coming soon!
#
# You can always use Linked API through HTTP
# https://linkedapi.io/docs/
// Go SDK is coming soon!
//
// You can always use Linked API through HTTP
// https://linkedapi.io/docs/
Custom workflows
For tasks requiring more flexibility or complex, multi-step logic, you can build a custom workflow. This approach allows you to directly interact with the Linked API workflow engine by constructing an object that defines the workflow's steps and logic.
You are responsible for correctly structuring the workflow definition object and then parsing the resulting completion object returned upon execution. The building workflows page provides the complete specification for both of these JSON structures.
When to use them
Switch to custom workflows when the predefined methods are not sufficient for your use case. For example:
- You want to search for companies using specific filters, then retrieve detailed information for each company in the search results.
- You want to find all managers at a company, get their profile and education details, and then send them connection requests.
// Custom workflow to find managers at a company,
// retrieve their education, and send connection requests
const customWorkflowHandler = await linkedapi.executeCustomWorkflow({
"actionType": "st.openCompanyPage",
"companyUrl": "https://www.linkedin.com/company/techcorp",
"basicInfo": true,
"then": {
"actionType": "st.retrieveCompanyEmployees",
"filter": {
"position": "Manager"
},
"then": {
"actionType": "st.doForPeople",
"then": {
"actionType": "st.openPersonPage",
"basicInfo": true,
"then": [
{
"actionType": "st.retrievePersonEducation"
},
{
"actionType": "st.sendConnectionRequest"
}
]
}
}
}
});
const customWorkflowResult = await customWorkflowHandler.result();
# Python SDK is coming soon!
#
# You can always use Linked API through HTTP
# https://linkedapi.io/docs/
// Go SDK is coming soon!
//
// You can always use Linked API through HTTP
// https://linkedapi.io/docs/