Python SDK for interacting with Unipile API.
Project description
Unipile Python SDK
An unofficial, fully functional Python SDK for the Unipile API.
Why?
Integrating with powerful APIs can be complex, unfortunately Unipile does not provide an official Python client (actual for 2025), only Node.JS based official client.
When I started working with the Unipile API and Python to automate LinkedIn interactions, I found myself writing a lot of boilerplate code to handle authentication, make HTTP requests, and parse responses. It was repetitive and error-prone. I wanted a simpler way to interact with the API, so I could focus on building features, not on the underlying HTTP calls.
That's why I built this SDK. It's a Pythonic wrapper around the Unipile API that handles the heavy lifting for you. Now, you can retrieve user profiles, search for candidates, and send messages with just a few lines of code. It's the tool I wish I had when I started, and I hope it makes your life easier too.
QuickStart
Get up and running with the Unipile Python SDK in just a few steps.
Demonstration of the work:
https://github.com/user-attachments/assets/4c15716a-d314-429e-9fe4-c6cf654073fd
Installation
pip install i-unipile-sdk # or add it into requirements and install it
Alternatively, you can use uv and add unipile SDK into your existing project.
uv add i-unipile-sdk
Configuration
1. Getting required credentials
You need to get some data before processing:
- Get DNS (
base_url), can be copied from dashboard. - Generate your API token (
auth) in access tokens - Connect account and get it's id (
default_account_id), can be copied next to account name in the accounts section.
All related information can be found in the getting-started documentation. I recommended to watch a quick start video first.
2. Initialize client
You can configure the client by passing an ClientOptions object directly:
from unipile_sdk import Client
from unipile_sdk.client import ClientOptions
options = ClientOptions(
auth="your_api_key_here", # Your Unipile API Key
base_url="https://your_base_url_here", # The Unipile API base URL
default_account_id="your_account_id_here", # The ID of the account to use
)
client = Client(options=options)
me = client.users.me()
print(f"My occupation is: {me.occupation}")
Usage Examples
This section showcases some of the more advanced features of the SDK. For
brevity, it is assumed that the client object has been initialized as shown
in the QuickStart section.
To use examples, you need to import the relevant models and functions from the
SDK, e.g., LinkedinSearchPayload, iterate_paginated_api, and Client:
from unipile_sdk.models import LinkedinSearchPayload, NotFoundType
from unipile_sdk.helpers import iterate_paginated_api
from unipile_sdk.errors import APIResponseError
List Accounts
Retrieve a list of all connected accounts.
accounts = client.accounts.accounts(limit=100)
for account in accounts.items:
print(f"Account: {account.type} - {account.name}")
LinkedIn Search
Perform a detailed search for people on LinkedIn. The SDK will handle pagination for you.
payload = LinkedinSearchPayload(
api="classic", category="people", keywords="Software Engineer, Programmer"
)
for person in iterate_paginated_api(
client.ln_search.search, payload=payload, max_total=10
):
print(f"Found Person: {person.name} ({person.id})")
Retrieve Company by Name
Fetch company details using its name.
company = client.ln_search.retrieve_company(identifier="LinkedIn")
print(f"Company: {company.name} ({company.id})")
For more examples, please check the
tests/integrationdirectory. The following examples are also available as Python files in theexamplesdirectory.
Drawbacks
This SDK is currently under development and should be considered a work in progress. Here are a few things to keep in mind:
- Incomplete API Coverage: The SDK does not cover the entire Unipile API. The primary focus has been on the LinkedIn-related endpoints.
- Potential for Bugs: As with any active development project, there may be bugs or incomplete features.
Contributions to improve the SDK and expand its coverage are welcome.
Contributing
Contributions are welcome! Here's how you can get started with the development of the SDK.
Development Setup
-
Clone the repository.
-
Install the development dependencies:
git clone repo-url cd repo-directory uv pip install -e ".[dev]" # or `pip install -e ".[dev]"`
Running Tests
To run the tests, you need to set up your test environment variables. Create a
.tests.env file in the root of the project:
UNIPILE_BASE_URL should be without protocol (like api.unipile.com...).
UNIPILE_ACCESS_TOKEN=your_api_token_here
UNIPILE_BASE_URL=your_unipile_api_basi_url
UNIPILE_ACCOUNT=your__account_id_here
UNIPILE_LN_DEFAULT_USER_URN=your_default_user_urn_here
UNIPILE_LN_USER_URN_TO_MESSAGE=your_target_user_urn_here
Then, run the tests using pytest:
pytest
Activities tests
Some tests that perform actions like sending messages are marked as messaging
and are skipped by default. To run them, use the --activities flag:
If you specify UNIPILE_LN_USER_URN_TO_MESSAGE, you can test messaging
functionality by sending a message to that user URN. Be careful this can
actually send a many same messages on LinkedIn. Use a test account or a
controlled recipient.
There additional test_send_message_to_attendees test, which sends messages
with specific logic. If there found only one message (usually invite message),
it sends a test message to that attendee and asserts success. So expect some
"thank you for connection" messages if --activities flag is used.
pytest --messaging
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file i_unipile_sdk-0.3.4a1.tar.gz.
File metadata
- Download URL: i_unipile_sdk-0.3.4a1.tar.gz
- Upload date:
- Size: 23.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
caf5350bc40afe0bf924a58b6d4b6a66f46a769a1079791842002b39cbe82160
|
|
| MD5 |
f79b5aba8f136c23e5fe3c719c5e7743
|
|
| BLAKE2b-256 |
6d0a700c0578ddd27e5e27dcf95327abc2f6b27101a9a7b79ffa69b82a02176e
|
File details
Details for the file i_unipile_sdk-0.3.4a1-py3-none-any.whl.
File metadata
- Download URL: i_unipile_sdk-0.3.4a1-py3-none-any.whl
- Upload date:
- Size: 27.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9ed652ada4cb4b9827de73399f0c2313f758f5d83143a130b3d89c96fed1fe2
|
|
| MD5 |
d08729cc91202ee386e0489e92d9046f
|
|
| BLAKE2b-256 |
849e11a34dd935aa32acf351f04140e4249fe44b4b0038e596e23ebd2f72a0c1
|