{
  "markdown": "# 📝 LinkedIn Posts API: Posts & Engagement to Structured JSON\n\n> The most efficient, reliable, and developer-friendly way to use the LinkedIn Posts API.\n\n**Actor page:** [apify.com/johnvc/linkedin-posts-api](https://apify.com/johnvc/linkedin-posts-api?fpr=9n7kx3)\n**Input schema:** [apify.com/johnvc/linkedin-posts-api/input-schema](https://apify.com/johnvc/linkedin-posts-api/input-schema?fpr=9n7kx3)\n\nGive it a public LinkedIn profile URL and it discovers that person's recent posts, or pass specific post URLs to fetch directly. You get back one clean JSON row per post: text, reactions, comments, shares, hashtags, media, and author details. It is built API-first and MCP-ready, so you can call it from Python or drive it as a tool from an AI agent.\n\n## Video Walkthrough\n\n[![Watch the walkthrough](https://img.youtube.com/vi/jREWahDGhJM/maxresdefault.jpg)](https://www.youtube.com/watch?v=jREWahDGhJM)\n\n## Quick Start\n\n### Prerequisites\n- Python 3.11 or higher\n- An Apify account and API key ([get a free key here](https://apify.com?fpr=9n7kx3))\n\n1. **Clone the repository**\n   ```bash\n   git clone https://github.com/johnisanerd/Apify-LinkedIn-Posts-API.git\n   cd Apify-LinkedIn-Posts-API\n   ```\n\n2. **Install dependencies with UV**\n   ```bash\n   # Install UV if you do not have it:\n   curl -LsSf https://astral.sh/uv/install.sh | sh\n\n   # Install project dependencies:\n   uv sync\n   ```\n\n3. **Configure your API key**\n   ```bash\n   cp .env.example .env\n   # Edit .env and add your Apify API key\n   # Get your free API key at: https://apify.com?fpr=9n7kx3\n   ```\n\n4. **Run the example**\n   ```bash\n   uv run python linkedin-posts-api-example.py\n   ```\n\n### Alternative: set the API key directly\n```bash\nexport APIFY_API_TOKEN=\"your_api_key_here\"\nuv run python linkedin-posts-api-example.py\n```\n\n## Why Use This LinkedIn Posts API?\n\n**A URL in, structured data out.** You never touch collection infrastructure. Pass a profile URL (or specific post URLs) and get flat, predictable fields you can load straight into a sheet, a database, or a BI tool.\n\n**Two ways to collect.** Discover a profile's recent posts (newest first, capped and optionally date-filtered), or fetch a known set of posts by URL, up to 1000 per run.\n\n**Pay per post.** Billing is per post returned, with no per-run setup fee, so you only pay for what is delivered.\n\n**Reliable and predictable.** Every post comes back with the same field shape, and a profile with no public posts returns a clear error row instead of failing the whole run.\n\n**MCP-ready.** Call it as a tool from Claude, Cursor, and other AI agents (see the install sections below).\n\n## Features\n\n### Core Capabilities\n- Discover a profile's recent posts by profile URL, or fetch specific posts by URL\n- Post text, hashtags, media, and links, plus post type and date\n- Reactions, comments, and shares on every post\n- Author name, headline, follower count, and a sample of top comments\n\n### Data Quality\n- One consistent JSON row per post, every time\n- A plain-language `summary` field on every row for quick scanning and AI use\n- A clear error row for a profile with no public posts, so one empty profile never sinks the batch\n\n## Usage Examples\n\n### Discover a profile's posts\n```json\n{\n  \"profileUrls\": [\"https://www.linkedin.com/in/williamhgates\"],\n  \"maxPostsPerProfile\": 5\n}\n```\n\n### Limit discovery to a date range\n```json\n{\n  \"profileUrls\": [\"https://www.linkedin.com/in/williamhgates\"],\n  \"maxPostsPerProfile\": 50,\n  \"startDate\": \"2025-01-01\",\n  \"endDate\": \"2025-12-31\"\n}\n```\n\n### Fetch specific posts by URL\n```json\n{\n  \"postUrls\": [\n    \"https://www.linkedin.com/posts/williamhgates_activity-7446904645010210816\"\n  ]\n}\n```\n\n## Input Parameters\n\n| Parameter | Type | Required | Default | Description |\n|-----------|------|----------|---------|-------------|\n| `profileUrls` | `list[str]` | one of these | - | Public LinkedIn `/in/` profile URLs to discover posts from. Up to 25 per run. |\n| `postUrls` | `list[str]` | one of these | - | Specific LinkedIn post URLs to fetch directly. Up to 1000 per run. |\n| `maxPostsPerProfile` | `int` | No | `20` | Max posts per profile in discover mode (max 200). Caps cost. Ignored for post URLs. |\n| `startDate` | `str` | No | - | Only discover posts on or after this date (YYYY-MM-DD). Discover mode only. |\n| `endDate` | `str` | No | - | Only discover posts on or before this date (YYYY-MM-DD). Discover mode only. |\n\nSupply at least one of `profileUrls` or `postUrls`.\n\n## Output Format\n\nEach post is returned as one JSON row:\n\n```json\n{\n  \"result_type\": \"post\",\n  \"postId\": \"7446904645010210816\",\n  \"postUrl\": \"https://www.linkedin.com/posts/williamhgates_activity-7446904645010210816\",\n  \"postType\": \"post\",\n  \"datePosted\": \"2025-06-01T12:00:00.000Z\",\n  \"text\": \"A few books shaped how I think about clean energy this year...\",\n  \"hashtags\": [\"cleanenergy\", \"books\"],\n  \"authorName\": \"williamhgates\",\n  \"authorHeadline\": \"Co-chair, Bill & Melinda Gates Foundation\",\n  \"authorUrl\": \"https://www.linkedin.com/in/williamhgates\",\n  \"authorFollowers\": 37000000,\n  \"numLikes\": 12045,\n  \"numComments\": 843,\n  \"numShares\": 210,\n  \"summary\": \"Post by williamhgates, 12,045 reactions, 843 comments, posted 2025-06-01\"\n}\n```\n\nThe `numShares` field is returned when the post has shares.\n\n---\n\n## Install in Claude Cowork Desktop\n\n![Install in Claude Cowork Desktop](https://raw.githubusercontent.com/johnisanerd/ApifyPublicData/main/assets/guides/install_mcp_into_claude_desktop.png)\n\nCowork is the desktop app's automation mode. To give it the LinkedIn Posts API as a tool, add the Apify MCP server as a connector.\n\n1. Open the Claude desktop app and go to **Settings → Connectors** (or **Settings → Developer → Edit Config** to edit `claude_desktop_config.json` directly).\n   - macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`\n   - Windows: `%APPDATA%\\Claude\\claude_desktop_config.json`\n2. Add the Apify MCP server, preloaded with only this Actor:\n\n```json\n{\n  \"mcpServers\": {\n    \"apify\": {\n      \"command\": \"npx\",\n      \"args\": [\n        \"-y\",\n        \"mcp-remote\",\n        \"https://mcp.apify.com/?tools=actors,docs,johnvc/linkedin-posts-api\"\n      ]\n    }\n  }\n}\n```\n\n3. Restart the app. When Cowork first calls the tool, complete the OAuth prompt in your browser, or add your Apify API token in the connector settings to skip OAuth.\n4. In a Cowork chat, confirm the tool is available and ask it to run the LinkedIn Posts API.\n\nDownload the desktop app and start a free trial: https://claude.ai/referral/uIlpa7nPLg\nMore help: https://docs.apify.com/platform/integrations/claude-desktop\n\n---\n\n## Install in Claude Code\n\n![Install in Claude Code](https://raw.githubusercontent.com/johnisanerd/ApifyPublicData/main/assets/guides/install_mcp_into_claude_code.png)\n\nClaude Code is the command-line tool. Add the Actor's MCP server with one command:\n\n```bash\nclaude mcp add --transport http apify \\\n  \"https://mcp.apify.com/?tools=actors,docs,johnvc/linkedin-posts-api\"\n```\n\nTo use a token instead of browser OAuth:\n\n```bash\nclaude mcp add --transport http apify \\\n  \"https://mcp.apify.com/?tools=actors,docs,johnvc/linkedin-posts-api\" \\\n  --header \"Authorization: Bearer YOUR_APIFY_TOKEN\"\n```\n\nThen verify with `claude mcp list`, or run `/mcp` inside a session. Ask Claude Code to call the LinkedIn Posts API.\n\nTry Claude Code free: https://claude.ai/referral/uIlpa7nPLg\nClaude Code MCP docs: https://code.claude.com/docs/en/mcp\n\n---\n\n## Install in Claude (website)\n\n![Install in Claude (website)](https://raw.githubusercontent.com/johnisanerd/ApifyPublicData/main/assets/guides/install_mcp_into_claude_ai.png)\n\nOn claude.ai you add Apify as a connector, then enable just this Actor's tool.\n\n1. Go to **Settings → Connectors → Browse connectors** and search for **Apify MCP server**. Install it (enable or update if prompted).\n2. When connecting, authenticate with your Apify API token, and enable the tool `johnvc/linkedin-posts-api`.\n3. In any chat, open **+ → Connectors** and turn on **Apify**.\n4. Alternatively, choose **Add custom connector** and paste the full MCP URL `https://mcp.apify.com/?tools=actors,docs,johnvc/linkedin-posts-api`, using OAuth when prompted.\n5. Ask Claude to run the LinkedIn Posts API.\n\nOpen Claude on the web: https://claude.ai/referral/uIlpa7nPLg\n\n---\n\n## Install in Cursor\n\n![Install in Cursor](https://raw.githubusercontent.com/johnisanerd/ApifyPublicData/main/assets/guides/install_mcp_into_cursor.png)\n\nCursor reads MCP servers from a project file at `.cursor/mcp.json`.\n\n1. In your project, create `.cursor/mcp.json`:\n\n```json\n{\n  \"mcpServers\": {\n    \"apify\": {\n      \"url\": \"https://mcp.apify.com/?tools=actors,docs,johnvc/linkedin-posts-api\"\n    }\n  }\n}\n```\n\n2. If you prefer token auth over browser OAuth, add a header:\n\n```json\n{\n  \"mcpServers\": {\n    \"apify\": {\n      \"url\": \"https://mcp.apify.com/?tools=actors,docs,johnvc/linkedin-posts-api\",\n      \"headers\": { \"Authorization\": \"Bearer YOUR_APIFY_TOKEN\" }\n    }\n  }\n}\n```\n\n3. Open **Cursor → Settings → MCP** and confirm the **apify** server is connected (green dot).\n4. In Composer or Chat, ask Cursor to call the LinkedIn Posts API.\n\nNew to Cursor? Get it here: https://cursor.com/referral?code=XQP4VBLI3NNX\n\n---\n\n## Install in ChatGPT\n\n![Install in ChatGPT](https://raw.githubusercontent.com/johnisanerd/ApifyPublicData/main/assets/guides/install_mcp_into_ChatGPT.png)\n\nChatGPT connects to the Apify MCP server through Developer mode (available on ChatGPT Pro, Plus, Business, Enterprise, and Education plans).\n\n1. Click your profile icon, then go to **Settings > Apps**. If you do not see a **Create app** button, open **Advanced settings** and enable **Developer mode**.\n2. Click **Create app** and fill out the form:\n   - **Name:** Apify\n   - **MCP Server URL:** `https://mcp.apify.com/?tools=actors,docs,johnvc/linkedin-posts-api`\n   - **Authentication:** OAuth\n3. Click **Create** and authorize the connection with Apify.\n4. To use the app in a conversation, click **+** in the chat, choose **Developer mode**, and select **Apify**.\n\nMore help: https://docs.apify.com/platform/integrations/mcp\n\n---\n\n[**Made with care**](https://apify.com/johnvc?fpr=9n7kx3)\n\n*Use the LinkedIn Posts API to power your content research, social listening, and engagement analytics with reliable, structured results.*\n\nLast Updated: 2026.09.07\n",
  "bytes": 10335,
  "sha": "6402e2d9344bd1565329e50672dc571a669c37251ec488c129f1254d61eeb415",
  "repo_slug": "johnisanerd/apify-linkedin-posts-api",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_johnisanerd_linkedin_posts_f9fca96e/readme"
}