# LinkedIn Posts Scraper (`khadinakbar/linkedin-posts-scraper`) Actor

Scrape public LinkedIn posts from keyword searches, company feeds, and exact post URLs. Returns post text, author, engagement, media, comments preview, provider provenance, and run summaries. Charged $0.006 per post. MCP/API-ready.

- **URL**: https://apify.com/khadinakbar/linkedin-posts-scraper.md
- **Developed by:** [Khadin Akbar](https://apify.com/khadinakbar) (community)
- **Categories:** Social media, Lead generation, MCP servers
- **Stats:** 40 total users, 14 monthly users, 100.0% runs succeeded, 8 bookmarks
- **User rating**: No ratings yet

## Pricing

from $6.00 / 1,000 linkedin post scrapeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## LinkedIn Posts Scraper

LinkedIn Posts Scraper collects public LinkedIn posts from keyword searches, public company feeds, and exact post URLs. It is designed for readers who need one record per post, with fields such as post text, author details, engagement counts, media URLs, comments preview, provider provenance, and scrape metadata. The result is a dataset of structured public post records plus a machine-readable run summary in key-value store output.

This Actor is available through Apify and usable through Apify MCP. It accepts public LinkedIn source inputs and returns one dataset row per scraped post, which makes each record a single post-level observation from the chosen source. Typical output fields include `postUrl`, `postId`, `publishedAt`, `text`, `authorName`, `authorUrl`, `companyName`, `reactionCount`, `commentCount`, `shareCount`, `engagementCount`, `mediaUrl`, and `provider`.

### Best fit and connected workflows

This Actor fits workflows that start from public LinkedIn discovery and end with structured records for analysis or downstream automation. It routes naturally into:

- keyword-based social listening for public post discovery
- company page monitoring for recent public company posts
- exact URL enrichment for a known public LinkedIn post, feed update, or article
- agent pipelines that need a compact post record with provenance
- B2B research and lead qualification flows built on public post activity

If your workflow begins with a search phrase, a company page URL, or a post URL, this Actor turns that input into consistent post rows that can be filtered, reviewed, or passed to another step.

### Focused standalone workflow

This Actor is designed as a focused standalone workflow.

### Practical scenario

A sales analyst wants to review public posts about "AI agents" from the last month. She enters one search query, sets a post cap, and enables enrichment for fuller post detail. The returned rows include `authorName`, `postUrl`, `text`, `reactionCount`, `commentCount`, `shareCount`, and `provider`. She uses those fields to shortlist posts for manual review, then opens the source post URLs to assess messaging trends and outreach relevance.

### Input

Provide at least one source: search query, company URL, or exact post URL.

| Field | Type | Purpose |
| --- | --- | --- |
| `searchQueries` | array of strings | Keywords or phrases to search in public LinkedIn posts. |
| `companyUrls` | array of strings | Public LinkedIn company page URLs whose recent posts should be scraped. |
| `postUrls` | array of strings | Exact public LinkedIn post, feed update, or article URLs to fetch. |
| `maxPosts` | integer | Maximum number of post records to save across all sources. |
| `datePosted` | string | Freshness filter for keyword search results. |
| `maxSearchPages` | integer | Maximum search pages for keyword pagination. |
| `maxPagesPerCompany` | integer | Maximum pages to fetch per company URL. |
| `startCursor` | string | Cursor for continuing a keyword search run. |
| `providerOrder` | string | Provider order for company feeds and post-detail enrichment. |
| `enrichPostDetails` | boolean | Fetch post detail when supported by the provider. |
| `includeComments` | boolean | Include up to five public comments from post detail payloads. |
| `outputMode` | string | `full` or `compact` output shape. |
| `includeRawData` | boolean | Attach raw provider payloads to each dataset item. |

Focused JSON example:

```json
{
  "searchQueries": ["ai agents", "sales automation"],
  "datePosted": "last-month",
  "maxPosts": 25,
  "maxSearchPages": 3,
  "enrichPostDetails": true,
  "includeComments": false,
  "outputMode": "compact"
}
```

### Output

Each dataset item represents one public LinkedIn post row.

| Field | Type | Purpose |
| --- | --- | --- |
| `sourceType` | string | Discovery method: `search`, `company`, or `postUrl`. |
| `sourceInput` | string | Search query, company URL, or exact post URL that produced the row. |
| `postUrl` | string or null | Public LinkedIn URL for the post, feed update, or article. |
| `postId` | string or null | LinkedIn activity, share, article, or provider identifier. |
| `publishedAt` | string or null | Provider-returned publication date or timestamp. |
| `text` | string or null | Visible post body, article text, or provider description. |
| `authorName` | string or null | Public name of the post author. |
| `authorUrl` | string or null | Public LinkedIn profile or page URL for the author. |
| `companyName` | string or null | Company name for company-sourced or enriched rows. |
| `reactionCount` | integer or null | Total reaction count when available. |
| `commentCount` | integer or null | Public comment count when available. |
| `shareCount` | integer or null | Share or repost count when available. |
| `engagementCount` | integer or null | Convenience total of available engagement counts. |
| `mediaUrl` | string or null | Primary media or image URL when available. |
| `provider` | string | Managed provider or provider chain used for the row. |
| `scrapedAt` | string | ISO timestamp when the Actor saved the row. |

Illustrative JSON record:

```json
{
  "sourceType": "search",
  "sourceInput": "ai agents",
  "postUrl": "https://www.linkedin.com/posts/example_activity-7354600338621906944",
  "postId": "7354600338621906944",
  "publishedAt": "2025-01-12T10:15:00Z",
  "text": "Public post text",
  "authorName": "Example Author",
  "authorUrl": "https://www.linkedin.com/in/example-author/",
  "companyName": "Example Company",
  "reactionCount": 42,
  "commentCount": 5,
  "shareCount": 3,
  "engagementCount": 50,
  "mediaUrl": "https://example.com/image.jpg",
  "provider": "scrapecreators",
  "scrapedAt": "2025-01-12T10:16:02Z"
}
```

The default output also includes a machine-readable run summary in the key-value store, with counters such as records saved, provider attempts, retries, status codes, billing counters, dedupe counts, stop reason, and provider usage.

### How it works

This Actor uses managed provider-backed collection for public LinkedIn posts. Search mode uses Google-indexed public LinkedIn results via ScrapeCreators. Company feeds and exact post URLs are handled through the configured provider order, with `scrapecreators-first` as the default. When post enrichment is enabled, the Actor can fetch fuller text, engagement counts, media, and comments preview when the provider exposes them. Raw provider payloads are available only when `includeRawData` is enabled.

### Pricing

This Actor uses Pay per event pricing plus Apify platform usage.

- Each public LinkedIn post saved to the dataset is billed as one `LinkedIn post scraped` event.
- Actor start is billed as a separate one-time event based on the Actor's memory allocation.
- Apify platform usage, including compute and storage, is applied separately according to the live Pricing tab.

For example, a run that saves one hundred posts is billed for one hundred post-scraped events, plus the Actor start event, plus the standard Apify platform usage shown in the live Pricing tab.

### Use with AI agents (MCP)

This Actor is available through Apify MCP as a tool for retrieving structured public LinkedIn post records. The exact Actor identity is `khadinakbar/linkedin-posts-scraper`.

> Find recent public LinkedIn posts about AI agents, return the post text, author name, engagement counts, source URL, and provider for each row, and keep the result compact for downstream agent processing.

The output is suitable interpreted as post-level records. `sourceType` and `sourceInput` explain how each row was discovered, `provider` shows the managed provider or chain that supplied it, and `scrapedAt` marks when the Actor saved the row. `postUrl` and `postId` identify the public post, while counts such as `reactionCount`, `commentCount`, `shareCount`, and `engagementCount` support ranking or filtering.

For agent workflows, `compact` output keeps the record smaller, while `full` output includes richer post fields when available. `includeComments` adds up to five public comments inside the post-detail payload. Search mode uses provider pagination through `maxSearchPages`, and company mode uses `maxPagesPerCompany`. Billing follows the saved post count, so `maxPosts` is a practical cap for agent calls and test runs.

### Example using the Apify API

```javascript
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({
  token: process.env.APIFY_TOKEN,
});

const run = await client.actor('khadinakbar/linkedin-posts-scraper').call({
  searchQueries: ['ai agents'],
  datePosted: 'last-month',
  maxPosts: 10,
  outputMode: 'compact',
});

const datasetId = run.defaultDatasetId;
const { items } = await client.dataset(datasetId).listItems();
console.log(items);
```

Set `APIFY_TOKEN` in your environment before running the script. The dataset readback returns the saved post rows from the default dataset.

### Best results and outcome guidance

Use one source family at a time when the workflow starts with a narrow goal: keyword search for topic discovery, company URLs for page monitoring, and exact post URLs for single-post enrichment. Lower `maxPosts` for quick agent calls, then raise it when you want a broader sample. If you need richer post records, keep `enrichPostDetails` enabled and use `outputMode: "full"`. If you are testing cursor behavior, adjust `startCursor` and `maxSearchPages` together for search runs.

### Design note

I found that the dataset contract marks `sourceType`, `sourceInput`, `provider`, and `scrapedAt` as required, which makes each record traceable even when many other fields are optional or provider-dependent.

### FAQ

#### Can this Actor start from a keyword search and a company URL in the same run?

Yes. The input schema accepts `searchQueries`, `companyUrls`, and `postUrls` together, and the Actor combines the selected sources into one output set.

#### What does `sourceType` tell me?

It tells you how the post was discovered: `search`, `company`, or `postUrl`.

#### Which fields are useful for routing a post to downstream analysis?

`postUrl`, `postId`, `authorName`, `companyName`, `publishedAt`, `reactionCount`, `commentCount`, `shareCount`, and `engagementCount` are the most common routing fields.

#### When should I use `compact` output?

Use `compact` when you want a smaller record shape for MCP agents, tables, or simple pipelines.

#### When should I use `full` output?

Use `full` when you want richer post fields such as media lists, author images, and additional company context where the provider exposes them.

#### How do I continue a keyword search?

Use `startCursor` with a previous ScrapeCreators search cursor and keep `maxSearchPages` aligned with the search depth you want.

### Responsible use

This Actor is intended for public LinkedIn post data returned by managed provider APIs. Review LinkedIn's terms, applicable laws, and your own use case before running large-scale collection. Use the output for lawful analysis, monitoring, enrichment, and agent workflows that respect privacy and platform rules.

# Actor input Schema

## `searchQueries` (type: `array`):

Keywords or phrases to search in public LinkedIn posts, for example ai agents or open source CRM. Uses Google-indexed public LinkedIn results via ScrapeCreators. Defaults to an empty list. Not for private LinkedIn feeds or logged-in-only posts.

## `companyUrls` (type: `array`):

Public LinkedIn company pages whose recent posts should be scraped, for example https://www.linkedin.com/company/shopify. Accepts one URL per line. Defaults to an empty list. Not for personal profile URLs.

## `postUrls` (type: `array`):

Exact public LinkedIn post, feed update, or article URLs to fetch, for example https://www.linkedin.com/posts/example\_activity-7354600338621906944. Defaults to an empty list. Invalid or non-post LinkedIn URLs are skipped.

## `maxPosts` (type: `integer`):

Maximum number of post records to save across all sources. This is the hard cap for billable post-scraped events. Default is 100. Use lower values for canaries or agent calls.

## `datePosted` (type: `string`):

Freshness filter for keyword search results. Supported values mirror the upstream public-search provider, such as last-week or last-month. Default is last-month. Does not filter company feeds or exact post URLs.

## `maxSearchPages` (type: `integer`):

Advanced cap for ScrapeCreators search pagination. Default is 5 pages and maximum is 60. Lower it when testing cursor behavior. Not used for company URLs or exact post URLs.

## `maxPagesPerCompany` (type: `integer`):

How many provider pages to fetch for each LinkedIn company URL. Default is 2 and maximum is 7 because public company-post coverage is shallow. SociaVault company fallback only returns one page. Not used for search queries.

## `startCursor` (type: `string`):

Optional ScrapeCreators cursor from a previous keyword-search run. Paste the cursor when continuing a search. Leave empty for a fresh search. Not used for company feeds or exact post URLs.

## `providerOrder` (type: `string`):

Choose which managed provider is tried first for company feeds and post-detail enrichment. ScrapeCreators first is recommended for broad post discovery. Default is scrapecreators-first. Search mode requires ScrapeCreators.

## `enrichPostDetails` (type: `boolean`):

Fetch each discovered post detail when a provider supports it. This can add fuller text, engagement counts, media, and comments preview. Default is enabled. Disable it for cheaper, faster discovery-only runs.

## `includeComments` (type: `boolean`):

Include up to five public comments returned inside each post detail payload. Default is false to keep records compact for agents. This is a preview only, not exhaustive comment scraping. Use the comments actor for full comment rows.

## `outputMode` (type: `string`):

Compact mode keeps the main fields for MCP and tables. Full mode also includes image lists, company extras, author images, and richer provenance. Default is full. Raw provider payloads still require includeRawData.

## `includeRawData` (type: `boolean`):

Attach raw provider payloads to each dataset item. Default is false because raw payloads are large and less useful for agents. Enable only for debugging or custom downstream parsing. Does not expose provider API keys.

## Actor input object example

```json
{
  "searchQueries": [
    "ai agents"
  ],
  "companyUrls": [],
  "postUrls": [],
  "maxPosts": 1,
  "datePosted": "last-month",
  "maxSearchPages": 1,
  "maxPagesPerCompany": 2,
  "providerOrder": "scrapecreators-first",
  "enrichPostDetails": true,
  "includeComments": false,
  "outputMode": "full",
  "includeRawData": false
}
```

# Actor output Schema

## `results` (type: `string`):

Dataset items containing post URL, text, author, company context, engagement counts, media, comments preview, source type, and scrape metadata.

## `summary` (type: `string`):

Run summary including recordsSaved, provider attempts, retries, status codes, billing counters, dedupe counts, stopReason, and provider usage.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "searchQueries": [
        "ai agents"
    ],
    "companyUrls": [],
    "postUrls": [],
    "maxPosts": 1,
    "maxSearchPages": 1,
    "enrichPostDetails": false
};

// Run the Actor and wait for it to finish
const run = await client.actor("khadinakbar/linkedin-posts-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "searchQueries": ["ai agents"],
    "companyUrls": [],
    "postUrls": [],
    "maxPosts": 1,
    "maxSearchPages": 1,
    "enrichPostDetails": False,
}

# Run the Actor and wait for it to finish
run = client.actor("khadinakbar/linkedin-posts-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "searchQueries": [
    "ai agents"
  ],
  "companyUrls": [],
  "postUrls": [],
  "maxPosts": 1,
  "maxSearchPages": 1,
  "enrichPostDetails": false
}' |
apify call khadinakbar/linkedin-posts-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=khadinakbar/linkedin-posts-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/EkO2fBxRl67z2FXiH/builds/8oh90e7r1uvNoyWpc/openapi.json
