Skip to main content

Python SDK for interacting with Unipile API.

Project description

Unipile Python SDK

Python License: MIT

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.

Installation

It is recommended to use uv, a fast, next-generation Python package installer.

# Using uv (recommended)
uv pip install i-unipile-sdk

Alternatively, you can use pip:

pip install i-unipile-sdk

Your First API Call

You need to configure the client by passing an ClientOptions object and create your first client instance. Here's a simple example to get you started:

from unipile_sdk import Client
from unipile_sdk.client import ClientOptions

options = ClientOptions(
    auth="your_api_key_here",
    base_url="https://api.unipile.com",
    default_account_id="your_default_account_id_here",
)

client = Client(options=options)

# Get your user information
me = client.users.me()
print(f"Hello, {me.name}!")

Alternative configuration possible via Environment Variables:

For convenience, especially in development and testing, you can also configure the client using environment variables. The client will automatically pick them up if no direct configuration is provided.

export UNIPILE_BASE_URL="api.unipile.com"
export UNIPILE_ACCESS_TOKEN="your_api_key_here"
export UNIPILE_ACCOUNT="your_default_account_id_here"

# The client automatically picks up the environment variables
client = Client()

# Get your user information
me = client.users.me()
print(f"Hello, {me.name}!")

Usage

This section showcases some of the more advanced features of the SDK.

Advanced LinkedIn Search

Perform a detailed search for people on LinkedIn. The SDK will handle pagination for you.

from unipile_sdk.models import LinkedinSearchPayload
from unipile_sdk.helpers import iterate_paginated_api

payload = LinkedinSearchPayload(
    api="classic",
    category="people",
    keywords="Software Engineer in Test"
)

for person in iterate_paginated_api(client.search.search, payload=payload, max_total=50):
    print(f"Found Person: {person.name} ({person.id})")

Send a LinkedIn Message

Send a message to a LinkedIn user. You'll need the user's URN.

# Note: This is a simplified example. You'll need a valid chat_id.
# You can get a chat_id by listing chats for an attendee.
try:
    chat_id = "some_chat_id"
    client.messages.send_message(
        chat_id=chat_id,
        text="Hello from the Unipile SDK!"
    )
    print("Message sent successfully!")
except Exception as e:
    print(f"Failed to send message: {e}")

Error Handling

The SDK raises custom exceptions for different types of errors.

from unipile_sdk.errors import APIResponseError
from unipile_sdk.models import NotFoundType

try:
    client.search.retrieve_company(identifier="a-company-that-does-not-exist")
except APIResponseError as e:
    if e.error == NotFoundType.ERRORS_RESOURCE_NOT_FOUND:
        print("Caught a 'Not Found' error, as expected.")
    else:
        raise e

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

  1. Clone the repository.

  2. Install the development dependencies:

    uv clone repo-url
    cd repo-directory
    uv sync
    

    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=api.unipile.com
UNIPILE_ACCESS_TOKEN=your_api_key_here
UNIPILE_ACCOUNT=your_default_account_id_here
UNIPILE_TEST_LN_ATTENDEE=an_attendee_id

Then, run the tests using pytest:

pytest

Some tests that perform actions like sending messages are marked as messaging and are skipped by default. To run them, use the --messaging flag:

pytest --messaging

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

i_unipile_sdk-0.3.0a1.tar.gz (23.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

i_unipile_sdk-0.3.0a1-py3-none-any.whl (26.8 kB view details)

Uploaded Python 3

File details

Details for the file i_unipile_sdk-0.3.0a1.tar.gz.

File metadata

  • Download URL: i_unipile_sdk-0.3.0a1.tar.gz
  • Upload date:
  • Size: 23.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.7

File hashes

Hashes for i_unipile_sdk-0.3.0a1.tar.gz
Algorithm Hash digest
SHA256 78dc92bdcea97463e130dbda1795002e43d8627f9d15861f01de45eb8d238f4a
MD5 9b7b53fc9f5f4345ee1641d4d846a2f8
BLAKE2b-256 f2fa42349ac485092dfac2bc86d5b58207458e49134e4ec3246623e442baccb1

See more details on using hashes here.

File details

Details for the file i_unipile_sdk-0.3.0a1-py3-none-any.whl.

File metadata

File hashes

Hashes for i_unipile_sdk-0.3.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 6aad38908d00f4696571a67d7785360a0df7ee9ec844332a5d89cdb317e08849
MD5 c94c5becd370d8672ca0235762327a4f
BLAKE2b-256 229189cf7a0cb41056725eca0182230230eccd1e466ef731e47382030fc22415

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page