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

# Search LinkedIn

> Search for LinkedIn companies or people

export const PlansAvailable = ({plans = [], maxPackRequired}) => {
  let displayPlans = plans;
  if (plans && plans.length === 1) {
    const lowerCasePlan = plans[0].toLowerCase();
    if (lowerCasePlan === "basic") {
      displayPlans = ["Basic", "Premium", "Business", "Enterprise"];
    } else if (lowerCasePlan === "business") {
      displayPlans = ["Business", "Enterprise"];
    } else if (lowerCasePlan === "premium") {
      displayPlans = ["Premium", "Business", "Enterprise"];
    }
  }
  return <Note>
Available on {displayPlans.length === 1 ? "the " : ""}
{displayPlans.join(", ").replace(/\b\w/g, l => l.toUpperCase())}{" "}
{displayPlans.length > 1 ? "plans" : "plan"}.

{maxPackRequired && <span onClick={() => window.open('https://www.ayrshare.com/docs/additional/maxpack', '_self')} className="flex items-center mt-2 cursor-pointer">
 <span className="px-1.5 py-0.5 rounded text-sm" style={{
    backgroundColor: '#C264B6',
    color: 'white',
    fontSize: '12px'
  }}>
   Max Pack required
 </span>
</span>}
</Note>;
};

export const HeaderAPI = ({noProfileKey, profileKeyRequired}) => <>
    <ParamField header="Authorization" type="string" required>
      <a href="/apis/overview#authorization">API Key</a> of the Primary Profile.
      <br />
      <br />
      Format: <code>Authorization: Bearer API_KEY</code>
    </ParamField>
    {!noProfileKey && (profileKeyRequired ? <ParamField header="Profile-Key" type="string" required>
          <a href="/apis/overview#profile-key-format">Profile Key</a> of a User Profile.
          <br />
          <br />
          Format: <code>Profile-Key: PROFILE_KEY</code>
        </ParamField> : <ParamField header="Profile-Key" type="string">
          <a href="/apis/overview#profile-key-format">Profile Key</a> of a User Profile.
          <br />
          <br />
          Format: <code>Profile-Key: PROFILE_KEY</code>
        </ParamField>)}
  </>;

<PlansAvailable plans={["business"]} maxPackRequired={false} />

Search for LinkedIn companies or people based on a search query.
This endpoint is commonly used for typeahead mention completion in social media posts.

**The linked account must be a LinkedIn company page to search.** Personal LinkedIn accounts can not be used to perform searches.

1. **For mentions in posts**: When implementing @mentions, use this endpoint with typeahead functionality.
2. **Company search**: The exact company vanity name is required.
3. **Person search**: Start with at least 3 characters of a name for best results.
4. **Rate limiting**: This endpoint follows standard API rate limits.

<Note>
  **Search Limitations**

  <ul class="custom-bullets">
    <li>**Companies**: You can search for any LinkedIn company page</li>

    <li>
      **People**: You can only search for people who are followers of your LinkedIn account and the
      Ayrshare linked account must be a LinkedIn company page to perform the search. If a person has
      their LinkedIn visibility set to private, they will not be found in the search results.
    </li>
  </ul>
</Note>

## Header Parameters

<HeaderAPI />

## Query Parameters

<ParamField query="search" type="string" required>
  Search query to find LinkedIn companies or people.

  **Requirements:**

  {" "}

  <ul class="custom-bullets">
    <li>Minimum length: 3 characters for people and 1 character for companies.</li>
    <li>Maximum length: 100 characters for both people and companies.</li>
  </ul>

  **Search behavior:**

  <ul class="custom-bullets">
    <li>
      <strong>For companies</strong>: Use the company's vanity name (found in the LinkedIn URL). Only **exact vanity name matches** will be returned.

      <ul class="custom-bullets">
        <li>
          Example: For `linkedin.com/company/ayrshare`, search for "ayrshare".
        </li>

        <li>
          Searching for partial names like "ayrsh" will NOT return results.
        </li>
      </ul>
    </li>

    <li>
      <strong>For people</strong>: Use first name and/or last name. Partial name matches are supported.

      <ul class="custom-bullets">
        <li>
          Example: "John Smith" will find people named John Smith. Be sure to URL encode the space.
        </li>

        <li>
          Partial matches like "Joh" or "Smi" will also return results.
        </li>
      </ul>

      <ul class="custom-bullets">
        <li>
          Remember: Only your LinkedIn followers can be found and the Ayrshare linked account must be a LinkedIn company page to perform the search
        </li>
      </ul>
    </li>
  </ul>
