universal-mcp-applications 0.1.25__py3-none-any.whl → 0.1.32__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- universal_mcp/applications/google_docs/app.py +6 -2
- universal_mcp/applications/google_gemini/app.py +3 -3
- universal_mcp/applications/google_sheet/app.py +6 -2
- universal_mcp/applications/linkedin/README.md +16 -4
- universal_mcp/applications/linkedin/app.py +748 -153
- universal_mcp/applications/onedrive/README.md +24 -0
- universal_mcp/applications/onedrive/__init__.py +1 -0
- universal_mcp/applications/onedrive/app.py +338 -0
- universal_mcp/applications/outlook/app.py +253 -209
- universal_mcp/applications/reddit/app.py +30 -47
- universal_mcp/applications/scraper/app.py +304 -290
- universal_mcp/applications/sharepoint/README.md +16 -14
- universal_mcp/applications/sharepoint/app.py +267 -154
- universal_mcp/applications/slack/app.py +31 -0
- {universal_mcp_applications-0.1.25.dist-info → universal_mcp_applications-0.1.32.dist-info}/METADATA +2 -2
- {universal_mcp_applications-0.1.25.dist-info → universal_mcp_applications-0.1.32.dist-info}/RECORD +18 -18
- universal_mcp/applications/unipile/README.md +0 -28
- universal_mcp/applications/unipile/__init__.py +0 -1
- universal_mcp/applications/unipile/app.py +0 -1077
- {universal_mcp_applications-0.1.25.dist-info → universal_mcp_applications-0.1.32.dist-info}/WHEEL +0 -0
- {universal_mcp_applications-0.1.25.dist-info → universal_mcp_applications-0.1.32.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,1077 +0,0 @@
|
|
|
1
|
-
import json
|
|
2
|
-
from collections.abc import Callable
|
|
3
|
-
from typing import Any, Literal
|
|
4
|
-
|
|
5
|
-
from loguru import logger
|
|
6
|
-
from universal_mcp.applications.application import APIApplication
|
|
7
|
-
from universal_mcp.integrations import Integration
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class UnipileApp(APIApplication):
|
|
11
|
-
"""
|
|
12
|
-
Application for interacting with the LinkedIn API via Unipile.
|
|
13
|
-
Handles operations related to chats, messages, accounts, posts, and user profiles.
|
|
14
|
-
"""
|
|
15
|
-
|
|
16
|
-
def __init__(self, integration: Integration) -> None:
|
|
17
|
-
"""
|
|
18
|
-
Initialize the LinkedinApp.
|
|
19
|
-
|
|
20
|
-
Args:
|
|
21
|
-
integration: The integration configuration containing credentials and other settings.
|
|
22
|
-
It is expected that the integration provides the 'x-api-key'
|
|
23
|
-
via headers in `integration.get_credentials()`, e.g.,
|
|
24
|
-
`{"headers": {"x-api-key": "YOUR_API_KEY"}}`.
|
|
25
|
-
"""
|
|
26
|
-
super().__init__(name="unipile", integration=integration)
|
|
27
|
-
|
|
28
|
-
self._base_url = None
|
|
29
|
-
|
|
30
|
-
@property
|
|
31
|
-
def base_url(self) -> str:
|
|
32
|
-
"""
|
|
33
|
-
A property that lazily constructs and caches the Unipile API base URL from 'subdomain' and 'port' credentials. Built on first access and used by all API methods, it raises a ValueError if credentials are missing. This is the default construction, unlike the setter which allows manual override.
|
|
34
|
-
"""
|
|
35
|
-
if not self._base_url:
|
|
36
|
-
credentials = self.integration.get_credentials()
|
|
37
|
-
subdomain = credentials.get("subdomain")
|
|
38
|
-
port = credentials.get("port")
|
|
39
|
-
if not subdomain or not port:
|
|
40
|
-
logger.error(
|
|
41
|
-
"UnipileApp: Missing 'subdomain' or 'port' in integration credentials."
|
|
42
|
-
)
|
|
43
|
-
raise ValueError(
|
|
44
|
-
"Integration credentials must include 'subdomain' and 'port'."
|
|
45
|
-
)
|
|
46
|
-
self._base_url = f"https://{subdomain}.unipile.com:{port}"
|
|
47
|
-
return self._base_url
|
|
48
|
-
|
|
49
|
-
@base_url.setter
|
|
50
|
-
def base_url(self, base_url: str) -> None:
|
|
51
|
-
"""
|
|
52
|
-
Sets or overrides the Unipile API's base URL. This setter allows manually changing the endpoint, bypassing the default URL that is dynamically constructed from integration credentials. It is primarily intended for testing against different environments or for custom deployments.
|
|
53
|
-
|
|
54
|
-
Args:
|
|
55
|
-
base_url: The new base URL to set.
|
|
56
|
-
"""
|
|
57
|
-
self._base_url = base_url
|
|
58
|
-
logger.info(f"UnipileApp: Base URL set to {self._base_url}")
|
|
59
|
-
|
|
60
|
-
def _get_headers(self) -> dict[str, str]:
|
|
61
|
-
"""
|
|
62
|
-
Get the headers for Unipile API requests.
|
|
63
|
-
Overrides the base class method to use X-Api-Key.
|
|
64
|
-
"""
|
|
65
|
-
if not self.integration:
|
|
66
|
-
logger.warning(
|
|
67
|
-
"UnipileApp: No integration configured, returning empty headers."
|
|
68
|
-
)
|
|
69
|
-
return {}
|
|
70
|
-
|
|
71
|
-
credentials = self.integration.get_credentials()
|
|
72
|
-
|
|
73
|
-
api_key = (
|
|
74
|
-
credentials.get("api_key")
|
|
75
|
-
or credentials.get("API_KEY")
|
|
76
|
-
or credentials.get("apiKey")
|
|
77
|
-
)
|
|
78
|
-
|
|
79
|
-
if not api_key:
|
|
80
|
-
logger.error(
|
|
81
|
-
"UnipileApp: API key not found in integration credentials for Unipile."
|
|
82
|
-
)
|
|
83
|
-
return { # Or return minimal headers if some calls might not need auth (unlikely for Unipile)
|
|
84
|
-
"Content-Type": "application/json",
|
|
85
|
-
"Cache-Control": "no-cache",
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
logger.debug("UnipileApp: Using X-Api-Key for authentication.")
|
|
89
|
-
return {
|
|
90
|
-
"x-api-key": api_key,
|
|
91
|
-
"Content-Type": "application/json",
|
|
92
|
-
"Cache-Control": "no-cache", # Often good practice for APIs
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
def list_all_chats(
|
|
96
|
-
self,
|
|
97
|
-
unread: bool | None = None,
|
|
98
|
-
cursor: str | None = None,
|
|
99
|
-
before: str | None = None, # ISO 8601 UTC datetime
|
|
100
|
-
after: str | None = None, # ISO 8601 UTC datetime
|
|
101
|
-
limit: int | None = None, # 1-250
|
|
102
|
-
account_type: str | None = None,
|
|
103
|
-
account_id: str | None = None, # Comma-separated list of ids
|
|
104
|
-
) -> dict[str, Any]:
|
|
105
|
-
"""
|
|
106
|
-
Retrieves a paginated list of all chat conversations across linked accounts. Supports filtering by unread status, date range, account provider, and specific account IDs, distinguishing it from functions listing messages within a single chat.
|
|
107
|
-
|
|
108
|
-
Args:
|
|
109
|
-
unread: Filter for unread chats only or read chats only.
|
|
110
|
-
cursor: Pagination cursor for the next page of entries.
|
|
111
|
-
before: Filter for items created before this ISO 8601 UTC datetime (exclusive).
|
|
112
|
-
after: Filter for items created after this ISO 8601 UTC datetime (exclusive).
|
|
113
|
-
limit: Number of items to return (1-250).
|
|
114
|
-
account_type: Filter by provider (e.g., "linkedin").
|
|
115
|
-
account_id: Filter by specific account IDs (comma-separated).
|
|
116
|
-
|
|
117
|
-
Returns:
|
|
118
|
-
A dictionary containing a list of chat objects and a pagination cursor.
|
|
119
|
-
|
|
120
|
-
Raises:
|
|
121
|
-
httpx.HTTPError: If the API request fails.
|
|
122
|
-
|
|
123
|
-
Tags:
|
|
124
|
-
linkedin, chat, list, messaging, api
|
|
125
|
-
"""
|
|
126
|
-
url = f"{self.base_url}/api/v1/chats"
|
|
127
|
-
params: dict[str, Any] = {}
|
|
128
|
-
if unread is not None:
|
|
129
|
-
params["unread"] = unread
|
|
130
|
-
if cursor:
|
|
131
|
-
params["cursor"] = cursor
|
|
132
|
-
if before:
|
|
133
|
-
params["before"] = before
|
|
134
|
-
if after:
|
|
135
|
-
params["after"] = after
|
|
136
|
-
if limit:
|
|
137
|
-
params["limit"] = limit
|
|
138
|
-
if account_type:
|
|
139
|
-
params["account_type"] = account_type
|
|
140
|
-
if account_id:
|
|
141
|
-
params["account_id"] = account_id
|
|
142
|
-
|
|
143
|
-
response = self._get(url, params=params)
|
|
144
|
-
return response.json()
|
|
145
|
-
|
|
146
|
-
def list_chat_messages(
|
|
147
|
-
self,
|
|
148
|
-
chat_id: str,
|
|
149
|
-
cursor: str | None = None,
|
|
150
|
-
before: str | None = None, # ISO 8601 UTC datetime
|
|
151
|
-
after: str | None = None, # ISO 8601 UTC datetime
|
|
152
|
-
limit: int | None = None, # 1-250
|
|
153
|
-
sender_id: str | None = None,
|
|
154
|
-
) -> dict[str, Any]:
|
|
155
|
-
"""
|
|
156
|
-
Retrieves messages from a specific chat identified by `chat_id`. Supports pagination and filtering by date or sender. Unlike `list_all_messages`, which fetches from all chats, this function targets the contents of a single conversation.
|
|
157
|
-
|
|
158
|
-
Args:
|
|
159
|
-
chat_id: The ID of the chat to retrieve messages from.
|
|
160
|
-
cursor: Pagination cursor for the next page of entries.
|
|
161
|
-
before: Filter for items created before this ISO 8601 UTC datetime (exclusive).
|
|
162
|
-
after: Filter for items created after this ISO 8601 UTC datetime (exclusive).
|
|
163
|
-
limit: Number of items to return (1-250).
|
|
164
|
-
sender_id: Filter messages from a specific sender ID.
|
|
165
|
-
|
|
166
|
-
Returns:
|
|
167
|
-
A dictionary containing a list of message objects and a pagination cursor.
|
|
168
|
-
|
|
169
|
-
Raises:
|
|
170
|
-
httpx.HTTPError: If the API request fails.
|
|
171
|
-
|
|
172
|
-
Tags:
|
|
173
|
-
linkedin, chat, message, list, messaging, api
|
|
174
|
-
"""
|
|
175
|
-
url = f"{self.base_url}/api/v1/chats/{chat_id}/messages"
|
|
176
|
-
params: dict[str, Any] = {}
|
|
177
|
-
if cursor:
|
|
178
|
-
params["cursor"] = cursor
|
|
179
|
-
if before:
|
|
180
|
-
params["before"] = before
|
|
181
|
-
if after:
|
|
182
|
-
params["after"] = after
|
|
183
|
-
if limit:
|
|
184
|
-
params["limit"] = limit
|
|
185
|
-
if sender_id:
|
|
186
|
-
params["sender_id"] = sender_id
|
|
187
|
-
|
|
188
|
-
response = self._get(url, params=params)
|
|
189
|
-
return response.json()
|
|
190
|
-
|
|
191
|
-
def send_chat_message(
|
|
192
|
-
self,
|
|
193
|
-
chat_id: str,
|
|
194
|
-
text: str,
|
|
195
|
-
) -> dict[str, Any]:
|
|
196
|
-
"""
|
|
197
|
-
Sends a text message to a specific chat conversation using its `chat_id`. This function creates a new message via a POST request, distinguishing it from read-only functions like `list_chat_messages`. It returns the API's response, which typically confirms the successful creation of the message.
|
|
198
|
-
|
|
199
|
-
Args:
|
|
200
|
-
chat_id: The ID of the chat where the message will be sent.
|
|
201
|
-
text: The text content of the message.
|
|
202
|
-
attachments: Optional list of attachment objects to include with the message.
|
|
203
|
-
|
|
204
|
-
Returns:
|
|
205
|
-
A dictionary containing the ID of the sent message.
|
|
206
|
-
|
|
207
|
-
Raises:
|
|
208
|
-
httpx.HTTPError: If the API request fails.
|
|
209
|
-
|
|
210
|
-
Tags:
|
|
211
|
-
linkedin, chat, message, send, create, messaging, api
|
|
212
|
-
"""
|
|
213
|
-
url = f"{self.base_url}/api/v1/chats/{chat_id}/messages"
|
|
214
|
-
payload: dict[str, Any] = {"text": text}
|
|
215
|
-
|
|
216
|
-
response = self._post(url, data=payload)
|
|
217
|
-
return response.json()
|
|
218
|
-
|
|
219
|
-
def retrieve_chat(
|
|
220
|
-
self, chat_id: str, account_id: str | None = None
|
|
221
|
-
) -> dict[str, Any]:
|
|
222
|
-
"""
|
|
223
|
-
Retrieves a single chat's details using its Unipile or provider-specific ID. Requires an `account_id` when using a provider ID for context. This function is distinct from `list_all_chats`, which returns a collection, by targeting one specific conversation.
|
|
224
|
-
|
|
225
|
-
Args:
|
|
226
|
-
chat_id: The Unipile or provider ID of the chat.
|
|
227
|
-
account_id: Mandatory if the chat_id is a provider ID. Specifies the account context.
|
|
228
|
-
|
|
229
|
-
Returns:
|
|
230
|
-
A dictionary containing the chat object details.
|
|
231
|
-
|
|
232
|
-
Raises:
|
|
233
|
-
httpx.HTTPError: If the API request fails.
|
|
234
|
-
|
|
235
|
-
Tags:
|
|
236
|
-
linkedin, chat, retrieve, get, messaging, api
|
|
237
|
-
"""
|
|
238
|
-
url = f"{self.base_url}/api/v1/chats/{chat_id}"
|
|
239
|
-
params: dict[str, Any] = {}
|
|
240
|
-
if account_id:
|
|
241
|
-
params["account_id"] = account_id
|
|
242
|
-
|
|
243
|
-
response = self._get(url, params=params)
|
|
244
|
-
return response.json()
|
|
245
|
-
|
|
246
|
-
def list_all_messages(
|
|
247
|
-
self,
|
|
248
|
-
cursor: str | None = None,
|
|
249
|
-
before: str | None = None, # ISO 8601 UTC datetime
|
|
250
|
-
after: str | None = None, # ISO 8601 UTC datetime
|
|
251
|
-
limit: int | None = None, # 1-250
|
|
252
|
-
sender_id: str | None = None,
|
|
253
|
-
account_id: str | None = None,
|
|
254
|
-
) -> dict[str, Any]:
|
|
255
|
-
"""
|
|
256
|
-
Retrieves a paginated list of messages from all chats associated with the account(s). Unlike `list_chat_messages` which targets a specific conversation, this function provides a global message view, filterable by sender, account, and date range.
|
|
257
|
-
|
|
258
|
-
Args:
|
|
259
|
-
cursor: Pagination cursor.
|
|
260
|
-
before: Filter for items created before this ISO 8601 UTC datetime.
|
|
261
|
-
after: Filter for items created after this ISO 8601 UTC datetime.
|
|
262
|
-
limit: Number of items to return (1-250).
|
|
263
|
-
sender_id: Filter messages from a specific sender.
|
|
264
|
-
account_id: Filter messages from a specific linked account.
|
|
265
|
-
|
|
266
|
-
Returns:
|
|
267
|
-
A dictionary containing a list of message objects and a pagination cursor.
|
|
268
|
-
|
|
269
|
-
Raises:
|
|
270
|
-
httpx.HTTPError: If the API request fails.
|
|
271
|
-
|
|
272
|
-
Tags:
|
|
273
|
-
linkedin, message, list, all_messages, messaging, api
|
|
274
|
-
"""
|
|
275
|
-
url = f"{self.base_url}/api/v1/messages"
|
|
276
|
-
params: dict[str, Any] = {}
|
|
277
|
-
if cursor:
|
|
278
|
-
params["cursor"] = cursor
|
|
279
|
-
if before:
|
|
280
|
-
params["before"] = before
|
|
281
|
-
if after:
|
|
282
|
-
params["after"] = after
|
|
283
|
-
if limit:
|
|
284
|
-
params["limit"] = limit
|
|
285
|
-
if sender_id:
|
|
286
|
-
params["sender_id"] = sender_id
|
|
287
|
-
if account_id:
|
|
288
|
-
params["account_id"] = account_id
|
|
289
|
-
|
|
290
|
-
response = self._get(url, params=params)
|
|
291
|
-
return response.json()
|
|
292
|
-
|
|
293
|
-
def list_all_accounts(
|
|
294
|
-
self,
|
|
295
|
-
cursor: str | None = None,
|
|
296
|
-
limit: int | None = None, # 1-259 according to spec
|
|
297
|
-
) -> dict[str, Any]:
|
|
298
|
-
"""
|
|
299
|
-
Retrieves a paginated list of all social media accounts linked to the Unipile service. This is crucial for obtaining the `account_id` required by other methods to specify which user account should perform an action, like sending a message or retrieving user-specific posts.
|
|
300
|
-
|
|
301
|
-
Args:
|
|
302
|
-
cursor: Pagination cursor.
|
|
303
|
-
limit: Number of items to return (1-259).
|
|
304
|
-
|
|
305
|
-
Returns:
|
|
306
|
-
A dictionary containing a list of account objects and a pagination cursor.
|
|
307
|
-
|
|
308
|
-
Raises:
|
|
309
|
-
httpx.HTTPError: If the API request fails.
|
|
310
|
-
|
|
311
|
-
Tags:
|
|
312
|
-
linkedin, account, list, unipile, api, important
|
|
313
|
-
"""
|
|
314
|
-
url = f"{self.base_url}/api/v1/accounts"
|
|
315
|
-
params: dict[str, Any] = {}
|
|
316
|
-
if cursor:
|
|
317
|
-
params["cursor"] = cursor
|
|
318
|
-
if limit:
|
|
319
|
-
params["limit"] = limit
|
|
320
|
-
|
|
321
|
-
response = self._get(url, params=params)
|
|
322
|
-
return response.json()
|
|
323
|
-
|
|
324
|
-
def retrieve_linked_account(
|
|
325
|
-
self,
|
|
326
|
-
account_id: str,
|
|
327
|
-
) -> dict[str, Any]:
|
|
328
|
-
"""
|
|
329
|
-
Retrieves details for a specific account linked to Unipile using its ID. It fetches metadata about the connection itself (e.g., a linked LinkedIn account), differentiating it from `retrieve_user_profile` which fetches a user's profile from the external platform.
|
|
330
|
-
|
|
331
|
-
Args:
|
|
332
|
-
account_id: The ID of the account to retrieve.
|
|
333
|
-
|
|
334
|
-
Returns:
|
|
335
|
-
A dictionary containing the account object details.
|
|
336
|
-
|
|
337
|
-
Raises:
|
|
338
|
-
httpx.HTTPError: If the API request fails.
|
|
339
|
-
|
|
340
|
-
Tags:
|
|
341
|
-
linkedin, account, retrieve, get, unipile, api, important
|
|
342
|
-
"""
|
|
343
|
-
url = f"{self.base_url}/api/v1/accounts/{account_id}"
|
|
344
|
-
response = self._get(url)
|
|
345
|
-
return response.json()
|
|
346
|
-
|
|
347
|
-
def list_profile_posts(
|
|
348
|
-
self,
|
|
349
|
-
identifier: str, # User or Company provider internal ID
|
|
350
|
-
account_id: str, # Account to perform the request from (REQUIRED)
|
|
351
|
-
cursor: str | None = None,
|
|
352
|
-
limit: int | None = None, # 1-100 (spec says max 250)
|
|
353
|
-
is_company: bool | None = None,
|
|
354
|
-
) -> dict[str, Any]:
|
|
355
|
-
"""
|
|
356
|
-
Retrieves a paginated list of posts from a specific user or company profile using their provider ID. An authorizing `account_id` is required, and the `is_company` flag must specify the entity type, distinguishing this from `retrieve_post` which fetches a single post by its own ID.
|
|
357
|
-
|
|
358
|
-
Args:
|
|
359
|
-
identifier: The entity's provider internal ID (LinkedIn ID).
|
|
360
|
-
account_id: The ID of the Unipile account to perform the request from (REQUIRED).
|
|
361
|
-
cursor: Pagination cursor.
|
|
362
|
-
limit: Number of items to return (1-100, as per Unipile example, though spec allows up to 250).
|
|
363
|
-
is_company: Boolean indicating if the identifier is for a company.
|
|
364
|
-
|
|
365
|
-
Returns:
|
|
366
|
-
A dictionary containing a list of post objects and pagination details.
|
|
367
|
-
|
|
368
|
-
Raises:
|
|
369
|
-
httpx.HTTPError: If the API request fails.
|
|
370
|
-
|
|
371
|
-
Tags:
|
|
372
|
-
linkedin, post, list, user_posts, company_posts, content, api, important
|
|
373
|
-
"""
|
|
374
|
-
url = f"{self.base_url}/api/v1/users/{identifier}/posts"
|
|
375
|
-
params: dict[str, Any] = {"account_id": account_id}
|
|
376
|
-
if cursor:
|
|
377
|
-
params["cursor"] = cursor
|
|
378
|
-
if limit:
|
|
379
|
-
params["limit"] = limit
|
|
380
|
-
if is_company is not None:
|
|
381
|
-
params["is_company"] = is_company
|
|
382
|
-
|
|
383
|
-
response = self._get(url, params=params)
|
|
384
|
-
return response.json()
|
|
385
|
-
|
|
386
|
-
def retrieve_own_profile(
|
|
387
|
-
self,
|
|
388
|
-
account_id: str,
|
|
389
|
-
) -> dict[str, Any]:
|
|
390
|
-
"""
|
|
391
|
-
Retrieves the profile details for the user associated with the specified Unipile account ID. This function targets the API's 'me' endpoint to fetch the authenticated user's profile, distinct from `retrieve_user_profile` which fetches profiles of other users by their public identifier.
|
|
392
|
-
|
|
393
|
-
Args:
|
|
394
|
-
account_id: The ID of the Unipile account to use for retrieving the profile (REQUIRED).
|
|
395
|
-
|
|
396
|
-
Returns:
|
|
397
|
-
A dictionary containing the user's profile details.
|
|
398
|
-
|
|
399
|
-
Raises:
|
|
400
|
-
httpx.HTTPError: If the API request fails.
|
|
401
|
-
|
|
402
|
-
Tags:
|
|
403
|
-
linkedin, user, profile, me, retrieve, get, api
|
|
404
|
-
"""
|
|
405
|
-
url = f"{self.base_url}/api/v1/users/me"
|
|
406
|
-
params: dict[str, Any] = {"account_id": account_id}
|
|
407
|
-
response = self._get(url, params=params)
|
|
408
|
-
return response.json()
|
|
409
|
-
|
|
410
|
-
def retrieve_post(
|
|
411
|
-
self,
|
|
412
|
-
post_id: str,
|
|
413
|
-
account_id: str,
|
|
414
|
-
) -> dict[str, Any]:
|
|
415
|
-
"""
|
|
416
|
-
Fetches a specific post's details by its unique ID, requiring an `account_id` for authorization. Unlike `list_profile_posts`, which retrieves a collection of posts from a user or company profile, this function targets one specific post and returns its full object.
|
|
417
|
-
|
|
418
|
-
Args:
|
|
419
|
-
post_id: The ID of the post to retrieve.
|
|
420
|
-
account_id: The ID of the Unipile account to perform the request from (REQUIRED).
|
|
421
|
-
|
|
422
|
-
Returns:
|
|
423
|
-
A dictionary containing the post details.
|
|
424
|
-
|
|
425
|
-
Raises:
|
|
426
|
-
httpx.HTTPError: If the API request fails.
|
|
427
|
-
|
|
428
|
-
Tags:
|
|
429
|
-
linkedin, post, retrieve, get, content, api, important
|
|
430
|
-
"""
|
|
431
|
-
url = f"{self.base_url}/api/v1/posts/{post_id}"
|
|
432
|
-
params: dict[str, Any] = {"account_id": account_id}
|
|
433
|
-
response = self._get(url, params=params)
|
|
434
|
-
return response.json()
|
|
435
|
-
|
|
436
|
-
def list_post_comments(
|
|
437
|
-
self,
|
|
438
|
-
post_id: str,
|
|
439
|
-
account_id: str,
|
|
440
|
-
comment_id: str | None = None,
|
|
441
|
-
cursor: str | None = None,
|
|
442
|
-
limit: int | None = None,
|
|
443
|
-
) -> dict[str, Any]:
|
|
444
|
-
"""
|
|
445
|
-
Fetches comments for a specific post using an `account_id` for authorization. Providing an optional `comment_id` retrieves threaded replies instead of top-level comments. This read-only operation contrasts with `create_post_comment`, which publishes new comments, and `list_content_reactions`, which retrieves 'likes'.
|
|
446
|
-
|
|
447
|
-
Args:
|
|
448
|
-
post_id: The social ID of the post.
|
|
449
|
-
account_id: The ID of the Unipile account to perform the request from (REQUIRED).
|
|
450
|
-
comment_id: If provided, retrieves replies to this comment ID instead of top-level comments.
|
|
451
|
-
cursor: Pagination cursor.
|
|
452
|
-
limit: Number of comments to return. (OpenAPI spec shows type string, passed as string if provided).
|
|
453
|
-
|
|
454
|
-
Returns:
|
|
455
|
-
A dictionary containing a list of comment objects and pagination details.
|
|
456
|
-
|
|
457
|
-
Raises:
|
|
458
|
-
httpx.HTTPError: If the API request fails.
|
|
459
|
-
|
|
460
|
-
Tags:
|
|
461
|
-
linkedin, post, comment, list, content, api, important
|
|
462
|
-
"""
|
|
463
|
-
url = f"{self.base_url}/api/v1/posts/{post_id}/comments"
|
|
464
|
-
params: dict[str, Any] = {"account_id": account_id}
|
|
465
|
-
if cursor:
|
|
466
|
-
params["cursor"] = cursor
|
|
467
|
-
if limit is not None:
|
|
468
|
-
params["limit"] = str(limit)
|
|
469
|
-
if comment_id:
|
|
470
|
-
params["comment_id"] = comment_id
|
|
471
|
-
|
|
472
|
-
response = self._get(url, params=params)
|
|
473
|
-
return response.json()
|
|
474
|
-
|
|
475
|
-
def create_post(
|
|
476
|
-
self,
|
|
477
|
-
account_id: str,
|
|
478
|
-
text: str,
|
|
479
|
-
mentions: list[dict[str, Any]] | None = None,
|
|
480
|
-
external_link: str | None = None,
|
|
481
|
-
) -> dict[str, Any]:
|
|
482
|
-
"""
|
|
483
|
-
Publishes a new top-level post from a specified account, including text, user mentions, and an external link. This function creates original content, distinguishing it from `create_post_comment` which adds replies to existing posts.
|
|
484
|
-
|
|
485
|
-
Args:
|
|
486
|
-
account_id: The ID of the Unipile account that will author the post (added as query parameter).
|
|
487
|
-
text: The main text content of the post.
|
|
488
|
-
mentions: Optional list of dictionaries, each representing a mention.
|
|
489
|
-
Example: `[{"entity_urn": "urn:li:person:...", "start_index": 0, "end_index": 5}]`
|
|
490
|
-
external_link: Optional string, an external URL that should be displayed within a card.
|
|
491
|
-
|
|
492
|
-
Returns:
|
|
493
|
-
A dictionary containing the ID of the created post.
|
|
494
|
-
|
|
495
|
-
Raises:
|
|
496
|
-
httpx.HTTPError: If the API request fails.
|
|
497
|
-
|
|
498
|
-
Tags:
|
|
499
|
-
linkedin, post, create, share, content, api, important
|
|
500
|
-
"""
|
|
501
|
-
url = f"{self.base_url}/api/v1/posts"
|
|
502
|
-
|
|
503
|
-
params: dict[str, str] = {
|
|
504
|
-
"account_id": account_id,
|
|
505
|
-
"text": text,
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
if mentions:
|
|
509
|
-
params["mentions"] = mentions
|
|
510
|
-
if external_link:
|
|
511
|
-
params["external_link"] = external_link
|
|
512
|
-
|
|
513
|
-
response = self._post(url, data=params)
|
|
514
|
-
return response.json()
|
|
515
|
-
|
|
516
|
-
def list_content_reactions(
|
|
517
|
-
self,
|
|
518
|
-
post_id: str,
|
|
519
|
-
account_id: str,
|
|
520
|
-
comment_id: str | None = None,
|
|
521
|
-
cursor: str | None = None,
|
|
522
|
-
limit: int | None = None,
|
|
523
|
-
) -> dict[str, Any]:
|
|
524
|
-
"""
|
|
525
|
-
Retrieves a paginated list of reactions for a given post or, optionally, a specific comment. This read-only operation uses the provided `account_id` for the request, distinguishing it from the `create_reaction` function which adds new reactions.
|
|
526
|
-
|
|
527
|
-
Args:
|
|
528
|
-
post_id: The social ID of the post.
|
|
529
|
-
account_id: The ID of the Unipile account to perform the request from .
|
|
530
|
-
comment_id: If provided, retrieves reactions for this comment ID.
|
|
531
|
-
cursor: Pagination cursor.
|
|
532
|
-
limit: Number of reactions to return (1-100, spec max 250).
|
|
533
|
-
|
|
534
|
-
Returns:
|
|
535
|
-
A dictionary containing a list of reaction objects and pagination details.
|
|
536
|
-
|
|
537
|
-
Raises:
|
|
538
|
-
httpx.HTTPError: If the API request fails.
|
|
539
|
-
|
|
540
|
-
Tags:
|
|
541
|
-
linkedin, post, reaction, list, like, content, api
|
|
542
|
-
"""
|
|
543
|
-
url = f"{self.base_url}/api/v1/posts/{post_id}/reactions"
|
|
544
|
-
params: dict[str, Any] = {"account_id": account_id}
|
|
545
|
-
if cursor:
|
|
546
|
-
params["cursor"] = cursor
|
|
547
|
-
if limit:
|
|
548
|
-
params["limit"] = limit
|
|
549
|
-
if comment_id:
|
|
550
|
-
params["comment_id"] = comment_id
|
|
551
|
-
|
|
552
|
-
response = self._get(url, params=params)
|
|
553
|
-
return response.json()
|
|
554
|
-
|
|
555
|
-
def create_post_comment(
|
|
556
|
-
self,
|
|
557
|
-
post_social_id: str,
|
|
558
|
-
account_id: str,
|
|
559
|
-
text: str,
|
|
560
|
-
comment_id: str | None = None, # If provided, replies to a specific comment
|
|
561
|
-
mentions_body: list[dict[str, Any]] | None = None,
|
|
562
|
-
) -> dict[str, Any]:
|
|
563
|
-
"""
|
|
564
|
-
Publishes a comment on a specified post. By providing an optional `comment_id`, it creates a threaded reply to an existing comment instead of a new top-level one. This function's dual capability distinguishes it from `list_post_comments`, which only retrieves comments and their replies.
|
|
565
|
-
|
|
566
|
-
Args:
|
|
567
|
-
post_social_id: The social ID of the post to comment on.
|
|
568
|
-
account_id: The ID of the Unipile account performing the comment.
|
|
569
|
-
text: The text content of the comment (passed as a query parameter).
|
|
570
|
-
Supports Unipile's mention syntax like "Hey {{0}}".
|
|
571
|
-
comment_id: Optional ID of a specific comment to reply to instead of commenting on the post.
|
|
572
|
-
mentions_body: Optional list of mention objects for the request body if needed.
|
|
573
|
-
|
|
574
|
-
Returns:
|
|
575
|
-
A dictionary, likely confirming comment creation. (Structure depends on actual API response)
|
|
576
|
-
|
|
577
|
-
Raises:
|
|
578
|
-
httpx.HTTPError: If the API request fails.
|
|
579
|
-
|
|
580
|
-
Tags:
|
|
581
|
-
linkedin, post, comment, create, content, api, important
|
|
582
|
-
"""
|
|
583
|
-
url = f"{self.base_url}/api/v1/posts/{post_social_id}/comments"
|
|
584
|
-
params: dict[str, Any] = {
|
|
585
|
-
"account_id": account_id,
|
|
586
|
-
"text": text,
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
if comment_id:
|
|
590
|
-
params["comment_id"] = comment_id
|
|
591
|
-
|
|
592
|
-
if mentions_body:
|
|
593
|
-
params = {"mentions": mentions_body}
|
|
594
|
-
|
|
595
|
-
response = self._post(url, data=params)
|
|
596
|
-
|
|
597
|
-
try:
|
|
598
|
-
return response.json()
|
|
599
|
-
except json.JSONDecodeError:
|
|
600
|
-
return {
|
|
601
|
-
"status": response.status_code,
|
|
602
|
-
"message": "Comment action processed.",
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
def create_reaction(
|
|
606
|
-
self,
|
|
607
|
-
post_social_id: str,
|
|
608
|
-
reaction_type: Literal[
|
|
609
|
-
"like", "celebrate", "love", "insightful", "funny", "support"
|
|
610
|
-
],
|
|
611
|
-
account_id: str,
|
|
612
|
-
comment_id: str | None = None,
|
|
613
|
-
) -> dict[str, Any]:
|
|
614
|
-
"""
|
|
615
|
-
Adds a specified reaction (e.g., 'like', 'love') to a LinkedIn post or, optionally, to a specific comment. This function performs a POST request to create the reaction, differentiating it from `list_content_reactions` which only retrieves existing ones.
|
|
616
|
-
|
|
617
|
-
Args:
|
|
618
|
-
post_social_id: The social ID of the post or comment to react to.
|
|
619
|
-
reaction_type: The type of reaction .
|
|
620
|
-
account_id: Account ID of the Unipile account performing the reaction.
|
|
621
|
-
comment_id: Optional ID of a specific comment to react to instead of the post.
|
|
622
|
-
|
|
623
|
-
Returns:
|
|
624
|
-
A dictionary, likely confirming the reaction. (Structure depends on actual API response)
|
|
625
|
-
|
|
626
|
-
Raises:
|
|
627
|
-
httpx.HTTPError: If the API request fails.
|
|
628
|
-
|
|
629
|
-
Tags:
|
|
630
|
-
linkedin, post, reaction, create, like, content, api, important
|
|
631
|
-
"""
|
|
632
|
-
url = f"{self.base_url}/api/v1/posts/reaction"
|
|
633
|
-
|
|
634
|
-
params: dict[str, str] = {
|
|
635
|
-
"account_id": account_id,
|
|
636
|
-
"post_id": post_social_id,
|
|
637
|
-
"reaction_type": reaction_type,
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
if comment_id:
|
|
641
|
-
params["comment_id"] = comment_id
|
|
642
|
-
|
|
643
|
-
response = self._post(url, data=params)
|
|
644
|
-
|
|
645
|
-
try:
|
|
646
|
-
return response.json()
|
|
647
|
-
except json.JSONDecodeError:
|
|
648
|
-
return {
|
|
649
|
-
"status": response.status_code,
|
|
650
|
-
"message": "Reaction action processed.",
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
def search(
|
|
654
|
-
self,
|
|
655
|
-
account_id: str,
|
|
656
|
-
category: Literal["people", "companies", "posts", "jobs"] = "posts",
|
|
657
|
-
api: Literal["classic", "sales_navigator"] = "classic",
|
|
658
|
-
cursor: str | None = None,
|
|
659
|
-
limit: int | None = None,
|
|
660
|
-
keywords: str | None = None,
|
|
661
|
-
sort_by: Literal["relevance", "date"] | None = None,
|
|
662
|
-
date_posted: Literal["past_day", "past_week", "past_month"] | None = None,
|
|
663
|
-
content_type: Literal[
|
|
664
|
-
"videos", "images", "live_videos", "collaborative_articles", "documents"
|
|
665
|
-
]
|
|
666
|
-
| None = None,
|
|
667
|
-
posted_by: dict[str, Any] | None = None,
|
|
668
|
-
mentioning: dict[str, Any] | None = None,
|
|
669
|
-
author: dict[str, Any] | None = None,
|
|
670
|
-
# People search specific parameters
|
|
671
|
-
location: list[str] | None = None,
|
|
672
|
-
industry: list[str] | None = None,
|
|
673
|
-
company: list[str] | None = None,
|
|
674
|
-
past_company: list[str] | None = None,
|
|
675
|
-
school: list[str] | None = None,
|
|
676
|
-
# Company search specific parameters
|
|
677
|
-
headcount: list[dict[str, int]] | None = None,
|
|
678
|
-
# Job search specific parameters
|
|
679
|
-
job_type: list[str] | None = None,
|
|
680
|
-
minimum_salary: dict[str, Any] | None = None,
|
|
681
|
-
# URL search
|
|
682
|
-
search_url: str | None = None,
|
|
683
|
-
) -> dict[str, Any]:
|
|
684
|
-
"""
|
|
685
|
-
Performs a comprehensive LinkedIn search for people, companies, posts, or jobs using granular filters like keywords and location. Alternatively, it can execute a search from a direct LinkedIn URL. Supports pagination and targets either the classic or Sales Navigator API.
|
|
686
|
-
|
|
687
|
-
Args:
|
|
688
|
-
account_id: The ID of the Unipile account to perform the search from (REQUIRED).
|
|
689
|
-
category: Type of search to perform - "people", "companies", "posts", or "jobs".
|
|
690
|
-
api: Which LinkedIn API to use - "classic" or "sales_navigator".
|
|
691
|
-
cursor: Pagination cursor for the next page of entries.
|
|
692
|
-
limit: Number of items to return (up to 50 for Classic search).
|
|
693
|
-
keywords: Keywords to search for.
|
|
694
|
-
sort_by: How to sort the results, e.g., "relevance" or "date".
|
|
695
|
-
date_posted: Filter posts by when they were posted (posts only).
|
|
696
|
-
content_type: Filter by the type of content in the post (posts only).
|
|
697
|
-
posted_by: Dictionary to filter by who posted (posts only).
|
|
698
|
-
location: Location filter for people/company search (array of strings).
|
|
699
|
-
industry: Industry filter for people/company search (array of strings).
|
|
700
|
-
company: Company filter for people search (array of strings).
|
|
701
|
-
past_company: Past company filter for people search (array of strings).
|
|
702
|
-
school: School filter for people search (array of strings).
|
|
703
|
-
headcount: Company size filter for company search (array of objects with min/max numbers).
|
|
704
|
-
job_type: Job type filter for job search (array of strings).
|
|
705
|
-
minimum_salary: Minimum salary filter for job search (object with currency and value). Example:
|
|
706
|
-
minimum_salary = {
|
|
707
|
-
"currency": "USD",
|
|
708
|
-
"value": 80
|
|
709
|
-
}
|
|
710
|
-
search_url: Direct LinkedIn search URL to use instead of building parameters.
|
|
711
|
-
|
|
712
|
-
Returns:
|
|
713
|
-
A dictionary containing search results and pagination details.
|
|
714
|
-
|
|
715
|
-
Raises:
|
|
716
|
-
httpx.HTTPError: If the API request fails.
|
|
717
|
-
|
|
718
|
-
Tags:
|
|
719
|
-
linkedin, search, people, companies, posts, jobs, api, important
|
|
720
|
-
"""
|
|
721
|
-
url = f"{self.base_url}/api/v1/linkedin/search"
|
|
722
|
-
|
|
723
|
-
params: dict[str, Any] = {"account_id": account_id}
|
|
724
|
-
if cursor:
|
|
725
|
-
params["cursor"] = cursor
|
|
726
|
-
if limit is not None:
|
|
727
|
-
params["limit"] = limit
|
|
728
|
-
|
|
729
|
-
payload: dict[str, Any] = {"api": api, "category": category}
|
|
730
|
-
|
|
731
|
-
# Add search URL if provided (takes precedence over other parameters)
|
|
732
|
-
if search_url:
|
|
733
|
-
payload["search_url"] = search_url
|
|
734
|
-
else:
|
|
735
|
-
# Add common parameters
|
|
736
|
-
common_params = {
|
|
737
|
-
"keywords": keywords,
|
|
738
|
-
"sort_by": sort_by,
|
|
739
|
-
}
|
|
740
|
-
payload.update({k: v for k, v in common_params.items() if v is not None})
|
|
741
|
-
|
|
742
|
-
# Category-specific parameters
|
|
743
|
-
category_params = {
|
|
744
|
-
"posts": {
|
|
745
|
-
"date_posted": date_posted,
|
|
746
|
-
"content_type": content_type,
|
|
747
|
-
"posted_by": posted_by,
|
|
748
|
-
},
|
|
749
|
-
"people": {
|
|
750
|
-
"location": location,
|
|
751
|
-
"industry": industry,
|
|
752
|
-
"company": company,
|
|
753
|
-
"past_company": past_company,
|
|
754
|
-
"school": school,
|
|
755
|
-
},
|
|
756
|
-
"companies": {
|
|
757
|
-
"location": location,
|
|
758
|
-
"industry": industry,
|
|
759
|
-
"headcount": headcount,
|
|
760
|
-
},
|
|
761
|
-
"jobs": {
|
|
762
|
-
"location": location,
|
|
763
|
-
"job_type": job_type,
|
|
764
|
-
"minimum_salary": minimum_salary,
|
|
765
|
-
},
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
if category in category_params:
|
|
769
|
-
payload.update(
|
|
770
|
-
{
|
|
771
|
-
k: v
|
|
772
|
-
for k, v in category_params[category].items()
|
|
773
|
-
if v is not None
|
|
774
|
-
}
|
|
775
|
-
)
|
|
776
|
-
|
|
777
|
-
response = self._post(url, params=params, data=payload)
|
|
778
|
-
return self._handle_response(response)
|
|
779
|
-
|
|
780
|
-
def people_search(
|
|
781
|
-
self,
|
|
782
|
-
account_id: str,
|
|
783
|
-
cursor: str | None = None,
|
|
784
|
-
limit: int | None = None,
|
|
785
|
-
keywords: str | None = None,
|
|
786
|
-
last_viewed_at: int | None = None,
|
|
787
|
-
saved_search_id: str | None = None,
|
|
788
|
-
recent_search_id: str | None = None,
|
|
789
|
-
location: dict[str, Any] | None = None,
|
|
790
|
-
location_by_postal_code: dict[str, Any] | None = None,
|
|
791
|
-
industry: dict[str, Any] | None = None,
|
|
792
|
-
first_name: str | None = None,
|
|
793
|
-
last_name: str | None = None,
|
|
794
|
-
tenure: list[dict[str, Any]] | None = None,
|
|
795
|
-
groups: list[str] | None = None,
|
|
796
|
-
school: dict[str, Any] | None = None,
|
|
797
|
-
profile_language: list[str] | None = None,
|
|
798
|
-
company: dict[str, Any] | None = None,
|
|
799
|
-
company_headcount: list[dict[str, Any]] | None = None,
|
|
800
|
-
company_type: list[str] | None = None,
|
|
801
|
-
company_location: dict[str, Any] | None = None,
|
|
802
|
-
tenure_at_company: list[dict[str, Any]] | None = None,
|
|
803
|
-
past_company: dict[str, Any] | None = None,
|
|
804
|
-
function: dict[str, Any] | None = None,
|
|
805
|
-
role: dict[str, Any] | None = None,
|
|
806
|
-
tenure_at_role: list[dict[str, Any]] | None = None,
|
|
807
|
-
seniority: dict[str, Any] | None = None,
|
|
808
|
-
past_role: dict[str, Any] | None = None,
|
|
809
|
-
following_your_company: bool | None = None,
|
|
810
|
-
viewed_your_profile_recently: bool | None = None,
|
|
811
|
-
network_distance: list[str] | None = None,
|
|
812
|
-
connections_of: list[str] | None = None,
|
|
813
|
-
past_colleague: bool | None = None,
|
|
814
|
-
shared_experiences: bool | None = None,
|
|
815
|
-
changed_jobs: bool | None = None,
|
|
816
|
-
posted_on_linkedin: bool | None = None,
|
|
817
|
-
mentionned_in_news: bool | None = None,
|
|
818
|
-
persona: list[str] | None = None,
|
|
819
|
-
account_lists: dict[str, Any] | None = None,
|
|
820
|
-
lead_lists: dict[str, Any] | None = None,
|
|
821
|
-
viewed_profile_recently: bool | None = None,
|
|
822
|
-
messaged_recently: bool | None = None,
|
|
823
|
-
include_saved_leads: bool | None = None,
|
|
824
|
-
include_saved_accounts: bool | None = None,
|
|
825
|
-
) -> dict[str, Any]:
|
|
826
|
-
"""
|
|
827
|
-
Performs a comprehensive LinkedIn Sales Navigator people search with all available parameters.
|
|
828
|
-
This function provides access to LinkedIn's advanced Sales Navigator search capabilities
|
|
829
|
-
for finding people with precise targeting options.
|
|
830
|
-
|
|
831
|
-
Args:
|
|
832
|
-
account_id: The ID of the Unipile account to perform the search from (REQUIRED).
|
|
833
|
-
cursor: Pagination cursor for the next page of entries.
|
|
834
|
-
limit: Number of items to return.
|
|
835
|
-
keywords: LinkedIn native filter: KEYWORDS.
|
|
836
|
-
last_viewed_at: Unix timestamp for saved search filtering.
|
|
837
|
-
saved_search_id: ID of saved search (overrides other parameters).
|
|
838
|
-
recent_search_id: ID of recent search (overrides other parameters).
|
|
839
|
-
location: LinkedIn native filter: GEOGRAPHY.
|
|
840
|
-
location_by_postal_code: Location filter by postal code.
|
|
841
|
-
industry: LinkedIn native filter: INDUSTRY.
|
|
842
|
-
first_name: LinkedIn native filter: FIRST NAME.
|
|
843
|
-
last_name: LinkedIn native filter: LAST NAME.
|
|
844
|
-
tenure: LinkedIn native filter: YEARS OF EXPERIENCE.
|
|
845
|
-
groups: LinkedIn native filter: GROUPS.
|
|
846
|
-
school: LinkedIn native filter: SCHOOL.
|
|
847
|
-
profile_language: ISO 639-1 language codes, LinkedIn native filter: PROFILE LANGUAGE.
|
|
848
|
-
company: LinkedIn native filter: CURRENT COMPANY.
|
|
849
|
-
company_headcount: LinkedIn native filter: COMPANY HEADCOUNT.
|
|
850
|
-
company_type: LinkedIn native filter: COMPANY TYPE.
|
|
851
|
-
company_location: LinkedIn native filter: COMPANY HEADQUARTERS LOCATION.
|
|
852
|
-
tenure_at_company: LinkedIn native filter: YEARS IN CURRENT COMPANY.
|
|
853
|
-
past_company: LinkedIn native filter: PAST COMPANY.
|
|
854
|
-
function: LinkedIn native filter: FUNCTION.
|
|
855
|
-
role: LinkedIn native filter: CURRENT JOB TITLE.
|
|
856
|
-
tenure_at_role: LinkedIn native filter: YEARS IN CURRENT POSITION.
|
|
857
|
-
seniority: LinkedIn native filter: SENIORITY LEVEL.
|
|
858
|
-
past_role: LinkedIn native filter: PAST JOB TITLE.
|
|
859
|
-
following_your_company: LinkedIn native filter: FOLLOWING YOUR COMPANY.
|
|
860
|
-
viewed_your_profile_recently: LinkedIn native filter: VIEWED YOUR PROFILE RECENTLY.
|
|
861
|
-
network_distance: First, second, third+ degree or GROUP, LinkedIn native filter: CONNECTION.
|
|
862
|
-
connections_of: LinkedIn native filter: CONNECTIONS OF.
|
|
863
|
-
past_colleague: LinkedIn native filter: PAST COLLEAGUE.
|
|
864
|
-
shared_experiences: LinkedIn native filter: SHARED EXPERIENCES.
|
|
865
|
-
changed_jobs: LinkedIn native filter: CHANGED JOBS.
|
|
866
|
-
posted_on_linkedin: LinkedIn native filter: POSTED ON LINKEDIN.
|
|
867
|
-
mentionned_in_news: LinkedIn native filter: MENTIONNED IN NEWS.
|
|
868
|
-
persona: LinkedIn native filter: PERSONA.
|
|
869
|
-
account_lists: LinkedIn native filter: ACCOUNT LISTS.
|
|
870
|
-
lead_lists: LinkedIn native filter: LEAD LISTS.
|
|
871
|
-
viewed_profile_recently: LinkedIn native filter: PEOPLE YOU INTERACTED WITH / VIEWED PROFILE.
|
|
872
|
-
messaged_recently: LinkedIn native filter: PEOPLE YOU INTERACTED WITH / MESSAGED.
|
|
873
|
-
include_saved_leads: LinkedIn native filter: SAVED LEADS AND ACCOUNTS / ALL MY SAVED LEADS.
|
|
874
|
-
include_saved_accounts: LinkedIn native filter: SAVED LEADS AND ACCOUNTS / ALL MY SAVED ACCOUNTS.
|
|
875
|
-
|
|
876
|
-
Returns:
|
|
877
|
-
A dictionary containing search results and pagination details.
|
|
878
|
-
|
|
879
|
-
Raises:
|
|
880
|
-
httpx.HTTPError: If the API request fails.
|
|
881
|
-
|
|
882
|
-
Tags:
|
|
883
|
-
linkedin, sales_navigator, people, search, advanced, api, important
|
|
884
|
-
"""
|
|
885
|
-
url = f"{self.base_url}/api/v1/linkedin/search"
|
|
886
|
-
|
|
887
|
-
params: dict[str, Any] = {"account_id": account_id}
|
|
888
|
-
if cursor:
|
|
889
|
-
params["cursor"] = cursor
|
|
890
|
-
if limit is not None:
|
|
891
|
-
params["limit"] = limit
|
|
892
|
-
|
|
893
|
-
payload: dict[str, Any] = {"api": "sales_navigator", "category": "people"}
|
|
894
|
-
|
|
895
|
-
# Add all the Sales Navigator specific parameters
|
|
896
|
-
sn_params = {
|
|
897
|
-
"keywords": keywords,
|
|
898
|
-
"last_viewed_at": last_viewed_at,
|
|
899
|
-
"saved_search_id": saved_search_id,
|
|
900
|
-
"recent_search_id": recent_search_id,
|
|
901
|
-
"location": location,
|
|
902
|
-
"location_by_postal_code": location_by_postal_code,
|
|
903
|
-
"industry": industry,
|
|
904
|
-
"first_name": first_name,
|
|
905
|
-
"last_name": last_name,
|
|
906
|
-
"tenure": tenure,
|
|
907
|
-
"groups": groups,
|
|
908
|
-
"school": school,
|
|
909
|
-
"profile_language": profile_language,
|
|
910
|
-
"company": company,
|
|
911
|
-
"company_headcount": company_headcount,
|
|
912
|
-
"company_type": company_type,
|
|
913
|
-
"company_location": company_location,
|
|
914
|
-
"tenure_at_company": tenure_at_company,
|
|
915
|
-
"past_company": past_company,
|
|
916
|
-
"function": function,
|
|
917
|
-
"role": role,
|
|
918
|
-
"tenure_at_role": tenure_at_role,
|
|
919
|
-
"seniority": seniority,
|
|
920
|
-
"past_role": past_role,
|
|
921
|
-
"following_your_company": following_your_company,
|
|
922
|
-
"viewed_your_profile_recently": viewed_your_profile_recently,
|
|
923
|
-
"network_distance": network_distance,
|
|
924
|
-
"connections_of": connections_of,
|
|
925
|
-
"past_colleague": past_colleague,
|
|
926
|
-
"shared_experiences": shared_experiences,
|
|
927
|
-
"changed_jobs": changed_jobs,
|
|
928
|
-
"posted_on_linkedin": posted_on_linkedin,
|
|
929
|
-
"mentionned_in_news": mentionned_in_news,
|
|
930
|
-
"persona": persona,
|
|
931
|
-
"account_lists": account_lists,
|
|
932
|
-
"lead_lists": lead_lists,
|
|
933
|
-
"viewed_profile_recently": viewed_profile_recently,
|
|
934
|
-
"messaged_recently": messaged_recently,
|
|
935
|
-
"include_saved_leads": include_saved_leads,
|
|
936
|
-
"include_saved_accounts": include_saved_accounts,
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
# Only add parameters that are not None
|
|
940
|
-
payload.update({k: v for k, v in sn_params.items() if v is not None})
|
|
941
|
-
|
|
942
|
-
response = self._post(url, params=params, data=payload)
|
|
943
|
-
return self._handle_response(response)
|
|
944
|
-
|
|
945
|
-
def company_search(
|
|
946
|
-
self,
|
|
947
|
-
account_id: str,
|
|
948
|
-
cursor: str | None = None,
|
|
949
|
-
limit: int | None = None,
|
|
950
|
-
keywords: str | None = None,
|
|
951
|
-
last_viewed_at: int | None = None,
|
|
952
|
-
saved_search_id: str | None = None,
|
|
953
|
-
recent_search_id: str | None = None,
|
|
954
|
-
location: dict[str, Any] | None = None,
|
|
955
|
-
location_by_postal_code: dict[str, Any] | None = None,
|
|
956
|
-
industry: dict[str, Any] | None = None,
|
|
957
|
-
company_headcount: list[dict[str, Any]] | None = None,
|
|
958
|
-
company_type: list[str] | None = None,
|
|
959
|
-
company_location: dict[str, Any] | None = None,
|
|
960
|
-
following_your_company: bool | None = None,
|
|
961
|
-
account_lists: dict[str, Any] | None = None,
|
|
962
|
-
include_saved_accounts: bool | None = None,
|
|
963
|
-
) -> dict[str, Any]:
|
|
964
|
-
"""
|
|
965
|
-
Performs a comprehensive LinkedIn Sales Navigator company search with relevant parameters.
|
|
966
|
-
This function provides access to LinkedIn's advanced Sales Navigator search capabilities
|
|
967
|
-
for finding companies with precise targeting options.
|
|
968
|
-
|
|
969
|
-
Args:
|
|
970
|
-
account_id: The ID of the Unipile account to perform the search from (REQUIRED).
|
|
971
|
-
cursor: Pagination cursor for the next page of entries.
|
|
972
|
-
limit: Number of items to return.
|
|
973
|
-
keywords: LinkedIn native filter: KEYWORDS.
|
|
974
|
-
last_viewed_at: Unix timestamp for saved search filtering.
|
|
975
|
-
saved_search_id: ID of saved search (overrides other parameters).
|
|
976
|
-
recent_search_id: ID of recent search (overrides other parameters).
|
|
977
|
-
location: LinkedIn native filter: GEOGRAPHY.
|
|
978
|
-
location_by_postal_code: Location filter by postal code.
|
|
979
|
-
industry: LinkedIn native filter: INDUSTRY.
|
|
980
|
-
company_headcount: LinkedIn native filter: COMPANY HEADCOUNT. Example {"min": 10, "max": 100}
|
|
981
|
-
company_type: LinkedIn native filter: COMPANY TYPE.
|
|
982
|
-
company_location: LinkedIn native filter: COMPANY HEADQUARTERS LOCATION.
|
|
983
|
-
following_your_company: LinkedIn native filter: FOLLOWING YOUR COMPANY.
|
|
984
|
-
account_lists: LinkedIn native filter: ACCOUNT LISTS.
|
|
985
|
-
include_saved_accounts: LinkedIn native filter: SAVED LEADS AND ACCOUNTS / ALL MY SAVED ACCOUNTS.
|
|
986
|
-
|
|
987
|
-
Returns:
|
|
988
|
-
A dictionary containing search results and pagination details.
|
|
989
|
-
|
|
990
|
-
Raises:
|
|
991
|
-
httpx.HTTPError: If the API request fails.
|
|
992
|
-
|
|
993
|
-
Tags:
|
|
994
|
-
linkedin, sales_navigator, companies, search, advanced, api, important
|
|
995
|
-
"""
|
|
996
|
-
url = f"{self.base_url}/api/v1/linkedin/search"
|
|
997
|
-
|
|
998
|
-
params: dict[str, Any] = {"account_id": account_id}
|
|
999
|
-
if cursor:
|
|
1000
|
-
params["cursor"] = cursor
|
|
1001
|
-
if limit is not None:
|
|
1002
|
-
params["limit"] = limit
|
|
1003
|
-
|
|
1004
|
-
payload: dict[str, Any] = {"api": "sales_navigator", "category": "companies"}
|
|
1005
|
-
|
|
1006
|
-
# Add all the Sales Navigator company-specific parameters
|
|
1007
|
-
sn_params = {
|
|
1008
|
-
"keywords": keywords,
|
|
1009
|
-
"last_viewed_at": last_viewed_at,
|
|
1010
|
-
"saved_search_id": saved_search_id,
|
|
1011
|
-
"recent_search_id": recent_search_id,
|
|
1012
|
-
"location": location,
|
|
1013
|
-
"location_by_postal_code": location_by_postal_code,
|
|
1014
|
-
"industry": industry,
|
|
1015
|
-
"company_headcount": company_headcount,
|
|
1016
|
-
"company_type": company_type,
|
|
1017
|
-
"company_location": company_location,
|
|
1018
|
-
"following_your_company": following_your_company,
|
|
1019
|
-
"account_lists": account_lists,
|
|
1020
|
-
"include_saved_accounts": include_saved_accounts,
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1023
|
-
# Only add parameters that are not None
|
|
1024
|
-
payload.update({k: v for k, v in sn_params.items() if v is not None})
|
|
1025
|
-
|
|
1026
|
-
response = self._post(url, params=params, data=payload)
|
|
1027
|
-
return self._handle_response(response)
|
|
1028
|
-
|
|
1029
|
-
def retrieve_user_profile(
|
|
1030
|
-
self,
|
|
1031
|
-
identifier: str,
|
|
1032
|
-
account_id: str,
|
|
1033
|
-
) -> dict[str, Any]:
|
|
1034
|
-
"""
|
|
1035
|
-
Retrieves a specific LinkedIn user's profile using their public or internal ID, authorized via the provided `account_id`. Unlike `retrieve_own_profile`, which fetches the authenticated user's details, this function targets and returns data for any specified third-party user profile on the platform.
|
|
1036
|
-
|
|
1037
|
-
Args:
|
|
1038
|
-
identifier: Can be the provider's internal id OR the provider's public id of the requested user.For example, for https://www.linkedin.com/in/manojbajaj95/, the identifier is "manojbajaj95".
|
|
1039
|
-
|
|
1040
|
-
account_id: The ID of the Unipile account to perform the request from (REQUIRED).
|
|
1041
|
-
|
|
1042
|
-
Returns:
|
|
1043
|
-
A dictionary containing the user's profile details.
|
|
1044
|
-
|
|
1045
|
-
Raises:
|
|
1046
|
-
httpx.HTTPError: If the API request fails.
|
|
1047
|
-
|
|
1048
|
-
Tags:
|
|
1049
|
-
linkedin, user, profile, retrieve, get, api, important
|
|
1050
|
-
"""
|
|
1051
|
-
url = f"{self.base_url}/api/v1/users/{identifier}"
|
|
1052
|
-
params: dict[str, Any] = {"account_id": account_id}
|
|
1053
|
-
response = self._get(url, params=params)
|
|
1054
|
-
return self._handle_response(response)
|
|
1055
|
-
|
|
1056
|
-
def list_tools(self) -> list[Callable]:
|
|
1057
|
-
return [
|
|
1058
|
-
self.list_all_chats,
|
|
1059
|
-
self.list_chat_messages,
|
|
1060
|
-
self.send_chat_message,
|
|
1061
|
-
self.retrieve_chat,
|
|
1062
|
-
self.list_all_messages,
|
|
1063
|
-
self.list_all_accounts,
|
|
1064
|
-
self.retrieve_linked_account,
|
|
1065
|
-
self.list_profile_posts,
|
|
1066
|
-
self.retrieve_own_profile,
|
|
1067
|
-
self.retrieve_user_profile,
|
|
1068
|
-
self.retrieve_post,
|
|
1069
|
-
self.list_post_comments,
|
|
1070
|
-
self.create_post,
|
|
1071
|
-
self.list_content_reactions,
|
|
1072
|
-
self.create_post_comment,
|
|
1073
|
-
self.create_reaction,
|
|
1074
|
-
self.search,
|
|
1075
|
-
self.people_search,
|
|
1076
|
-
self.company_search,
|
|
1077
|
-
]
|