Metadata-Version: 2.4
Name: linkedapi
Version: 1.3.5
Summary: Official synchronous Python SDK for Linked API.
Project-URL: Homepage, https://linkedapi.io
Project-URL: Repository, https://github.com/Linked-API/linkedapi-python
Project-URL: Documentation, https://linkedapi.io/docs/
Author: Linked API
License-Expression: MIT
License-File: LICENSE
Keywords: api,automation,data,linkedapi,linkedin,sdk
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: pydantic<3,>=2
Requires-Dist: requests<3,>=2
Provides-Extra: dev
Requires-Dist: build; extra == 'dev'
Requires-Dist: mypy; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: requests-mock>=1.12; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Requires-Dist: types-requests; extra == 'dev'
Description-Content-Type: text/markdown

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](https://linkedapi.io/sdks/core-concepts-0/) - understand how Linked API works.
2. [Installation & authorization](https://linkedapi.io/sdks/installation-authorization/) - install the SDK and authorize it.
3. [Predefined vs. custom workflows](https://linkedapi.io/sdks/predefined-vs-custom-workflows/) - choose ready-made operations or custom workflow definitions.
4. [Handling results and errors](https://linkedapi.io/sdks/handling-results-and-errors/) - process successful data and action errors.
5. [Persisting and cancelling workflows](https://linkedapi.io/sdks/persisting-and-cancelling-workflows/) - save, resume, and cancel workflows.

Install the package:

```bash
pip install linkedapi
```

Initialize the client:

```python
from linkedapi import LinkedApi, LinkedApiConfig

linkedapi = LinkedApi(
    LinkedApiConfig(
        linked_api_token="your-linked-api-token",
        identification_token="your-identification-token",
    )
)
```

Run a predefined workflow and poll the result:

```python
from linkedapi import FetchPersonParams

workflow = 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)
if result.data:
    print(result.data.name)
for error in result.errors:
    print(error.type, error.message)
```

Execute a custom workflow:

```python
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:

```python
from linkedapi import LinkedApiWorkflowTimeoutError

try:
    result = linkedapi.fetch_person.result(workflow.workflow_id, timeout=30.0)
except LinkedApiWorkflowTimeoutError as error:
    result = linkedapi.fetch_person.result(error.workflow_id)
```

Cancel a workflow:

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

## License

This project is licensed under the MIT License. See [LICENSE](LICENSE) for details.
