# Social Media Posts Extractor (`caprolok/social-media-posts-extractor`) Actor

Effortlessly extract posts from Instagram, TikTok, YouTube, LinkedIn, and Twitter. Search by specific keywords and locations to quickly get structured results, including usernames, captions, engagement stats, and direct post links. Ideal for marketers, creators, and researchers.

- **URL**: https://apify.com/caprolok/social-media-posts-extractor.md
- **Developed by:** [Caprolok](https://apify.com/caprolok) (community)
- **Categories:** Social media, Automation, Lead generation
- **Stats:** 300 total users, 13 monthly users, 100.0% runs succeeded, 9 bookmarks
- **User rating**: No ratings yet

## Pricing

$20.00 / 1,000 data requests

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

![Social Media Posts Extractor](https://caprolok-assets.s3.us-east-1.amazonaws.com/All+Social+Media+Posts+Extractor/all-social-media-posts-extractor-banner.png)

## Social Media Posts Extractor

Pull recent posts from **known accounts** (profile URL or username) on Instagram, TikTok, LinkedIn, Twitter (X), YouTube, Threads, Reddit, Facebook, or VK. Hashtags (`#tag`) still work for power users; for niche breadth across many platforms, prefer the Hashtag Posts Extractor.

### Media URLs

`post_thumbnail` / avatar URLs often come from CDN or search-index caches and **can expire**. Do not treat them as durable asset storage.

Optional: set `rehost_thumbnails` to download images into this run's Apify key-value store and fill `post_thumbnail_apify` (cloud runs only; download failures keep the original CDN URL). Default off.

### What you can extract

- Caption, content type, author name / username
- Platform, post ID, post link, thumbnail
- Timestamp, likes / comments / replies when present
- `engagement_rate` when author `followers` is known
- Original `search_input`

### How to use

1. Create a free Apify account.
2. Open the [Social Media Posts Extractor](https://apify.com/caprolok/social-media-posts-extractor) on Apify.
3. Add **profile URLs or usernames** (optional `#hashtags`), pick one platform, set max results. Optional `since` (YYYY-MM-DD) keeps newer posts only (best-effort).
4. Click Start, then download JSON / CSV / Excel or use the API.

### Pricing

This actor uses **pay-per-event** pricing.

| Event | When it charges |
| ----- | --------------- |
| `data_request` (primary) | Once per real dataset row pushed |
| `platform_usage` | Usage true-up based on Apify platform compute |

Free users are capped and may see upgrade placeholders after a small reveal. Set the Console Monetization primary event to `data_request`.

### Input parameters

| Field | Type | Description | Required |
| ----- | ---- | ----------- | -------- |
| `search_inputs` | array of string | Profile URLs or usernames (optional `#hashtag`) | Yes |
| `platforms` | array of string | One of `INSTAGRAM`, `TIKTOK`, `LINKEDIN`, `TWITTER`, `YOUTUBE`, `THREADS`, `REDDIT`, `FACEBOOK`, `VK` | Yes |
| `max_results` | integer | Maximum number of posts to fetch (default 10) | Yes |
| `location` | string | Country filter (e.g. `US`) | No |
| `exclusions` | array of string | Keywords/usernames/hashtags to exclude | No |
| `since` | string | Keep posts on/after this date (YYYY-MM-DD); best-effort | No |
| `rehost_thumbnails` | boolean | Cloud-only: store thumbnails in KV as `post_thumbnail_apify` (default false) | No |

Legacy `platform` / `max_posts` inputs are still accepted and mapped automatically.

#### Sample input

```json
{
    "search_inputs": [
        "https://www.instagram.com/google/",
        "apple"
    ],
    "platforms": ["INSTAGRAM"],
    "location": "US",
    "max_results": 10,
    "since": "2025-01-01",
    "rehost_thumbnails": false
}
```

### Output

The actor returns a structured dataset with the following fields for each record.

#### Sample Output (JSON)

```json
[
  {
    "caption": "This one’s for the vibe coders. Show us your creations below.",
    "contentType": "Tweet",
    "name": "Google",
    "platform": "twitter",
    "post_id": "191**************",
    "post_link": "https://x.com/Google/status/191**************",
    "timestamp": "2025-05-06",
    "user_link": "https://x.com/Google",
    "username": "Google",
    "replies": 32574278,
    "search_input": "Google"
  }
]
```

### Use Cases

- Build targeted influencer lists for brand collaborations
- Track competitor campaigns and engagement across platforms
- Monitor hashtags to spot trending topics in real time
- Target posts by geography with location-based filtering for localized marketing insights
- Feed social proof and testimonials into landing pages automatically
- Enrich CRM records with the latest customer posts and bios
- Collect user-generated content for market research or sentiment analysis
- Automate weekly social media performance reports for clients
- Train AI/ML models with fresh, labeled social content

### Usage Tips

- Combine multiple hashtags and profile URLs in one run to save credits.
- Set `max_results` to focus on fresh posts and speed up execution.
- Use specific hashtags or handles for higher-quality matches.

### Integrations

Social Media Posts Extractor fits seamlessly into your data pipeline. Thanks to built-in integrations on the Apify platform, you can connect this actor with virtually any cloud service or web app.

#### Popular integrations

- **Make (Integromat)** - automate multi-step workflows.
- **Zapier** - send data to 5,000+ apps.
- **Airbyte** - sync datasets into your data warehouse.
- **Slack** - push instant notifications.
- **Google Sheets & Drive** - store results in spreadsheets or cloud.
- **GitHub** - commit datasets directly to your repositories.
- **AWS S3 / Azure Blob Storage** - archive large exports securely.

#### Webhooks

Set up webhooks to trigger actions when the actor completes or fails, e.g., send email or Slack alerts.

### 🛠️ API Access

Prefer to automate with code? The Apify REST API lets you manage, schedule, and run this actor programmatically.

- **Run & Schedule Actors**
- **Access Datasets**
- **Monitor Runs**
- **Version Control**

#### Client libraries

| Language | Package        | Install                    |
| -------- | -------------- | -------------------------- |
| Node.js  | `apify-client` | `npm install apify-client` |
| Python   | `apify-client` | `pip install apify-client` |

***

For complete API examples and detailed usage, visit the [API documentation](https://apify.com/caprolok/social-media-posts-extractor/api/python).

```js
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 = { "search_inputs": [
        "https://www.instagram.com/google/",
        "apple",
        "#marketing",
    ] }

## Run the Actor and wait for it to finish
run = client.actor("caprolok/social-media-posts-extractor").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)

```

#### MCP Quickstart

You can use the Apify MCP Server in two ways:

```
        **1. Standard Input/Output (stdio):**
```

- Set MCP client server command to `npx @apify/actors-mcp-server` and environment variable `APIFY_TOKEN` to your Apify API token.

**2. HTTPS Endpoint mcp.apify.com:**

- Connect your MCP client by including `Authorization: Bearer <APIFY_TOKEN>` header in your requests.

For more details, see the [MCP API documentation](https://apify.com/caprolok/social-media-posts-extractor/api/python).

### 💬 Support

If you encounter any issues, have suggestions, or need assistance, please use the [Issues tab](https://apify.com/caprolok/social-media-posts-extractor/issues/open). Our team actively monitors this section and will respond promptly.

### Related scrapers

| Actor | Use for |
| ----- | ------- |
| [Social Media Hashtag Posts Extractor](https://apify.com/caprolok/social-media-hashtag-posts-extractor) | Niche keyword / hashtag posts across platforms |
| [Social Media Profile Extractor](https://apify.com/caprolok/social-media-profile-extractor) | Enrich known usernames or profile URLs |
| [Social Media Email Finder](https://apify.com/caprolok/social-media-email-finder) | Public emails by niche keyword |
| [Social Media Phone Finder](https://apify.com/caprolok/social-media-phone-finder) | Public phones by niche keyword |
| [Social Media Influencer Finder](https://apify.com/caprolok/social-media-influencer-finder) | Creator shortlist by follower band + niche |
| [TikTok Leads Generator](https://apify.com/caprolok/tiktok-leads-generator) | TikTok-focused lead discovery |
| [LinkedIn Leads Generator](https://apify.com/caprolok/linkedin-leads-generator) | LinkedIn B2B lead discovery |

# Actor input Schema

## `search_inputs` (type: `array`):

Prefer profile URLs or usernames. Hashtags (#tag) work for power users; for multi-platform niche discovery use the Hashtag Posts Extractor.

## `location` (type: `string`):

Restrict search to a specific country (e.g. US).

## `platforms` (type: `array`):

Select the platform to extract posts from (one platform per run).

## `exclusions` (type: `array`):

Exclude usernames, hashtags, or keywords from results.

## `since` (type: `string`):

Only keep posts on/after this date (YYYY-MM-DD or ISO). Best-effort: search-index lag applies.

## `rehost_thumbnails` (type: `boolean`):

Download post thumbnails into this run's key-value store and set post\_thumbnail\_apify (cloud only; fail-open to CDN URL). Default off.

## `max_results` (type: `integer`):

Maximum number of posts to extract.

## Actor input object example

```json
{
  "search_inputs": [
    "https://www.instagram.com/google/",
    "apple"
  ],
  "platforms": [
    "INSTAGRAM"
  ],
  "exclusions": [],
  "rehost_thumbnails": false,
  "max_results": 10
}
```

# Actor output Schema

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

Dataset of posts (caption, engagement, author, and post links).

# 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 = {
    "search_inputs": [
        "https://www.instagram.com/google/",
        "apple"
    ],
    "platforms": [
        "INSTAGRAM"
    ],
    "exclusions": []
};

// Run the Actor and wait for it to finish
const run = await client.actor("caprolok/social-media-posts-extractor").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 = {
    "search_inputs": [
        "https://www.instagram.com/google/",
        "apple",
    ],
    "platforms": ["INSTAGRAM"],
    "exclusions": [],
}

# Run the Actor and wait for it to finish
run = client.actor("caprolok/social-media-posts-extractor").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 '{
  "search_inputs": [
    "https://www.instagram.com/google/",
    "apple"
  ],
  "platforms": [
    "INSTAGRAM"
  ],
  "exclusions": []
}' |
apify call caprolok/social-media-posts-extractor --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/5pcbluK4V3n1ASdz2/builds/45i4hfJoPuR6FmbwG/openapi.json
