Skip to content

Latest commit

History

History
93 lines (71 loc) · 2.78 KB

File metadata and controls

93 lines (71 loc) · 2.78 KB

This official Python SDK is the synchronous way to integrate with Linked API. It provides pre-defined workflow operations, direct account/statistics methods, admin APIs, authentication headers, polling, and structured error responses.

Get started

To get started with Linked API Python SDK, read these essential guides first:

  1. Core concepts - understand how Linked API works.
  2. Installation & authorization - install the SDK and authorize it.
  3. Predefined vs. custom workflows - choose ready-made operations or custom workflow definitions.
  4. Handling results and errors - process successful data and action errors.
  5. Persisting and cancelling workflows - save, resume, and cancel workflows.

Install the package:

pip install linkedapi

Initialize the client:

fromlinkedapiimportLinkedApi, LinkedApiConfiglinkedapi=LinkedApi(
LinkedApiConfig(
linked_api_token="your-linked-api-token",
identification_token="your-identification-token",
)
)

Run a predefined workflow and poll the result:

fromlinkedapiimportFetchPersonParamsworkflow=linkedapi.fetch_person.execute(
FetchPersonParams(
person_url="https://www.linkedin.com/in/john-doe",
retrieve_experience=True,
retrieve_posts=True,
posts_retrieval_config={"limit": 10},
)
)
result=linkedapi.fetch_person.result(workflow.workflow_id)
ifresult.data:
print(result.data.name)
forerrorinresult.errors:
print(error.type, error.message)

Execute a custom workflow:

workflow=linkedapi.custom_workflow.execute(
{
"actionType": "st.searchCompanies",
"term": "Tech Inc",
"filter": {
"sizes": ["51-200", "2001-5000"],
"locations": ["San Francisco", "New York"],
"industries": ["Software Development"],
},
"then": {"actionType": "st.openCompanyPage", "basicInfo": True},
}
)
result=linkedapi.custom_workflow.result(workflow.workflow_id)
print(result.data)

Continue polling after a workflow timeout:

fromlinkedapiimportLinkedApiWorkflowTimeoutErrortry:
result=linkedapi.fetch_person.result(workflow.workflow_id, timeout=30.0)
exceptLinkedApiWorkflowTimeoutErroraserror:
result=linkedapi.fetch_person.result(error.workflow_id)

Cancel a workflow:

cancelled=linkedapi.fetch_person.cancel(workflow.workflow_id)
print(cancelled)

License

This project is licensed under the MIT License. See LICENSE for details.