# Instagram Post Scraper (`scrapeai/instagram-post-scraper`) Actor

Scrape Instagram posts. Just add one or more Instagram usernames and get your data in seconds including caption, metrics, images, mentions, coauthors, recent comments, sponsored status, video duration, views. Export scraped data, schedule scraper via API, integrate with other tools or AI workflows.

- **URL**: https://apify.com/scrapeai/instagram-post-scraper.md
- **Developed by:** [ScrapeAI](https://apify.com/scrapeai) (community)
- **Categories:** Social media, Developer tools, Automation
- **Stats:** 2 total users, 1 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.99 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

## 📸 Instagram Post Scraper

Scrape Instagram posts in seconds. Just add one or more Instagram usernames or direct post URLs to extract complete post details including captions, metrics, high-resolution images, mentions, coauthors, recent comments, sponsored status, video duration, and views.

Export scraped data in multiple formats (JSON, CSV, Excel, XML, HTML), schedule recurring scrapers via API, or integrate directly into your AI workflows and webhooks.

***

### ✨ Features

- **Profile & Post Scraping**: Extract posts by entering Instagram usernames or direct post links.
- **Rich Post Metrics**: Extract likes, comments count, video views, estimated shares, and saves.
- **Media & Carousel Images**: Extract single images, video URLs, or full multi-slide carousel image lists.
- **Coauthors & Mentions**: Discover tagged coauthors, brand collaborations, and `@mention` references in post captions.
- **Sponsored Content Detection**: Instantly identify paid partnerships (`isSponsored`).
- **Video & Reel Metadata**: Extract video duration in seconds and view counts for Reels and video posts.
- **Recent Comments Extraction**: Pull top recent comments with user handles, comment text, and comment likes.
- **Export & Integration Ready**: Easily connect to Webhooks, Make, Zapier, LangChain, or AI agents.

***

### 📥 Input Parameters

The Actor accepts the following input parameters in JSON format:

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `usernames` | `array` | `["instagram", "natgeo"]` | List of Instagram usernames to scrape posts from. |
| `directUrls` | `array` | `["https://www.instagram.com/p/C-XyZ12345/"]` | List of direct Instagram post URLs or profile links. |
| `resultsLimit` | `integer` | `20` | Maximum number of posts to scrape per target. |
| `includeComments` | `boolean` | `true` | Include recent comments for each scraped post. |
| `maxComments` | `integer` | `5` | Maximum number of recent comments per post item. |
| `proxyConfiguration` | `object` | `{"useApifyProxy": false}` | Proxy configuration to bypass rate limits. |
| `debugLog` | `boolean` | `false` | Enable verbose diagnostic debug logging. |

#### Input Example (`input.json`)

```json
{
    "usernames": [
        "instagram",
        "natgeo"
    ],
    "directUrls": [
        "https://www.instagram.com/p/C-XyZ12345/"
    ],
    "resultsLimit": 10,
    "includeComments": true,
    "maxComments": 5,
    "debugLog": false
}
```

***

### 📤 Output Dataset

The output is saved directly into an Apify Dataset. Each item contains complete post metadata structured as follows:

#### Output Item Example

```json
{
  "id": "post_CB3K9L1A",
  "type": "Sidecar/Carousel",
  "shortCode": "CB3K9L1A",
  "url": "https://www.instagram.com/p/CB3K9L1A/",
  "caption": "Exploring new horizons in #photography with @instagram! What do you think of this carousel? #photography #natgeo #viral",
  "hashtags": [
    "#photography",
    "#natgeo",
    "#viral"
  ],
  "mentions": [
    "@natgeo",
    "@instagram",
    "@creator_photography"
  ],
  "coauthors": [
    {
      "username": "coauthor_photography",
      "fullName": "Creative Partner",
      "verified": false
    }
  ],
  "images": [
    "https://instagram.com/p/CB3K9L1A/media_1.jpg",
    "https://instagram.com/p/CB3K9L1A/media_2.jpg",
    "https://instagram.com/p/CB3K9L1A/media_3.jpg"
  ],
  "displayUrl": "https://instagram.com/p/CB3K9L1A/media_1.jpg",
  "videoUrl": null,
  "videoDuration": null,
  "videoViewCount": 0,
  "views": 0,
  "metrics": {
    "likesCount": 42150,
    "commentsCount": 1820,
    "sharesCount": 5058,
    "savesCount": 3372,
    "videoViewCount": 0
  },
  "likesCount": 42150,
  "commentsCount": 1820,
  "isSponsored": false,
  "ownerUsername": "natgeo",
  "ownerId": "id_natgeo_681",
  "ownerFullName": "Natgeo",
  "recentComments": [
    {
      "commentId": "c_CB3K9L1A_1",
      "text": "Love the details in this sidecar/carousel! 🙌",
      "ownerUsername": "user_4812",
      "timestamp": "2026-08-06T11:00:00.000Z",
      "likesCount": 12,
      "postId": "post_CB3K9L1A",
      "postShortCode": "CB3K9L1A"
    }
  ],
  "timestamp": "2026-08-04T15:07:00.000Z",
  "scrapedAt": "2026-08-06T15:07:00.000Z"
}
```

***

### 🚀 How to Use & Integration

#### Run via Apify CLI

```bash
apify run
```

#### Run via API

You can start runs programmatically using the Apify REST API:

```bash
curl -X POST "https://api.apify.com/v2/acts/instagram-post-scraper/runs?token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "usernames": ["natgeo"],
    "resultsLimit": 20
  }'
```

#### Export Formats

Downstream data can be exported in:

- **JSON / JSONL**
- **CSV / Excel**
- **XML**
- **HTML Table**

***

### 🛡️ Proxies & Best Practices

For bulk requests or production automation, pass `proxyConfiguration` with Apify Proxy to avoid IP rate limits and ensure smooth data delivery across regions.

# Actor input Schema

## `usernames` (type: `array`):

List of Instagram usernames to scrape posts from. E.g. \['instagram', 'natgeo']

## `directUrls` (type: `array`):

List of direct Instagram post URLs or profile URLs to scrape.

## `resultsLimit` (type: `integer`):

Maximum number of posts to extract per username or profile URL.

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

Fetch recent comments for each extracted post.

## `maxComments` (type: `integer`):

Number of recent comments to include per post item.

## `proxyConfiguration` (type: `object`):

Proxy settings to bypass anti-scraping protections.

## `debugLog` (type: `boolean`):

Output verbose debug diagnostic logs.

## Actor input object example

```json
{
  "usernames": [
    "instagram",
    "natgeo"
  ],
  "directUrls": [
    "https://www.instagram.com/p/C-XyZ12345/"
  ],
  "resultsLimit": 20,
  "includeComments": true,
  "maxComments": 5,
  "proxyConfiguration": {
    "useApifyProxy": false
  },
  "debugLog": false
}
```

# Actor output Schema

## `dataset` (type: `string`):

Dataset containing scraped Instagram posts and carousels.

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("scrapeai/instagram-post-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 = {}

# Run the Actor and wait for it to finish
run = client.actor("scrapeai/instagram-post-scraper").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{}' |
apify call scrapeai/instagram-post-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,scrapeai/instagram-post-scraper"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/Hb62qVyw5aCqkkRw4/builds/QyVuheo5y35mgSmP6/openapi.json
