> ## Documentation Index
> Fetch the complete documentation index at: https://www.outx.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# LinkedIn API Quick Start - Fetch Your First Profile in 2 Minutes

> Get started with the OutX LinkedIn API. Fetch your first LinkedIn profile, poll for results, and retrieve full profile data in under 2 minutes.

This guide walks you through making your first LinkedIn API request end-to-end: from getting your API key to retrieving full profile data.

## Prerequisites

Before you begin, make sure you have:

1. An OutX account ([sign up at outx.ai](https://www.outx.ai))
2. The OutX Chrome extension installed and active
3. Your API key from [mentions.outx.ai/api-doc](https://mentions.outx.ai/api-doc)

<Warning>
  The OutX Chrome extension must be installed and active on at least one team member's browser within the last 48 hours. Without this, API calls will return a `403` error. See [Authentication](/docs/api-reference/authentication) for details.
</Warning>

## End-to-End Walkthrough

<Steps>
  <Step title="Get Your API Key">
    1. Log in to your OutX account
    2. Go to [mentions.outx.ai/api-doc](https://mentions.outx.ai/api-doc)
    3. Click **"Reveal API Key"**
    4. Copy your API key

    Store it in an environment variable for easy use:

    ```bash theme={null}
    export OUTX_API_KEY="your-api-key-here"
    ```
  </Step>

  <Step title="Install the Chrome Extension">
    Install the [OutX Chrome extension](https://chromewebstore.google.com/detail/outxai-track-linkedin-pos/epnimaeheelhgeelbppbfkjegklflakj) and log in with your OutX account. The extension will automatically maintain a browser session that the API uses to execute tasks.

    <Tip>
      The extension runs in the background. Just keep Chrome open and it will stay active.
    </Tip>
  </Step>

  <Step title="Fetch a LinkedIn Profile">
    Send a `POST` request to create a profile fetch task. You will receive an `api_agent_task_id` that you use to check for results.

    <CodeGroup>
      ```bash cURL theme={null}
      curl -X POST \
        "https://api.outx.ai/linkedin-agent/fetch-profile" \
        -H "Content-Type: application/json" \
        -H "x-api-key: $OUTX_API_KEY" \
        -d '{"profile_slug": "williamhgates"}'
      ```

      ```javascript JavaScript theme={null}
      const response = await fetch(
        "https://api.outx.ai/linkedin-agent/fetch-profile",
        {
          method: "POST",
          headers: {
            "Content-Type": "application/json",
            "x-api-key": process.env.OUTX_API_KEY,
          },
          body: JSON.stringify({ profile_slug: "williamhgates" }),
        }
      );

      const data = await response.json();
      console.log(data);
      // { success: true, api_agent_task_id: "abc-123-def-456", message: "Profile fetch task created successfully" }
      ```

      ```python Python theme={null}
      import requests
      import os

      url = "https://api.outx.ai/linkedin-agent/fetch-profile"
      headers = {
          "Content-Type": "application/json",
          "x-api-key": os.environ["OUTX_API_KEY"],
      }
      payload = {"profile_slug": "williamhgates"}

      response = requests.post(url, headers=headers, json=payload)
      data = response.json()
      print(data)
      # {"success": True, "api_agent_task_id": "abc-123-def-456", "message": "Profile fetch task created successfully"}
      ```
    </CodeGroup>

    **Response:**

    ```json theme={null}
    {
      "success": true,
      "api_agent_task_id": "abc-123-def-456",
      "message": "Profile fetch task created successfully"
    }
    ```
  </Step>

  <Step title="Poll for Results">
    The task is now queued. Poll the task status endpoint until the status changes from `pending` to `completed`.

    <CodeGroup>
      ```bash cURL theme={null}
      curl -X GET \
        "https://api.outx.ai/linkedin-agent/get-task-status?api_agent_task_id=abc-123-def-456" \
        -H "x-api-key: $OUTX_API_KEY"
      ```

      ```javascript JavaScript theme={null}
      async function pollForResult(taskId) {
        const maxAttempts = 30;
        const delayMs = 5000;

        for (let i = 0; i < maxAttempts; i++) {
          const response = await fetch(
            `https://api.outx.ai/linkedin-agent/get-task-status?api_agent_task_id=${taskId}`,
            {
              headers: { "x-api-key": process.env.OUTX_API_KEY },
            }
          );

          const result = await response.json();

          if (result.data.status === "completed") {
            return result.data.task_output;
          }

          console.log(`Status: ${result.data.status} - waiting ${delayMs / 1000}s...`);
          await new Promise((resolve) => setTimeout(resolve, delayMs));
        }

        throw new Error("Task did not complete within the expected time");
      }

      const profileData = await pollForResult("abc-123-def-456");
      console.log(profileData);
      ```

      ```python Python theme={null}
      import requests
      import time
      import os

      def poll_for_result(task_id, max_attempts=30, delay=5):
          url = "https://api.outx.ai/linkedin-agent/get-task-status"
          headers = {"x-api-key": os.environ["OUTX_API_KEY"]}

          for i in range(max_attempts):
              response = requests.get(
                  url,
                  headers=headers,
                  params={"api_agent_task_id": task_id},
              )
              result = response.json()

              if result["data"]["status"] == "completed":
                  return result["data"]["task_output"]

              print(f"Status: {result['data']['status']} - waiting {delay}s...")
              time.sleep(delay)

          raise TimeoutError("Task did not complete within the expected time")

      profile_data = poll_for_result("abc-123-def-456")
      print(profile_data)
      ```
    </CodeGroup>

    **Pending response:**

    ```json theme={null}
    {
      "success": true,
      "data": {
        "id": "abc-123-def-456",
        "status": "pending",
        "task_input": {
          "task_type": "agent_profile_fetch",
          "profile_slug": "williamhgates"
        },
        "task_output": null
      }
    }
    ```
  </Step>

  <Step title="Get Profile Data">
    Once the task completes, the response includes the full profile data in `task_output`:

    ```json theme={null}
    {
      "success": true,
      "data": {
        "id": "abc-123-def-456",
        "status": "completed",
        "task_input": {
          "task_type": "agent_profile_fetch",
          "profile_slug": "williamhgates"
        },
        "task_output": {
          "name": "Bill Gates",
          "headline": "Co-chair, Bill & Melinda Gates Foundation",
          "location": "Seattle, Washington, United States",
          "profile_url": "https://www.linkedin.com/in/williamhgates",
          "connections": 500,
          "followers": 35000000,
          "about": "Co-chair of the Bill & Melinda Gates Foundation...",
          "experience": [...],
          "education": [...],
          "skills": [...]
        }
      }
    }
    ```

    You now have full LinkedIn profile data accessible via a simple API.
  </Step>
</Steps>

## Complete Working Example

Here is a single, copy-paste-ready script that performs the entire flow:

<CodeGroup>
  ```bash cURL theme={null}
  # Step 1: Create the task
  TASK_ID=$(curl -s -X POST \
    "https://api.outx.ai/linkedin-agent/fetch-profile" \
    -H "Content-Type: application/json" \
    -H "x-api-key: $OUTX_API_KEY" \
    -d '{"profile_slug": "williamhgates"}' | jq -r '.api_agent_task_id')

  echo "Task created: $TASK_ID"

  # Step 2: Poll until complete
  while true; do
    RESULT=$(curl -s -X GET \
      "https://api.outx.ai/linkedin-agent/get-task-status?api_agent_task_id=$TASK_ID" \
      -H "x-api-key: $OUTX_API_KEY")

    STATUS=$(echo $RESULT | jq -r '.data.status')
    echo "Status: $STATUS"

    if [ "$STATUS" = "completed" ]; then
      echo $RESULT | jq '.data.task_output'
      break
    fi

    sleep 5
  done
  ```

  ```javascript JavaScript theme={null}
  const API_KEY = process.env.OUTX_API_KEY;
  const BASE_URL = "https://api.outx.ai";

  async function fetchLinkedInProfile(profileSlug) {
    // Step 1: Create the task
    const createResponse = await fetch(
      `${BASE_URL}/linkedin-agent/fetch-profile`,
      {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          "x-api-key": API_KEY,
        },
        body: JSON.stringify({ profile_slug: profileSlug }),
      }
    );

    const { api_agent_task_id } = await createResponse.json();
    console.log(`Task created: ${api_agent_task_id}`);

    // Step 2: Poll until complete
    for (let i = 0; i < 30; i++) {
      const statusResponse = await fetch(
        `${BASE_URL}/linkedin-agent/get-task-status?api_agent_task_id=${api_agent_task_id}`,
        { headers: { "x-api-key": API_KEY } }
      );

      const result = await statusResponse.json();
      console.log(`Status: ${result.data.status}`);

      if (result.data.status === "completed") {
        return result.data.task_output;
      }

      await new Promise((r) => setTimeout(r, 5000));
    }

    throw new Error("Timed out waiting for task");
  }

  const profile = await fetchLinkedInProfile("williamhgates");
  console.log(JSON.stringify(profile, null, 2));
  ```

  ```python Python theme={null}
  import requests
  import time
  import os
  import json

  API_KEY = os.environ["OUTX_API_KEY"]
  BASE_URL = "https://api.outx.ai"

  def fetch_linkedin_profile(profile_slug):
      # Step 1: Create the task
      response = requests.post(
          f"{BASE_URL}/linkedin-agent/fetch-profile",
          headers={
              "Content-Type": "application/json",
              "x-api-key": API_KEY,
          },
          json={"profile_slug": profile_slug},
      )
      task_id = response.json()["api_agent_task_id"]
      print(f"Task created: {task_id}")

      # Step 2: Poll until complete
      for _ in range(30):
          result = requests.get(
              f"{BASE_URL}/linkedin-agent/get-task-status",
              headers={"x-api-key": API_KEY},
              params={"api_agent_task_id": task_id},
          ).json()

          status = result["data"]["status"]
          print(f"Status: {status}")

          if status == "completed":
              return result["data"]["task_output"]

          time.sleep(5)

      raise TimeoutError("Task did not complete in time")

  profile = fetch_linkedin_profile("williamhgates")
  print(json.dumps(profile, indent=2))
  ```
</CodeGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Fetch Profile" icon="user" href="/docs/linkedin-api/fetch-profile">
    Full endpoint reference for profile fetching
  </Card>

  <Card title="Fetch Posts" icon="newspaper" href="/docs/linkedin-api/fetch-profiles-posts">
    Retrieve posts from LinkedIn profiles
  </Card>

  <Card title="Like Post" icon="heart" href="/docs/linkedin-api/like-post">
    Automate liking LinkedIn posts
  </Card>

  <Card title="Comment on Post" icon="comment" href="/docs/linkedin-api/comment-post">
    Post comments programmatically
  </Card>
</CardGroup>

## AI Agent Prompt

Use the following instructions when building an AI agent that integrates with the OutX LinkedIn Data API.

### Prerequisites

* API key stored in `OUTX_API_KEY` environment variable
* OutX Chrome extension installed and active on at least one team member's browser

### Quick Reference

| Action            | Method | Endpoint                               | Key Params                                         |
| ----------------- | ------ | -------------------------------------- | -------------------------------------------------- |
| Fetch profile     | POST   | `/linkedin-agent/fetch-profile`        | `profile_slug` (required)                          |
| Fetch posts       | POST   | `/linkedin-agent/fetch-profiles-posts` | `profile_urns` (required, array)                   |
| Like post         | POST   | `/linkedin-agent/like-post`            | `social_urn` (required)                            |
| Comment on post   | POST   | `/linkedin-agent/comment-post`         | `social_urn` (required), `comment_text` (required) |
| Check task status | GET    | `/linkedin-agent/get-task-status`      | `api_agent_task_id` (required, query param)        |

### Async Pattern

All LinkedIn Data endpoints return `{api_agent_task_id}` immediately. You must poll `get-task-status` until `status` is `"completed"`, then read `task_output`.

### Guardrails, ALWAYS DO

1. Use `x-api-key` header for authentication
2. Use base URL `https://api.outx.ai`
3. Poll `get-task-status` every 5 seconds after submitting a task
4. Set a timeout (30 attempts / 2.5 minutes) to avoid polling indefinitely
5. Check `status` field: `"pending"` → `"processing"` → `"completed"` or `"failed"`
6. **Space API calls at least 10–30 seconds apart**, OutX is a proxy, not a rate limiter
7. **Distribute calls throughout the day**, don't batch everything in a short window

### Guardrails, NEVER DO

1. Never hardcode API keys in source code
2. Never assume responses are synchronous, always poll for results
3. Never send engagement actions without a valid `social_urn`
4. Never skip error handling for 403 (Chrome extension not active)
5. **Never burst API calls**, sending many requests in rapid succession risks LinkedIn flagging the account

<Info>
  For the full OutX API skill file, see [outx-skill.md](https://outx.ai/docs/outx-skill.md).
</Info>

## Frequently Asked Questions

<AccordionGroup>
  <Accordion title="How long does a profile fetch task take to complete?">
    Usually seconds to a few minutes, depending on when the Chrome extension picks up the task. The extension checks for new tasks on a regular schedule. Most tasks complete within 30 seconds under normal conditions.
  </Accordion>

  <Accordion title="How often should I poll for task status?">
    Every 5 seconds is recommended. Set a timeout of 2-3 minutes to avoid polling indefinitely. The example code on this page uses 30 attempts with a 5-second delay, which provides a 2.5-minute window for task completion.
  </Accordion>
</AccordionGroup>

***

## Learn More

* [LinkedIn API Guide](https://www.outx.ai/blog/linkedin-api-guide)
* [How to Scrape LinkedIn Data Safely](https://www.outx.ai/blog/scrape-data-linkedin)
* [LinkedIn Automation Safety Guide](https://www.outx.ai/blog/linkedin-automation-safety-guide-best-practices-2026)
