### Install Linked API SDK for Node.js Source: https://linkedapi.io/sdks/installation Install the SDK using npm for Node.js projects. ```bash npm install -S @linkedapi/node ``` -------------------------------- ### Install Linked API SDK for Python Source: https://linkedapi.io/sdks/installation Install the SDK using pip for Python projects. ```bash pip install linkedapi ``` -------------------------------- ### Start and Save Workflow References Source: https://linkedapi.io/sdks/persisting-workflows Initiate a workflow and save its ID to a database for later retrieval. This is the first step in persisting a workflow. ```typescript // --- Step 1 & 2: Initiate a workflow and save its references --- async function startAndSaveWorkflow(taskId) { try { const { workflowId } = await linkedapi.checkConnectionStatus.execute({ personUrl: "https://www.linkedin.com/in/john-doe" }); // Save the workflow ID to your database await db.saveTask({ taskId: taskId, workflowId: workflowId }); console.log(`Workflow ${workflowId} started and saved for task ${taskId}.`); } catch (e) { console.error('Failed to start workflow:', e.message); } } ``` -------------------------------- ### Start and Save Workflow References (Python) Source: https://linkedapi.io/sdks/persisting-workflows Initiate a workflow and save its ID to a database for later retrieval using Python. This is the first step in persisting a workflow. ```python from linkedapi import CheckConnectionStatusParams, LinkedApiError # --- Step 1 & 2: Initiate a workflow and save its references --- def start_and_save_workflow(task_id): try: workflow = linkedapi.check_connection_status.execute( CheckConnectionStatusParams(person_url="https://www.linkedin.com/in/john-doe") ) # Save the workflow ID to your database db.save_task(task_id=task_id, workflow_id=workflow.workflow_id) print(f"Workflow {workflow.workflow_id} started and saved for task {task_id}.") except LinkedApiError as e: print("Failed to start workflow:", e.message) ``` -------------------------------- ### Start and Cancel Workflow in Python Source: https://linkedapi.io/sdks/persisting-workflows Initiates a workflow and then cancels it using its workflow ID. Call `cancel()` on the same method used to start the workflow. Actions already completed cannot be undone, and no intermediate data is preserved upon cancellation. ```python from linkedapi import CheckConnectionStatusParams, LinkedApiError # --- Start a workflow and then cancel it --- def start_and_cancel_workflow(): try: # Step 1: Initiate the workflow workflow = linkedapi.check_connection_status.execute( CheckConnectionStatusParams(person_url="https://www.linkedin.com/in/john-doe") ) print(f"Workflow {workflow.workflow_id} started.") # Step 2: Cancel the workflow using its ID # You call cancel() on the same method you used to start the workflow cancelled = linkedapi.check_connection_status.cancel(workflow.workflow_id) if cancelled: print(f"Workflow {workflow.workflow_id} cancelled successfully.") except LinkedApiError as e: print("Failed to process workflow:", e.message) ``` -------------------------------- ### Send Message and Check Connection Status (Python) Source: https://linkedapi.io/sdks/predefined-vs-custom-workflows Shows how to use predefined Python SDK methods for sending messages and checking connection status. These methods offer strong typing and are the recommended starting point for integrations. ```python from linkedapi import CheckConnectionStatusParams, SendMessageParams # Predefined method to send a message send_message_workflow = linkedapi.send_message.execute( SendMessageParams( person_url="https://www.linkedin.com/in/john-doe", text="Hello! I saw your post about AI and wanted to connect.", ) ) send_message_result = linkedapi.send_message.result(send_message_workflow.workflow_id) # Predefined method to check connection status connection_status_workflow = linkedapi.check_connection_status.execute( CheckConnectionStatusParams(person_url="https://www.linkedin.com/in/john-doe") ) connection_status_result = linkedapi.check_connection_status.result( connection_status_workflow.workflow_id ) ``` -------------------------------- ### Execute Workflow and Get Tracking Details Source: https://linkedapi.io/sdks/handling-results Initiates a workflow and returns tracking details including workflow ID and status. Use this to monitor workflow progress. ```python from linkedapi import CheckConnectionStatusParams workflow = linkedapi.check_connection_status.execute( CheckConnectionStatusParams(person_url="https://www.linkedin.com/in/john-doe") ) result = linkedapi.check_connection_status.result(workflow.workflow_id) ``` -------------------------------- ### Get usage Source: https://linkedapi.io/sdks/admin-limits Checks current usage against configured limits for a specific account. ```APIDOC ## Get usage ### Description Checks current usage against configured limits for a specific account. ### Method GET (implied by SDK usage) ### Endpoint /limits/usage (implied by SDK usage) ### Parameters #### Query Parameters - **accountId** (string) - Required - account UUID. ### Response #### Success Response (200) - **usage** (array) - An array of usage objects. - **category** (string) - limit category. - **period** (string) - `daily`, `weekly`, or `monthly`. - **maxValue** (integer) - maximum allowed actions. - **currentValue** (integer) - actions performed in the current period. - **isEnabled** (boolean) - whether this limit is enforced. ### Request Example ```typescript const { usage } = await admin.limits.getUsage({ accountId: 'f9b4346a-...' }); for (const entry of usage) { const remaining = entry.maxValue - entry.currentValue; console.log(`${entry.category} (${entry.period}): ${entry.currentValue}/${entry.maxValue} (${remaining} remaining)`); } ``` ```python from linkedapi import GetLimitsUsageParams usage = admin.limits.get_usage(GetLimitsUsageParams(account_id="f9b4346a-...")).usage for entry in usage: remaining = entry.max_value - entry.current_usage print(f"{entry.category} ({entry.period}): {entry.current_usage}/{entry.max_value} ({remaining} remaining)") ``` ### Response Example ```json { "usage": [ { "category": "stMessages", "period": "daily", "maxValue": 100, "currentValue": 50, "isEnabled": true } ] } ``` ``` -------------------------------- ### Get Subscription Pricing (Python) Source: https://linkedapi.io/sdks/admin-subscription Retrieves available product pricing details using Python. Iterates through the products to display seat type, billing period, and unit price. ```python products = admin.subscription.get_pricing().products for product in products: print(f"{product.seat_type} {product.billing_period}: ${product.unit_price / 100}/seat") ``` -------------------------------- ### Get Pricing Source: https://linkedapi.io/sdks/admin-subscription Retrieves the available pricing plans, including details about seat types, billing periods, and unit prices. ```APIDOC ## Get pricing ### Description Retrieves the available pricing plans. ### Data Array of product objects: * `id` – Stripe price identifier. * `seatType` – `core` or `plus`. * `billingPeriod` – `month` or `year`. * `unitPrice` – price per seat in cents (USD). E.g., `6900` = $69.00. ``` -------------------------------- ### Get Subscription Pricing Source: https://linkedapi.io/sdks/admin-subscription Retrieves available product pricing details. Iterates through the products to display seat type, billing period, and unit price. ```typescript const { products } = await admin.subscription.getPricing(); for (const product of products) { console.log(`${product.seatType} ${product.billingPeriod}: $${product.unitPrice / 100}/seat`); } ``` -------------------------------- ### Execute Workflow and Get Tracking Details Source: https://linkedapi.io/sdks/handling-results Initiates a workflow and returns tracking details including workflow ID and status. Use this to monitor workflow progress. ```typescript const workflow = await linkedapi.checkConnectionStatus.execute({ personUrl: "https://www.linkedin.com/in/john-doe" }); const result = await linkedapi.checkConnectionStatus.result(workflow.workflowId); ``` -------------------------------- ### Get Default Limits (Python) Source: https://linkedapi.io/sdks/admin-limits Retrieves the system default rate limits. These are applied when an account has no custom limits or after resetting. Handles potential API and unexpected errors. ```python from linkedapi import LinkedApiError try: limits = admin.limits.get_defaults().limits for limit in limits: print(f"{limit.category} ({limit.period}): max {limit.max_value}, enabled: {limit.is_enabled}") except LinkedApiError as e: print(f"Critical Error - Type: {e.type}, Message: {e.message}") except Exception as error: print("An unexpected, non-API error occurred:", error) ``` -------------------------------- ### Search Companies with Filters (Python) Source: https://linkedapi.io/sdks/nv-search-companies This Python snippet demonstrates how to search for companies using various criteria and handle both execution and critical errors. Ensure you have the LinkedAPI library installed. ```python from linkedapi import NvSearchCompaniesParams, LinkedApiError try: workflow = linkedapi.nv_search_companies.execute( NvSearchCompaniesParams( term="TechCorp", limit=10, filter={ "sizes": ["51-200", "201-500"], "locations": ["San Francisco", "New York"], "industries": ["Software Development", "Technology"], "annual_revenue": {"min": "10", "max": "100"}, }, custom_search_url="https://www.linkedin.com/sales/search/company?query=(spellCorrectionEnabled%3Atrue%2Ckeywords%3ALinked%2520API)", ) ) result = linkedapi.nv_search_companies.result(workflow.workflow_id) data = result.data errors = result.errors # The list of possible execution errors is below if errors: print("Workflow completed with execution errors:") for error in errors: print(f" - Type: {error.type}, Message: {error.message}") if data: print("Search completed successfully.") print("Found companies:", data) except LinkedApiError as e: # A list of all critical errors can be found here: # https://linkedapi.io/sdks/handling-results-and-errors/#handling-critical-errors print(f"Critical Error - Type: {e.type}, Message: {e.message}") except Exception as error: print("An unexpected, non-API error occurred:", error) ``` -------------------------------- ### Execute Custom Workflow and Get Raw Result (Python) Source: https://linkedapi.io/sdks/handling-results Use this when you need the full execution context of a custom workflow. The `result()` method returns the raw completion object that you must parse according to the specification. ```python workflow = linkedapi.custom_workflow.execute( { "actionType": "st.openPersonPage", "personUrl": "https://www.linkedin.com/in/john-doe", "basicInfo": True, "then": { "actionType": "st.checkConnectionStatus", }, } ) workflow_completion = linkedapi.custom_workflow.result(workflow.workflow_id) ``` -------------------------------- ### Get API Usage Statistics (TypeScript) Source: https://linkedapi.io/sdks/get-api-usage Retrieve usage statistics for a specified period. Ensure the LinkedApiError class is imported for proper error handling. The difference between start and end dates must not exceed 30 days. ```typescript try { // Get usage stats for the last 7 days const endDate = new Date(); const startDate = new Date(endDate.getTime() - 7 * 24 * 60 * 60 * 1000); const { data } = await linkedapi.getApiUsage({ start: startDate.toISOString(), end: endDate.toISOString() }); if (data) { console.log('Usage statistics retrieved successfully'); console.log('Total actions executed:', statsResponse.length); // Analyze the statistics const successfulActions = statsResponse.result?.filter(action => action.success); const failedActions = statsResponse.result?.filter(action => !action.success); console.log('Successful actions:', successfulActions?.length); console.log('Failed actions:', failedActions?.length); } } catch (e) { // A list of all critical errors can be found here: // https://linkedapi.io/sdks/handling-results-and-errors/#handling-critical-errors if (e instanceof LinkedApiError) { console.error(`Critical Error - Type: ${e.type}, Message: ${e.message}`); } else { console.error('An unexpected, non-API error occurred:', e); } } ``` -------------------------------- ### Initialize Admin API SDK (Python) Source: https://linkedapi.io/sdks/installation Initialize the Admin API SDK with your Linked API token for Python. ```python from linkedapi import LinkedApiAdmin, AdminConfig admin = LinkedApiAdmin( AdminConfig(linked_api_token="your-linked-api-token") ) status = admin.subscription.get_status() accounts = admin.accounts.get_all().accounts ``` -------------------------------- ### Restore Workflow and Get Result Source: https://linkedapi.io/sdks/persisting-workflows Retrieve a saved workflow ID from the database and use it to get the workflow's result. This is the second part of persisting a workflow. ```typescript // --- Step 3 & 4: Restore the workflow and get the result --- async function restoreAndGetResult(taskId) { try { // Retrieve the saved workflow ID from your database const task = await db.getTask(taskId); if (!task || !task.workflowId) { console.log(`No pending workflow found for task ${taskId}.`); return; } // Get the result using the saved workflow ID // You call the same method you used to start the workflow const { data, errors } = await linkedapi.checkConnectionStatus.result(task.workflowId); if (data) { console.log(`Task ${taskId} complete. Result:`, data); await db.updateTaskStatus(taskId, 'complete'); } } catch (e) { console.error(`Failed to get result for task ${taskId}:`, e.message); await db.updateTaskStatus(taskId, 'failed'); } } ``` -------------------------------- ### Restore Workflow and Get Result (Python) Source: https://linkedapi.io/sdks/persisting-workflows Retrieve a saved workflow ID from the database and use it to get the workflow's result using Python. This is the second part of persisting a workflow. ```python # --- Step 3 & 4: Restore the workflow and get the result --- def restore_and_get_result(task_id): try: # Retrieve the saved workflow ID from your database task = db.get_task(task_id) if not task or not task.workflow_id: print(f"No pending workflow found for task {task_id}.") return # Get the result using the saved workflow ID # You call the same method you used to start the workflow result = linkedapi.check_connection_status.result(task.workflow_id) if result.data: print(f"Task {task_id} complete. Result:", result.data) db.update_task_status(task_id, "complete") except LinkedApiError as e: print(f"Failed to get result for task {task_id}:", e.message) db.update_task_status(task_id, "failed") ``` -------------------------------- ### Initialize SDK for Multiple LinkedIn Accounts (Python) Source: https://linkedapi.io/sdks/installation Initialize separate SDK instances for managing multiple LinkedIn accounts in Python. ```python from linkedapi import LinkedApi, LinkedApiConfig first_linkedin_account = LinkedApi( LinkedApiConfig( linked_api_token="your-linked-api-token", identification_token="your-first-identification-token", ) ) second_linkedin_account = LinkedApi( LinkedApiConfig( linked_api_token="your-linked-api-token", identification_token="your-second-identification-token", ) ) ``` -------------------------------- ### Initialize Linked API SDK (Python) Source: https://linkedapi.io/sdks/installation Initialize the SDK with your Linked API and identification tokens for Python. ```python from linkedapi import LinkedApi, LinkedApiConfig linkedapi = LinkedApi( LinkedApiConfig( linked_api_token="your-linked-api-token", identification_token="your-identification-token", ) ) ``` -------------------------------- ### Start and Cancel Workflow in TypeScript Source: https://linkedapi.io/sdks/persisting-workflows Initiates a workflow and then cancels it using its workflow ID. Call `cancel()` on the same method used to start the workflow. Actions already completed cannot be undone, and no intermediate data is preserved upon cancellation. ```typescript // --- Start a workflow and then cancel it --- async function startAndCancelWorkflow() { try { // Step 1: Initiate the workflow const { workflowId } = await linkedapi.checkConnectionStatus.execute({ personUrl: "https://www.linkedin.com/in/john-doe" }); console.log(`Workflow ${workflowId} started.`); // Step 2: Cancel the workflow using its ID // You call cancel() on the same method you used to start the workflow const result = await linkedapi.checkConnectionStatus.cancel(workflowId); if (result.cancelled) { console.log(`Workflow ${workflowId} cancelled successfully.`); } } catch (e) { console.error('Failed to process workflow:', e.message); } } ``` -------------------------------- ### Initialize LinkedApiAdmin in Python Source: https://linkedapi.io/sdks/admin-overview Initialize the Admin class with your linkedApiToken. No identificationToken is needed. ```python from linkedapi import LinkedApiAdmin, AdminConfig admin = LinkedApiAdmin( AdminConfig(linked_api_token="your-linked-api-token") ) ``` -------------------------------- ### Get account limits Source: https://linkedapi.io/sdks/admin-limits Retrieves the current limits configured for a specific account. ```APIDOC ## Get account limits ### Description Retrieves the current limits configured for a specific account. ### Method GET (implied by SDK usage) ### Endpoint /limits (implied by SDK usage) ### Parameters #### Query Parameters - **accountId** (string) - Required - account UUID. ### Response #### Success Response (200) - **limits** (array) - An array of limit objects. - **category** (string) - limit category. - **period** (string) - `daily`, `weekly`, or `monthly`. - **maxValue** (integer) - maximum allowed actions. - **isEnabled** (boolean) - whether this limit is enforced. ### Request Example ```typescript const { limits } = await admin.limits.get({ accountId: 'f9b4346a-...' }); ``` ```python from linkedapi import GetLimitsParams limits = admin.limits.get(GetLimitsParams(account_id="f9b4346a-...")).limits ``` ### Response Example ```json { "limits": [ { "category": "stMessages", "period": "daily", "maxValue": 100, "isEnabled": true } ] } ``` ``` -------------------------------- ### Get Subscription Seats Source: https://linkedapi.io/sdks/admin-subscription Retrieves information about the number and type of seats associated with your Linked API subscription. ```APIDOC ## Get Subscription Seats ### Description Retrieves information about the number and type of seats associated with your Linked API subscription. ### Method `admin.subscription.getSeats()` (TypeScript) `admin.subscription.get_seats()` (Python) ### Parameters None ### Response #### Success Response An object containing an array of seat objects: - `seats` (array) - An array of seat objects, where each object has: - `seatType` (string) - The type of seat: 'core' or 'plus'. - `quantity` (number) - The number of seats. - `billingPeriod` (string) - The billing period for the seats: 'month' or 'year'. ### Response Example ```json { "seats": [ { "seatType": "core", "quantity": 5, "billingPeriod": "month" }, { "seatType": "plus", "quantity": 2, "billingPeriod": "year" } ] } ``` ``` -------------------------------- ### Connect a new account Source: https://linkedapi.io/sdks/admin-accounts This process involves creating a connection session, polling for its completion, and then retrieving the new account details. ```APIDOC ## Connect a new account ### Description Initiates the process of connecting a new LinkedIn account. This is a multi-step process that involves creating a session, waiting for user interaction via a provided link, and then confirming the connection. ### Methods 1. **`createConnectionSession()`** - **Description**: Creates a new session for connecting a LinkedIn account. - **Returns**: An object containing `sessionId` (string) and `connectionLink` (string). - **Errors**: - `noAvailableSeats`: No available seats for new connections. - `dailyConnectionAttemptsExceeded`: Exceeded daily connection attempt limit. 2. **`getConnectionSession({ sessionId })`** - **Description**: Polls the status of an existing connection session. - **Parameters**: - `sessionId` (string) - Required - The UUID of the session to check. - **Returns**: An object containing session status information. - **Session Statuses**: `pending`, `preparing`, `serving`, `streaming`, `success`, `expired`, `error`, `cancelled`. 3. **`getAll()`** - **Description**: Retrieves a list of all connected accounts. - **Returns**: An object containing an `accounts` array. ``` -------------------------------- ### Get Account Limits Source: https://linkedapi.io/sdks/admin-limits Retrieve the current limit configuration for a specific account. Requires the account ID. ```typescript const { limits } = await admin.limits.get({ accountId: 'f9b4346a-...' }); ``` ```python from linkedapi import GetLimitsParams limits = admin.limits.get(GetLimitsParams(account_id="f9b4346a-...")).limits ``` -------------------------------- ### Initialize Admin API SDK (TypeScript) Source: https://linkedapi.io/sdks/installation Initialize the Admin API SDK with your Linked API token for TypeScript. ```typescript import { LinkedApiAdmin } from '@linkedapi/node'; const admin = new LinkedApiAdmin({ linkedApiToken: 'your-linked-api-token', }); const status = await admin.subscription.getStatus(); const { accounts } = await admin.accounts.getAll(); ``` -------------------------------- ### Initialize Linked API SDK (TypeScript) Source: https://linkedapi.io/sdks/installation Initialize the SDK with your Linked API and identification tokens for TypeScript. ```typescript const linkedApi = new LinkedApi({ linkedApiToken: "your-linked-api-token", identificationToken: "your-identifiaction-token", }); ``` -------------------------------- ### Get Subscription Seats Source: https://linkedapi.io/sdks/admin-subscription Retrieve information about the number and type of seats associated with your subscription. Iterates through seat details. ```typescript const { seats } = await admin.subscription.getSeats(); for (const seat of seats) { console.log(`${seat.seatType} × ${seat.quantity} (${seat.billingPeriod})`); } ``` ```python seats = admin.subscription.get_seats().seats for seat in seats: print(f"{seat.seat_type} × {seat.quantity} ({seat.billing_period})") ``` -------------------------------- ### Get Billing Link Source: https://linkedapi.io/sdks/admin-subscription Retrieves a URL to the Stripe billing portal, allowing users to manage their payment methods and invoices. ```APIDOC ## Get billing link ### Description Retrieves a URL to the Stripe billing portal for managing payments and invoices. ### Method Not specified (SDK method) ### Endpoint Not specified (SDK method) ### Data * `stripeLink` (string) - URL to the Stripe billing portal. ### Request Example ```typescript const { stripeLink } = await admin.subscription.getBillingLink(); ``` ```python stripe_link = admin.subscription.get_billing_link().stripe_link ``` ``` -------------------------------- ### Initialize SDK for Multiple LinkedIn Accounts (TypeScript) Source: https://linkedapi.io/sdks/installation Initialize separate SDK instances for managing multiple LinkedIn accounts in TypeScript. ```typescript const firstLinkedInAccount = new LinkedApi({ linkedApiToken: "your-linked-api-token", identificationToken: "your-first-identifiaction-token", }); const secondLinkedInAccount = new LinkedApi({ linkedApiToken: "your-linked-api-token", identificationToken: "your-second-identifiaction-token", }) ``` -------------------------------- ### Get Subscription Status Source: https://linkedapi.io/sdks/admin-subscription Retrieve the current status of your Linked API subscription. Handles potential API and unexpected errors. ```typescript try { const status = await admin.subscription.getStatus(); console.log(status.status); console.log(status.eligibleForTrial); console.log(status.cancelAtPeriodEnd); } catch (e) { if (e instanceof LinkedApiError) { console.error(`Critical Error - Type: ${e.type}, Message: ${e.message}`); } else { console.error('An unexpected, non-API error occurred:', e); } } ``` ```python from linkedapi import LinkedApiError try: status = admin.subscription.get_status() print(status.status) print(status.eligible_for_trial) print(status.cancel_at_period_end) except LinkedApiError as e: print(f"Critical Error - Type: {e.type}, Message: {e.message}") except Exception as error: print("An unexpected, non-API error occurred:", error) ``` -------------------------------- ### Reset All Account Limits to Defaults (Python) Source: https://linkedapi.io/sdks/admin-limits Resets all limits for a given account back to the system's default configurations using Python. Requires only the account ID. ```python from linkedapi import ResetLimitsParams admin.limits.reset_to_defaults(ResetLimitsParams(account_id="f9b4346a-...")) ``` -------------------------------- ### Fetch Person Information (Python) Source: https://linkedapi.io/sdks/nv-fetch-person This Python snippet demonstrates how to fetch a person's profile data from Sales Navigator. It includes error handling for both execution issues and critical API errors. ```python from linkedapi import NvOpenPersonPageParams, LinkedApiError try: workflow = linkedapi.nv_fetch_person.execute( NvOpenPersonPageParams(person_hashed_url="https://www.linkedin.com/in/SInQBmjJ015eLr8") ) result = linkedapi.nv_fetch_person.result(workflow.workflow_id) data = result.data errors = result.errors # The list of possible execution errors is below if errors: print("Workflow completed with execution errors:") for error in errors: print(f" - Type: {error.type}, Message: {error.message}") # The structure of the 'data' object is below if data: print("Person name:", data.name) print("Headline:", data.headline) print("Location:", data.location) print("Position:", data.position) print("Company:", data.company_name) print("Workflow completed successfully. Data:", data) except LinkedApiError as e: # A list of all critical errors can be found here: # https://linkedapi.io/sdks/handling-results-and-errors/#handling-critical-errors print(f"Critical Error - Type: {e.type}, Message: {e.message}") except Exception as error: print("An unexpected, non-API error occurred:", error) ``` -------------------------------- ### Get Subscription Status Source: https://linkedapi.io/sdks/admin-subscription Retrieves the current status of your Linked API subscription, including eligibility for a free trial and whether cancellation is scheduled. ```APIDOC ## Get Subscription Status ### Description Retrieves the current status of your Linked API subscription, including eligibility for a free trial and whether cancellation is scheduled. ### Method `admin.subscription.getStatus()` (TypeScript) `admin.subscription.get_status()` (Python) ### Parameters None ### Response #### Success Response An object containing subscription details: - `status` (string) - The subscription status: 'active', 'trialing', 'past_due', 'canceled', or undefined if no subscription. - `eligibleForTrial` (boolean) - Indicates if a 7-day free trial is available. - `cancelAtPeriodEnd` (boolean) - Indicates if the subscription is scheduled to cancel at the end of the current billing period. ### Response Example ```json { "status": "active", "eligibleForTrial": false, "cancelAtPeriodEnd": false } ``` ``` -------------------------------- ### Retrieve Connections with Filters (Python) Source: https://linkedapi.io/sdks/retrieve-connections This Python snippet shows how to fetch connections using filters for first name, position, and locations. It includes handling for execution and critical errors. ```python from linkedapi import RetrieveConnectionsParams, LinkedApiError try: workflow = linkedapi.retrieve_connections.execute( RetrieveConnectionsParams( filter={ "first_name": "John", "position": "Engineer", "locations": ["San Francisco", "New York"], }, limit=100, ) ) result = linkedapi.retrieve_connections.result(workflow.workflow_id) data = result.data errors = result.errors # The list of possible execution errors is below if errors: print("Workflow completed with execution errors:") for error in errors: print(f" - Type: {error.type}, Message: {error.message}") # The structure of the 'data' object is below if data: print("Retrieved connections:", len(data)) for connection in data: print(f"{connection.name} - {connection.headline}") print(f"Location: {connection.location}") print(f"Profile: {connection.public_url}") except LinkedApiError as e: # A list of all critical errors can be found here: # https://linkedapi.io/sdks/handling-results-and-errors/#handling-critical-errors print(f"Critical Error - Type: {e.type}, Message: {e.message}") except Exception as error: print("An unexpected, non-API error occurred:", error) ``` -------------------------------- ### Get All Accounts - Python Source: https://linkedapi.io/sdks/admin-accounts Retrieves all connected LinkedIn accounts and pending connection sessions. Handles potential API errors and unexpected exceptions. ```python from linkedapi import LinkedApiError try: result = admin.accounts.get_all() accounts = result.accounts pending_connection_sessions = result.pending_connection_sessions for account in accounts: print(f"{account.name} ({account.status}) – {account.id}") for session in pending_connection_sessions: print(f"Pending session: {session.session_id} ({session.status})") except LinkedApiError as e: print(f"Critical Error - Type: {e.type}, Message: {e.message}") except Exception as error: print("An unexpected, non-API error occurred:", error) ``` -------------------------------- ### Get All Accounts - TypeScript Source: https://linkedapi.io/sdks/admin-accounts Retrieves all connected LinkedIn accounts and pending connection sessions. Handles potential API errors and unexpected exceptions. ```typescript try { const { accounts, pendingConnectionSessions } = await admin.accounts.getAll(); for (const account of accounts) { console.log(`${account.name} (${account.status}) – ${account.id}`); } for (const session of pendingConnectionSessions) { console.log(`Pending session: ${session.sessionId} (${session.status})`); } } catch (e) { if (e instanceof LinkedApiError) { console.error(`Critical Error - Type: ${e.type}, Message: ${e.message}`); } else { console.error('An unexpected, non-API error occurred:', e); } } ``` -------------------------------- ### Check Connection Status in Python Source: https://linkedapi.io/sdks/check-connection-status This Python snippet demonstrates how to check a connection status and handle potential execution and critical errors. Ensure you import necessary classes. ```python from linkedapi import CheckConnectionStatusParams, LinkedApiError try: workflow = linkedapi.check_connection_status.execute( CheckConnectionStatusParams(person_url="https://www.linkedin.com/in/john-doe") ) result = linkedapi.check_connection_status.result(workflow.workflow_id) data = result.data errors = result.errors # The list of possible execution errors is below if errors: print("Workflow completed with execution errors:") for error in errors: print(f" - Type: {error.type}, Message: {error.message}") # The structure of the 'data' object is below if data: print("Connection status:", data.connection_status) print("Workflow completed successfully. Data:", data) except LinkedApiError as e: # A list of all critical errors can be found here: # https://linkedapi.io/sdks/handling-results-and-errors/#handling-critical-errors print(f"Critical Error - Type: {e.type}, Message: {e.message}") except Exception as error: print("An unexpected, non-API error occurred:", error) ``` -------------------------------- ### Sync Sales Navigator Conversation (Python) Source: https://linkedapi.io/sdks/nv-sync-conversation This Python snippet demonstrates how to sync a Sales Navigator conversation. It includes error handling for execution and critical API errors. ```python from linkedapi import NvSyncConversationParams, LinkedApiError try: workflow = linkedapi.nv_sync_conversation.execute( NvSyncConversationParams(person_url="https://www.linkedin.com/in/john-doe") ) result = linkedapi.nv_sync_conversation.result(workflow.workflow_id) errors = result.errors # The list of possible execution errors is below if errors: print("Workflow completed with execution errors:") for error in errors: print(f" - Type: {error.type}, Message: {error.message}") else: print("Sales Navigator conversation synced successfully.") except LinkedApiError as e: # A list of all critical errors can be found here: # https://linkedapi.io/sdks/handling-results-and-errors/#handling-critical-errors print(f"Critical Error - Type: {e.type}, Message: {e.message}") except Exception as error: print("An unexpected, non-API error occurred:", error) ``` -------------------------------- ### Get Billing Link Source: https://linkedapi.io/sdks/admin-subscription Obtain a URL to redirect users to the Stripe billing portal for managing payment methods and invoices. Available in TypeScript and Python. ```typescript const { stripeLink } = await admin.subscription.getBillingLink(); // Redirect user to manage payment methods and invoices ``` ```python stripe_link = admin.subscription.get_billing_link().stripe_link # Redirect user to manage payment methods and invoices ``` -------------------------------- ### nvSyncConversation.execute Source: https://linkedapi.io/sdks/nv-sync-conversation Initiates the syncing process for a Sales Navigator conversation. It requires the person's LinkedIn URL as a parameter. ```APIDOC ## nvSyncConversation.execute ### Description Initiates the syncing of a Sales Navigator conversation. This action prepares the conversation for subsequent polling. ### Method POST (inferred from SDK usage pattern) ### Endpoint /nvSyncConversation ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **personUrl** (string) - Required - Public or hashed LinkedIn URL of the person whose conversation you want to sync. ### Request Example ```json { "personUrl": "https://www.linkedin.com/in/john-doe" } ``` ### Response #### Success Response (200) - **workflowId** (string) - The ID of the initiated workflow. #### Response Example ```json { "workflowId": "some-workflow-id" } ``` ### Errors - `noSalesNavigator`: Your account does not have a Sales Navigator subscription. - `personNotFound`: The provided URL is not an existing LinkedIn person. ``` -------------------------------- ### Get Account Usage Source: https://linkedapi.io/sdks/admin-limits Check the current usage against configured limits for an account. This is useful for monitoring and displaying remaining capacity. Requires the account ID. ```typescript const { usage } = await admin.limits.getUsage({ accountId: 'f9b4346a-...' }); for (const entry of usage) { const remaining = entry.maxValue - entry.currentValue; console.log(`${entry.category} (${entry.period}): ${entry.currentValue}/${entry.maxValue} (${remaining} remaining)`); } ``` ```python from linkedapi import GetLimitsUsageParams usage = admin.limits.get_usage(GetLimitsUsageParams(account_id="f9b4346a-...")).usage for entry in usage: remaining = entry.max_value - entry.current_usage print(f"{entry.category} ({entry.period}): {entry.current_usage}/{entry.max_value} ({remaining} remaining)") ``` -------------------------------- ### Fetch Company Data in Python Source: https://linkedapi.io/sdks/fetch-company This Python snippet demonstrates how to fetch company data using the LinkedAPI SDK. It includes configurations for retrieving employees, posts, and decision makers, along with robust error handling for execution and critical errors. ```python from linkedapi import FetchCompanyParams, LinkedApiError try: workflow = linkedapi.fetch_company.execute( FetchCompanyParams( company_url="https://www.linkedin.com/company/microsoft", retrieve_employees=True, retrieve_posts=True, retrieve_dms=True, employees_retrieval_config={ "limit": 25, "filter": { "first_name": "John", "last_name": "Smith", "position": "engineer", "locations": ["United States", "Canada"], "industries": ["Software Development"], "schools": ["Stanford University", "MIT"], }, }, posts_retrieval_config={"limit": 10, "since": "2024-01-01T00:00:00Z"}, dms_retrieval_config={"limit": 5}, ) ) result = linkedapi.fetch_company.result(workflow.workflow_id) data = result.data errors = result.errors # The list of possible execution errors is below if errors: print("Workflow completed with execution errors:") for error in errors: print(f" - Type: {error.type}, Message: {error.message}") # The structure of the 'data' object is below if data: print("Company name:", data.name) print("Description:", data.description) print("Location:", data.location) print("Industry:", data.industry) print("Employees count:", data.employees_count) print("Employees:", data.employees) print("Posts:", data.posts) print("Decision makers:", data.dms) print("Workflow completed successfully. Data:", data) except LinkedApiError as e: # A list of all critical errors can be found here: # https://linkedapi.io/sdks/handling-results-and-errors/#handling-critical-errors print(f"Critical Error - Type: {e.type}, Message: {e.message}") except Exception as error: print("An unexpected, non-API error occurred:", error) ```