</ParamField>

<ParamField query="personOnly" type="boolean" default={false}>
  Controls the search scope: - `false` (default): Searches for companies first, then people if no
  companies are found. - `true`: Searches only for people (skips company search entirely).
</ParamField>

## Examples

<RequestExample>
  ```bash Company Search theme={"system"}
  curl \
    -H "Authorization: Bearer API_KEY" \
    -X GET "https://api.ayrshare.com/api/brand/search/linkedin?search=ayrshare"
  ```

  ```bash Person Search Only theme={"system"}
  curl \
    -H "Authorization: Bearer API_KEY" \
    -X GET "https://api.ayrshare.com/api/brand/search/linkedin?search=John%20Smith&personOnly=true"
  ```

  ```javascript JavaScript theme={"system"}
  const API_KEY = "API_KEY";

  // Search for company or person
  fetch("https://api.ayrshare.com/api/brand/search/linkedin?search=ayrshare", {
    method: "GET",
    headers: {
      Authorization: `Bearer ${API_KEY}`
    }
  })
    .then((res) => res.json())
    .then((json) => console.log(json))
    .catch(console.error);

  // Search for person only
  fetch("https://api.ayrshare.com/api/brand/search/linkedin?search=John%20Smith&personOnly=true", {
    method: "GET",
    headers: {
      Authorization: `Bearer ${API_KEY}`
    }
  })
    .then((res) => res.json())
    .then((json) => console.log(json))
    .catch(console.error);
  ```

  ```python Python theme={"system"}
  import requests

  headers = {'Authorization': 'Bearer API_KEY'}

  # Search for company or person
  r = requests.get('https://api.ayrshare.com/api/brand/search/linkedin?search=ayrshare', headers=headers)
  print(r.json())

  # Search for person only
  r = requests.get('https://api.ayrshare.com/api/brand/search/linkedin?search=john&personOnly=true', headers=headers)
  print(r.json())
  ```
</RequestExample>

<ResponseExample>
  ```json Company Search Result theme={"system"}
  {
    "linkedin": [
      {
        "vanityName": "ayrshare",
        "website": "https://www.ayrshare.com",
        "groups": [],
        "description": "Ayrshare's APIs provide the core infrastructure for social media posting, management, and analytics.\n\nThe Ayrshare API takes care of the social media infrastructure so you don't have to. Your team can focus on building your product instead of stitching together and maintaining multiple social media platforms.\n\nPost to Facebook, Twitter, Instagram, LinkedIn, Reddit, Telegram, TikTok, Google My Business, and YouTube.\n",
        "defaultLocale": {
          "country": "US",
          "language": "en"
        },
        "organizationType": "PARTNERSHIP",
        "alternativeNames": [],
        "specialties": [
          "social media",
          "api",
          "saas",
          "social networks",
          "tiktok",
          "facebook",
          "instagram"
        ],
        "staffCountRange": "SIZE_10_TO_100",
        "name": "Ayrshare",
        "primaryOrganizationType": "NONE",
        "locations": [
          {
            "description": {
              "localized": {
                "en_US": "Headquarters"
              },
              "preferredLocale": {
                "country": "US",
                "language": "en"
              }
            },
            "locationType": "HEADQUARTERS",
            "address": {
              "geographicArea": "New York",
              "country": "US",
              "city": "New York",
              "line1": "142 W 57th St",
              "postalCode": "10019"
            },
            "localizedDescription": "Headquarters",
            "streetAddressFieldState": "UNSET_OPT_OUT",
            "geoLocation": "urn:li:geo:103963738"
          }
        ],
        "id": 66755333
      }
    ]
  }
  ```

  ```json Person Search Result theme={"system"}
  {
    "linkedin": [
      {
        "lastName": "Smith",
        "firstName": "John",
        "headline": "CTO at Ayrshare",
        "id": "urn:li:person:WBwF1C23L"
      }
    ]
  }
  ```

  ```json 400: Search query too short theme={"system"}
  {
    "linkedin": {
      "action": "request",
      "status": "error",
      "code": 101,
      "message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
      "details": "The search must be a string between 3 and 100 characters."
    }
  }
  ```

  ```json 404: No results found theme={"system"}
  {
    "linkedin": []
  }
  ```
</ResponseExample>
