# st.searchPosts

> The API Reference is also the SDK and CLI reference. Consecutive code fences marked `tab=HTTP`, `tab=Node`, `tab=Python` and `tab=CLI` are the same call on each surface (a fence marked `tab=HTTP,CLI` is the same text for both), and a block between `:::surface <names>` and `:::` applies only to the surfaces it names. Identifiers in the text are written as in Node and in HTTP JSON (camelCase); the Python SDK spells methods, parameters and result attributes in snake_case (`sendMessage` → `send_message`, `reconnectionLink` → `reconnection_link`), while names inside HTTP JSON stay camelCase.

This action allows you to search for posts applying various filtering criteria.

:::surface node,python
In the SDK this is the `searchPosts` method. It takes the parameters below except `label` and `then`, which exist only in workflow JSON, and returns the result below in `data`.
:::

:::surface cli
In the CLI this is `linkedin post search` – the command is below, under [Parameters](#parameters).
:::

## Constraints

> ⏺️ **Root Start:** allowed.

> ⬆️ **Parent Actions:** N/A.

> ⬇️ **Child Actions:** [st.doForPosts](/docs/action-st-do-for-posts).

## Parameters

```json tab=HTTP
{
  "actionType": "st.searchPosts",
  "label": "climateTechSearch1",
  "term": "climate tech",
  "limit": 20,
  "filter": {
    "sort": "latest",
    "datePosted": "pastWeek",
    "contentType": "images",
    "postedBy": ["firstConnections", "peopleYouFollow"],
    "fromMembers": [
      { "name": "Bill Gates", "id": "urn:li:member:251749025" }
    ],
    "fromCompanies": ["Example Company"],
    "mentioningMembers": [
      { "name": "Example Person", "id": "https://www.linkedin.com/in/example-person" }
    ],
    "mentioningCompanies": [
      { "name": "Another Company", "id": "https://www.linkedin.com/company/another-company" }
    ],
    "authorCompanies": [
      { "name": "Example Company", "id": "urn:li:organization:1234567" }
    ],
    "authorIndustries": ["Software Development"]
  },
  "customSearchUrl": "https://www.linkedin.com/search/results/content/?keywords=climate%20tech",
  "then": { ... }
}
```

```typescript tab=Node
const workflow = await linkedapi.searchPosts.execute({
  term: "climate tech",
  limit: 20,
  filter: {
    sort: "latest",
    datePosted: "pastWeek",
    contentType: "images",
    postedBy: ["firstConnections", "peopleYouFollow"],
    fromMembers: [
      { name: "Bill Gates", id: "urn:li:member:251749025" }
    ],
    fromCompanies: ["Example Company"],
    mentioningMembers: [
      {
        name: "Example Person",
        id: "https://www.linkedin.com/in/example-person"
      }
    ],
    mentioningCompanies: [
      {
        name: "Another Company",
        id: "https://www.linkedin.com/company/another-company"
      }
    ],
    authorCompanies: [
      {
        name: "Example Company",
        id: "urn:li:organization:1234567"
      }
    ],
    authorIndustries: ["Software Development"]
  },
  customSearchUrl: "https://www.linkedin.com/search/results/content/?keywords=climate%20tech"
});

const { data, errors } = await linkedapi.searchPosts.result(workflow.workflowId);
```

```python tab=Python
from linkedapi import SearchPostsParams

workflow = linkedapi.search_posts.execute(
    SearchPostsParams(
        term="climate tech",
        limit=20,
        filter={
            "sort": "latest",
            "date_posted": "pastWeek",
            "content_type": "images",
            "posted_by": ["firstConnections", "peopleYouFollow"],
            "from_members": [
                {"name": "Bill Gates", "id": "urn:li:member:251749025"},
            ],
            "from_companies": ["Example Company"],
            "mentioning_members": [
                {
                    "name": "Example Person",
                    "id": "https://www.linkedin.com/in/example-person",
                },
            ],
            "mentioning_companies": [
                {
                    "name": "Another Company",
                    "id": "https://www.linkedin.com/company/another-company",
                },
            ],
            "author_companies": [
                {
                    "name": "Example Company",
                    "id": "urn:li:organization:1234567",
                },
            ],
            "author_industries": ["Software Development"],
        },
        custom_search_url="https://www.linkedin.com/search/results/content/?keywords=climate%20tech",
    )
)

result = linkedapi.search_posts.result(workflow.workflow_id)
```

```bash tab=CLI
# Not available in the CLI: customSearchUrl
linkedin post search \
  --term "climate tech" \
  --limit 20 \
  --sort latest \
  --date-posted pastWeek \
  --content-type images \
  --posted-by firstConnections,peopleYouFollow \
  --author-industries "Software Development" \
  --from-members "Bill Gates:urn:li:member:251749025" \
  --from-companies "Example Company" \
  --mentioning-members "Example Person:https://www.linkedin.com/in/example-person" \
  --mentioning-companies "Another Company:https://www.linkedin.com/company/another-company" \
  --author-companies "Example Company:urn:li:organization:1234567"
```

In AI assistants, the MCP server runs this action as the `search_posts` tool.

:::surface cli
In the CLI this is `linkedin post search`:

```bash
linkedin post search [flags]
```

| Flag | Type | Description |
| --- | --- | --- |
| `--term` | string | Search keyword or phrase, up to 50 characters |
| `--limit` | integer | Max results to return, up to 100 |
| `--sort` | string | One of `topMatch`, `latest` |
| `--date-posted` | string | One of `past24Hours`, `pastWeek`, `pastMonth` |
| `--content-type` | string | One of `videos`, `images`, `jobPosts`, `liveVideos`, `documents` |
| `--posted-by` | string | Comma-separated: `me`, `firstConnections`, `peopleYouFollow` |
| `--from-members` | string | Comma-separated people whose posts to keep |
| `--from-companies` | string | Comma-separated companies whose posts to keep |
| `--mentioning-members` | string | Comma-separated people the post must mention |
| `--mentioning-companies` | string | Comma-separated companies the post must mention |
| `--author-companies` | string | Comma-separated companies the author works at |
| `--author-industries` | string | Comma-separated industries the author works in |

Each element of the member and company flags is `name` or `name:identifier`. The identifier is a URN or a LinkedIn URL of that person or company, and pins the filter to exactly them; a name alone may match a namesake. When no match is found, the action fails with `filterNotApplied`.

```bash
linkedin post search --term "ai" --from-members "Bill Gates,Example Person:urn:li:member:123456789" --json
```

> A Sales Navigator URL that contains a comma cannot be used inside the comma-separated list.

A search may return fewer posts than `--limit`, because how many results come back depends on what LinkedIn loads for that account on that search. LinkedIn also widens a narrow query on its own, so a non-empty result does not mean your term matched. See [searching for posts](/docs/searching-for-posts).

> Search results carry no `urn` on their `author` and `reposter` – run `post fetch` on a result's `url` when you need one.
:::

- `label` (optional) – custom label for tracking this action in workflow completion.
- `term` (optional) – keyword or phrase to search, from 1 to 50 characters. Either `term` or `customSearchUrl` must be provided; a request with neither (for example, with `filter` only) is rejected.
- `limit` (optional) – number of search results to return. Defaults to **10**, with a maximum value of **100**, or **20** when child actions are used. A value above the applicable maximum is rejected when the workflow is submitted. A search may return fewer posts than `limit`, because how many results come back depends on what LinkedIn loads for that account on that search.
- `filter` (optional) – object that specifies filtering criteria for posts. Every specified field is applied, or the action fails. When multiple filter fields are specified, they are combined using `AND` logic. Ignored entirely when `customSearchUrl` is specified.
  - `sort` (optional) – enum with possible values:
    - `topMatch`.
    - `latest`.
  - `datePosted` (optional) – enum with possible values:
    - `past24Hours`.
    - `pastWeek`.
    - `pastMonth`.
  - `contentType` (optional) – enum with possible values:
    - `videos`.
    - `images`.
    - `jobPosts`.
    - `liveVideos`.
    - `documents`.
  - `postedBy` (optional) – array of enums with possible values:
    - `me`.
    - `firstConnections`.
    - `peopleYouFollow`.
  - `fromMembers` (optional) – array of people whose posts to keep. Matches if the post was published by any of the listed people.
  - `fromCompanies` (optional) – array of companies whose posts to keep. Matches if the post was published by any of the listed companies.
  - `mentioningMembers` (optional) – array of people to look for in post text. Matches if the post mentions any of the listed people.
  - `mentioningCompanies` (optional) – array of companies to look for in post text. Matches if the post mentions any of the listed companies.
  - `authorCompanies` (optional) – array of companies the author works at. Matches if the post's author works at any of the listed companies.
  - `authorIndustries` (optional) – array of industry names the author works in. Matches if the post's author works in any of the listed industries. Takes specific values available in the LinkedIn interface. An industry is a taxonomy value rather than an entity, so it is matched by name only.
- `customSearchUrl` (optional) – URL copied from a LinkedIn content search page after configuring desired filters. When specified, `filter` is ignored entirely and the facets already encoded in the URL are the only ones applied. Either `term` or `customSearchUrl` must be provided.
- `then` (optional) – object or array of child actions to be executed within this action.

LinkedIn widens a narrow query on its own and returns loosely related posts, so a non-empty result does not mean your `term` matched. Check the returned posts against your own criteria when an exact match matters.

### Identifying people and companies in filters

Each entry of `fromMembers`, `fromCompanies`, `mentioningMembers`, `mentioningCompanies`, and `authorCompanies` is a name, or a name with an `id`:

```json
{
  "fromMembers": [
    "Bill Gates",
    { "name": "Satya Nadella", "id": "https://www.linkedin.com/in/satyanadella" }
  ],
  "fromCompanies": [
    "Microsoft",
    { "name": "Example Company", "id": "urn:li:organization:1234567" }
  ]
}
```

- `name` (required) – name of the person or company as typed into LinkedIn's filter panel, from 1 to 100 characters. When `id` is a member URN or a Sales Navigator URL, the person must appear among LinkedIn's suggestions for this name.
- `id` (optional) – [URN](/docs/data-conventions#linkedin-urns), [public or hashed](/faq/what-are-hashed-url-and-public-url) LinkedIn URL (Sales Navigator URLs included), or, for a company, numeric ID. Pins the filter to exactly that person or company. A person's public URL is opened once from your account to read their identifier, so they may see one profile visit; a company's public URL is opened on every search, so prefer its URN or numeric ID.

> A name alone may match a namesake: Linked API takes the LinkedIn suggestion whose name matches yours, ignoring case, punctuation and a trailing legal form such as `Inc` or `GmbH`, or else the first one that starts with it as a whole word, so `Anta` can become `Anta International` but never `Antal`. If no suggestion matches, the action fails with `filterNotApplied`.

## Result options

1. **Successful search:**

```json
{
  "actionType": "st.searchPosts",
  "label": "climateTechSearch1",
  "success": true,
  "data": [
    {
      "url": "https://www.linkedin.com/feed/update/urn:li:activity:1234567890123456789",
      "activityUrn": "urn:li:activity:1234567890123456789",
      "time": "2023-01-02T12:30:00Z",
      "type": "original",
      "author": {
        "type": "person",
        "name": "Example Person",
        "profileUrl": "https://www.linkedin.com/in/example-person",
        "headline": "Product Marketing Lead",
        "viewerState": { "connectionDegree": "2nd" }
      },
      "reposter": null,
      "text": "Check out our latest product launch!",
      "repostText": null,
      "hashtags": ["product", "launch"],
      "mentions": ["https://www.linkedin.com/company/example-company"],
      "externalLinks": ["https://example.com/launch"],
      "images": [
        "https://static.linkedin.com/image1.jpg",
        "https://static.linkedin.com/image2.jpg"
      ],
      "documentSlides": [],
      "hasVideo": false,
      "videoThumbnail": null,
      "hasPoll": false,
      "reactionsCount": 27,
      "commentsCount": 8,
      "repostsCount": 12,
      "viewerState": { "reaction": "like", "isOwn": false },
      "then": { ... }
    },
    {
      "url": "https://www.linkedin.com/feed/update/urn:li:activity:2345678901234567890",
      "activityUrn": "urn:li:activity:2345678901234567890",
      "time": "2023-01-01T09:15:00Z",
      "type": "repost",
      "author": {
        "type": "company",
        "name": "Example Company",
        "companyUrl": "https://www.linkedin.com/company/example-company"
      },
      "reposter": {
        "type": "person",
        "name": "Example Reposter",
        "profileUrl": "https://www.linkedin.com/in/example-reposter",
        "headline": null
      },
      "text": "Original post content about the webinar.",
      "repostText": "A useful summary for anyone planning a launch.",
      "hashtags": [],
      "mentions": [],
      "externalLinks": [],
      "images": [],
      "documentSlides": [],
      "hasVideo": true,
      "videoThumbnail": "https://media.licdn.com/dms/image/video-cover.jpg",
      "hasPoll": false,
      "reactionsCount": 6,
      "commentsCount": 0,
      "repostsCount": 1,
      "viewerState": { "reaction": null, "isOwn": false },
      "then": { ... }
    }
  ]
}
```

- `label` – included only if specified in the action parameters.
- `data` – array of search outputs with results of child actions execution.
  - `url` – URL of the post.
  - `activityUrn` – LinkedIn activity or UGC URN of the post, if available.
  - `time` – timestamp when the post was published.
  - `type` – type of the post. Enum with possible values:
    - `original` – for original posts.
    - `repost` – for reposts.
  - `author` – original content creator. Can be `null` if the actor cannot be parsed.
    - For person authors: `type`, `name`, `profileUrl`, `headline`, `viewerState` with `connectionDegree` – `1st`, `2nd`, `3rd+`, or `null` if LinkedIn does not show it (see [viewer state](/docs/data-conventions#viewer-state)).
    - For company authors: `type`, `name`, `companyUrl`.
  - `reposter` – person or company that reshared the post. Non-null only when `type` is `repost`.
    - For person reposters: `type`, `name`, `profileUrl`, `headline`.
    - For company reposters: `type`, `name`, `companyUrl`.
  - `text` – original author's post text, if available.
  - `repostText` – text added by the reposter on a repost with comment, if available.
  - `hashtags` – array of hashtags found in the post text, without leading `#`.
  - `mentions` – array of person and company profile URLs found in the post text.
  - `externalLinks` – array of outbound URLs found in the post text.
  - `images` – array of up to 3 preview image URLs, if available.
  - `documentSlides` – array of carousel or document slide image URLs, if available.
  - `hasVideo` – boolean indicating if the post contains a video.
  - `videoThumbnail` – URL of the video thumbnail, if available.
  - `hasPoll` – boolean indicating if the post contains a poll.
  - `reactionsCount` – number of reactions on the post.
  - `commentsCount` – number of comments on the post.
  - `repostsCount` – number of reposts on the post.
  - `viewerState` – what your account has done with the post, see [viewer state](/docs/data-conventions#viewer-state).
    - `reaction` – your reaction to the post (`like`, `celebrate`, `support`, `love`, `insightful`, `funny`), or `null` if you have not reacted or it could not be read.
    - `isOwn` – `true` if your account is the post author, `false` if someone else is, or `null` if this cannot be told.
  - `then` – results of child actions execution.

> Unlike posts returned by [st.openPost](/docs/action-st-open-post), the `author` and `reposter` of a search result carry **no** `urn` field. The URN is read from the post's own page, so open the post with [st.doForPosts](/docs/action-st-do-for-posts) and [st.openPost](/docs/action-st-open-post) when you need it.

2. **Failed search:**

```json
{
  "actionType": "st.searchPosts",
  "label": "climateTechSearch1",
  "success": false,
  "error": {
    "type": "searchingNotAllowed",
    "message": "LinkedIn has blocked performing the search."
  }
}
```

- `label` – included only if specified in the action parameters.
- `error.type` – enum with the following possible values:
  - `filterNotApplied` – one or more filter values could not be applied: no LinkedIn option matched a name, or the person or company an `id` names could not be found or is not among LinkedIn's suggestions for `name`. It does not mean the person or company is gone; the message lists each field, value, and reason, so correct or remove the entry rather than retrying.
  - `searchingNotAllowed` – LinkedIn has blocked performing the search due to exceeding limits or other restrictions.
