# Searching for posts

To search for posts on LinkedIn, include the st.searchPosts action in your workflow. Supports keyword search, sorting, date posted, content type, author, and mention filters.

> 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.

To search for posts in LinkedIn, you need to include [`st.searchPosts`](/docs/action-st-search-posts) action in your workflow. It runs LinkedIn's content search on your own account and returns the results as structured JSON. Here's an example:

:::surface node
Each example below has its Node SDK call in the Node tab, and the label over each completion says what that call returns.
:::

:::surface python
Each example below has its Python SDK call in the Python tab, and the label over each completion says what that call returns.
:::

:::surface cli
Each example below has its CLI command in the CLI tab, and the label over each completion says what the command prints.
:::

**Workflow:**

```json tab=HTTP
{
  "actionType": "st.searchPosts",
  "term": "climate tech",
  "limit": 2,
  "filter": {
    "sort": "latest",
    "datePosted": "pastWeek",
    "contentType": "images",
    "postedBy": ["peopleYouFollow"]
  }
}
```

```typescript tab=Node
const workflow = await linkedapi.searchPosts.execute({
  term: "climate tech",
  limit: 2,
  filter: {
    sort: "latest",
    datePosted: "pastWeek",
    contentType: "images",
    postedBy: ["peopleYouFollow"]
  }
});

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=2,
        filter={
            "sort": "latest",
            "date_posted": "pastWeek",
            "content_type": "images",
            "posted_by": ["peopleYouFollow"],
        },
    )
)

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

```bash tab=CLI
linkedin post search \
  --term "climate tech" \
  --limit 2 \
  --sort latest \
  --date-posted pastWeek \
  --content-type images \
  --posted-by peopleYouFollow
```

:::surface http
**Completion:**
:::

:::surface node,python
**Completion** – `result()` returns its `data` in `data`, and a failed action in `errors`:
:::

:::surface cli
**Completion** – with `--json` the CLI prints its `data` as `data`, or the action's `error`:
:::

```json
{
  "actionType": "st.searchPosts",
  "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"],
      "documentSlides": [],
      "hasVideo": false,
      "videoThumbnail": null,
      "hasPoll": false,
      "reactionsCount": 27,
      "commentsCount": 8,
      "repostsCount": 12,
      "viewerState": { "reaction": "like", "isOwn": false }
    },
    {
      "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 }
    }
  ]
}
```

## Narrowing the search by a person or a company

`fromMembers` and `fromCompanies` keep only posts published by the people or companies you list, `mentioningMembers` and `mentioningCompanies` keep only posts that mention them, and `authorCompanies` keeps only posts whose author works at them:

**Workflow:**

```json tab=HTTP
{
  "actionType": "st.searchPosts",
  "term": "climate tech",
  "limit": 5,
  "filter": {
    "fromMembers": [
      "Bill Gates",
      { "name": "Example Person", "id": "urn:li:member:123456789" },
      { "name": "Another Person", "id": "https://www.linkedin.com/in/another-person" }
    ],
    "mentioningCompanies": [
      "Microsoft",
      { "name": "Example Company", "id": "https://www.linkedin.com/company/example-company" }
    ],
    "authorIndustries": ["Software Development"]
  }
}
```

```typescript tab=Node
const workflow = await linkedapi.searchPosts.execute({
  term: "climate tech",
  limit: 5,
  filter: {
    fromMembers: [
      "Bill Gates",
      { name: "Example Person", id: "urn:li:member:123456789" },
      {
        name: "Another Person",
        id: "https://www.linkedin.com/in/another-person"
      }
    ],
    mentioningCompanies: [
      "Microsoft",
      {
        name: "Example Company",
        id: "https://www.linkedin.com/company/example-company"
      }
    ],
    authorIndustries: ["Software Development"]
  }
});

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=5,
        filter={
            "from_members": [
                "Bill Gates",
                {"name": "Example Person", "id": "urn:li:member:123456789"},
                {
                    "name": "Another Person",
                    "id": "https://www.linkedin.com/in/another-person",
                },
            ],
            "mentioning_companies": [
                "Microsoft",
                {
                    "name": "Example Company",
                    "id": "https://www.linkedin.com/company/example-company",
                },
            ],
            "author_industries": ["Software Development"],
        },
    )
)

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

```bash tab=CLI
linkedin post search \
  --term "climate tech" \
  --limit 5 \
  --author-industries "Software Development" \
  --from-members "Bill Gates,Example Person:urn:li:member:123456789,Another Person:https://www.linkedin.com/in/another-person" \
  --mentioning-companies "Microsoft,Example Company:https://www.linkedin.com/company/example-company"
```

Each entry is a name, or a name with an `id` – any identifier of the person or company: its URN or its LinkedIn URL, public or hashed. A name alone can match a namesake; with `id` the filter applies to exactly that person or company, and when it cannot, the action fails with [`filterNotApplied`](/docs/action-st-search-posts) rather than filtering by somebody else.

## How many posts come back

`limit` defaults to **10** and accepts up to **100**, or up to **20** when child actions are attached. 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.

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.

> 💡 If you want to perform actions on posts from search results, use [`st.doForPosts`](/docs/action-st-do-for-posts) action. Search results carry no `urn` on their `author` and `reposter` – nest [`st.openPost`](/docs/action-st-open-post) under it when you need one.

> This page provides examples of [workflows](/docs/building-workflows) and their [completions](/docs/executing-workflows). For detailed documentation on constraints, parameters, and possible results of specific actions, always refer to the corresponding [action documentation pages](/docs/actions-overview).
