# Instagram Comments Scraper (`khadinakbar/instagram-comments-scraper`) Actor

Scrape public Instagram post and Reel comments from URLs. MCP optimized output with usernames, timestamps, likes, profile URLs, cursors, and provider fallback.

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

## Pricing

from $10.00 / 1,000 scraped instagram comments

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

## Instagram Comments Scraper

Instagram Comments Scraper is an Apify Actor for people and agents that start from a public Instagram post or Reel URL and need one dataset record per visible top-level comment. It accepts `postUrls` or Apify request-list style `startUrls`, and it returns comment text, usernames, timestamps, likes, profile URLs, cursors, provider provenance, and run summary data. The outcome is a structured comment dataset ready for analysis, spreadsheets, automation, and Apify MCP workflows.

### Best fit and connected workflows

This Actor fits workflows that begin with a known public Instagram post or Reel and continue into comment-level analysis.

Common routing patterns include:

- social listening on public post and Reel conversations
- creator or brand monitoring from a specific URL
- lead research around public discussion on a post
- agent workflows that need compact comment rows through Apify MCP
- continuation runs when a single post needs the next page of comments

The Actor uses provider-backed public-data APIs and tries managed providers in the selected order. By default, ScrapeCreators is used first and SociaVault is available as fallback. That keeps the workflow centered on a single Instagram URL while preserving pagination cursors for later continuation.

### Focused standalone workflow

This Actor is designed as a focused standalone workflow.

### Practical scenario

Maya manages creator research for a brand campaign. She starts with a public Reel URL, sets a comment cap, and lets the Actor collect the visible top-level comments. The returned rows give her `commenter_username`, `text`, `created_at`, `comment_like_count`, and `commenter_profile_url`. She uses those fields to spot repeated questions in the thread and then reviews the profiles behind the most relevant replies.

### Input

Use `postUrls` for public Instagram post or Reel URLs. Use `startUrls` when another Apify actor or agent passes request-list objects. The remaining fields control pagination, provider routing, continuation, and row detail.

| Field | Type | Purpose |
|---|---|---|
| `postUrls` | array of strings | Public Instagram post or Reel URLs to scrape comments from |
| `startUrls` | array of request objects | Alternative request-list input for `/p/`, `/reel/`, or `/tv/` URLs |
| `maxComments` | integer | Maximum visible top-level comments to save per post or Reel |
| `maxPagesPerPost` | integer | Maximum provider pagination pages to request per post |
| `providerOrder` | string | Provider preference: `scrapecreators-first`, `sociavault-first`, `scrapecreators-only`, or `sociavault-only` |
| `initialCursor` | string | Cursor for continuing a previous single-post run |
| `outputMode` | string | `compact` or `detailed` rows |
| `includeRawData` | boolean | Adds the raw provider comment object to each row when enabled |

#### Focused input example

```json
{
  "postUrls": [
    "https://www.instagram.com/reel/DOq6eV6iIgD/"
  ],
  "maxComments": 100,
  "maxPagesPerPost": 20,
  "providerOrder": "scrapecreators-first",
  "outputMode": "compact",
  "includeRawData": false
}
```

### Output

Each saved dataset row represents one visible top-level comment. The default dataset stores the rows, and `RUN_SUMMARY` in the key-value store provides provider usage, per-target status, counts, next cursors, warnings, and stop reason.

| Field | Type | Purpose |
|---|---|---|
| `record_type` | string | Record type for this Actor, always `comment` |
| `provider` | string | Provider that returned the comment |
| `input_url` | string | Original Instagram URL supplied in the input |
| `post_url` | string | Normalized public Instagram post or Reel URL |
| `shortcode` | string or null | Instagram shortcode parsed from the source URL |
| `comment_id` | string or null | Provider-returned Instagram comment ID when available |
| `text` | string or null | Visible comment text |
| `created_at` | string or null | Comment creation timestamp in ISO 8601 format when returned |
| `comment_like_count` | integer or null | Number of likes on the comment when available |
| `commenter_username` | string or null | Instagram username of the commenter |
| `commenter_id` | string or null | Provider-returned Instagram user ID of the commenter |
| `commenter_is_verified` | boolean or null | Verified status of the commenter account |
| `commenter_profile_pic_url` | string or null | Profile picture URL returned for the commenter |
| `commenter_profile_url` | string or null | Direct Instagram profile URL for the commenter |
| `position` | integer | One-based global row position in this run |
| `page_number` | integer | One-based provider page number for this target |
| `source_cursor` | string or null | Cursor used to fetch the page that returned this comment |
| `next_cursor_at_fetch` | string or null | Cursor returned with this page for continuation runs |
| `source_url` | string | Normalized post or Reel URL used for the provider request |
| `run_id` | string or null | Apify run ID when available |
| `scraped_at` | string | Timestamp when this row was saved |
| `raw_data` | object, array, string, number, boolean, or null | Optional raw provider comment object when detailed output is enabled |

#### Illustrative output record

```json
{
  "record_type": "comment",
  "provider": "scrapecreators",
  "input_url": "https://www.instagram.com/reel/DOq6eV6iIgD/",
  "post_url": "https://www.instagram.com/reel/DOq6eV6iIgD/",
  "shortcode": "DOq6eV6iIgD",
  "comment_id": "18051843701642870",
  "text": "Great post",
  "created_at": "2025-09-16T17:03:04.000Z",
  "comment_like_count": 3,
  "commenter_username": "catherina_thijs",
  "commenter_id": "46773599357",
  "commenter_is_verified": false,
  "commenter_profile_pic_url": "https://scontent.cdninstagram.com/profile.jpg",
  "commenter_profile_url": "https://www.instagram.com/catherina_thijs/",
  "position": 1,
  "page_number": 1,
  "source_cursor": "eyJjYWNoZWRfY29tbWVud...",
  "next_cursor_at_fetch": "AQHSpoi6HyDbzYRMzrD",
  "source_url": "https://www.instagram.com/reel/DOq6eV6iIgD/",
  "scraped_at": "2026-06-11T10:00:00.000Z"
}
```

### How it works

The Actor follows a straightforward provider-backed flow:

1. It accepts public Instagram post or Reel URLs, or request-list style start URLs.
2. It uses managed public-data APIs to fetch visible top-level comments.
3. It tries ScrapeCreators first by default and SociaVault as fallback.
4. It stores one dataset row per comment using a compact schema by default.
5. It records diagnostics, including provider usage and continuation cursors, in `RUN_SUMMARY`.
6. It supports continuation with `initialCursor` when exactly one target URL is supplied.

The live contract also exposes these provider-access environment variables:

- `SCRAPECREATORS_API_KEY`
- `SOCIAVAULT_API_KEY`
- `SOCIALVAULT_API_KEY`

### Pricing

This Actor uses pay per event pricing plus Apify platform usage. The live Pricing tab shows the current billing details.

The charged events are:

- Actor start
- Scraped Instagram Comment

For example, if a run saves one hundred comments, the execution includes one actor-start event and one hundred scraped-comment events, plus Apify platform usage. Review the live Pricing tab before running larger comment sets.

### Use with AI agents (MCP)

This Actor is available as an Apify Actor usable through Apify MCP. It is built for compact comment rows that agents can read directly, while still exposing provenance fields such as `provider`, `post_url`, `source_cursor`, and `next_cursor_at_fetch`.

**Tool description:** Fetch public Instagram post or Reel comments from a URL and return dataset rows with comment text, author metadata, timestamps, likes, and pagination cursors.

**Actor identity:** `khadinakbar/instagram-comments-scraper`

> Scrape the comments from this public Instagram Reel URL. Return compact rows with commenter usernames, text, timestamps, like counts, and the next cursor if more pages are available.

Output interpretation for agents:

- `text` is the visible comment body.
- `commenter_username` and `commenter_profile_url` identify the commenter.
- `created_at` is the provider timestamp when returned.
- `provider` records which managed public-data API supplied the row.
- `source_cursor` and `next_cursor_at_fetch` support continuation on a single target URL.
- `raw_data` is available when detailed output or raw-data capture is enabled.

Provenance and scope:

- Rows come from public Instagram post and Reel URLs only.
- The Actor stores comments in the default dataset and execution diagnostics in `RUN_SUMMARY`.
- The live schema marks each row as a comment record.
- Pagination is provider-based, with `maxPagesPerPost` controlling page requests and `maxComments` controlling saved rows.

Cost guidance for agents:

- Use smaller `maxComments` values for quick calls.
- Use `initialCursor` only when continuing one target URL.
- Keep `includeRawData` off for compact agent loops unless raw provider fragments are needed.

### Apify API example

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

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

const run = await client.actor("khadinakbar/instagram-comments-scraper").call({
  postUrls: ["https://www.instagram.com/reel/DOq6eV6iIgD/"],
  maxComments: 100,
  maxPagesPerPost: 20,
  providerOrder: "scrapecreators-first",
  outputMode: "compact",
  includeRawData: false,
});

const dataset = await client.dataset(run.defaultDatasetId).listItems();

console.log("Run ID:", run.id);
console.log("Items:", dataset.items);
```

### Best results and outcome guidance

Use a public post or Reel URL as the starting point. Keep `maxComments` aligned with the amount of comment data you need. Use `maxPagesPerPost` to control provider pagination, and use `initialCursor` only for a single URL continuation run. If you want a cleaner agent payload, keep `outputMode` set to `compact` and leave `includeRawData` off. If you want provider debugging or custom field inspection, switch to detailed output and include raw data.

### Design note

I found that the live output view is centered on `post_url`, `commenter_username`, `text`, `created_at`, `comment_like_count`, `provider`, and `position`, which makes the default dataset easy to scan in a table.

### FAQ

#### When should I use `postUrls` instead of `startUrls`?

Use `postUrls` when you already have a public Instagram post or Reel URL. Use `startUrls` when another Apify actor or agent passes request-list objects.

#### Which Instagram URLs fit this Actor?

This Actor is routed for public `/p/`, `/reel/`, and `/tv/` URLs that point to a post or Reel.

#### Which provider runs first?

By default, ScrapeCreators runs first and SociaVault is used as fallback. You can switch the order or use a single-provider mode through `providerOrder`.

#### How do I continue a previous run?

Use `initialCursor` with exactly one target URL, and pass the `next_cursor_at_fetch` value from the prior run's `RUN_SUMMARY`.

#### What gets written to the dataset?

One dataset row is written per visible top-level Instagram comment, with commenter and provenance fields when returned by the provider.

#### Where do I read execution diagnostics?

Read `RUN_SUMMARY` from the key-value store for per-target status, counts, cursors, warnings, and stop reason.

### Responsible use

Use the Actor only for public Instagram post and Reel URLs that are available through the provider-backed public-data APIs. Keep usage aligned with Instagram content access rules, your own governance requirements, and the current Apify Pricing tab.

# Actor input Schema

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

Public Instagram posts or reels to scrape comments from. Accepts full URLs such as https://www.instagram.com/p/CODE/ or https://www.instagram.com/reel/CODE/. Not for profile URLs, hashtags, private posts, or login-only content.

## `startUrls` (type: `array`):

Alternative Apify request-list input for Instagram /p/, /reel/, or /tv/ URLs. Use this when another actor or agent passes request objects. Not for usernames, hashtag pages, or explore URLs.

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

Maximum visible top-level comments to save per post or reel. Defaults to 100. Range 1 to 50000. Use a lower value for quick MCP calls and a higher value for bulk exports.

## `maxPagesPerPost` (type: `integer`):

Maximum provider pagination pages to request per post. Defaults to 20. Each provider page usually returns around 15 comments. Not a comment limit, use maxComments for that.

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

Choose which managed public-data API is tried first. ScrapeCreators is the recommended primary and SociaVault is the fallback. Use single-provider modes only for debugging provider-specific behavior.

## `initialCursor` (type: `string`):

Optional provider cursor for continuing a previous single-post run. Use the nextCursor from RUN\_SUMMARY. Only applies when exactly one target URL is supplied.

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

Compact returns clean comment rows for AI agents and spreadsheets. Detailed includes raw provider fragments when includeRawData is enabled or detailed mode is selected. Defaults to compact.

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

Attach the raw provider comment object to each dataset row for debugging custom fields. Defaults to false because raw payloads increase dataset size and token usage.

## Actor input object example

```json
{
  "postUrls": [
    "https://www.instagram.com/reel/DOq6eV6iIgD/"
  ],
  "startUrls": [
    {
      "url": "https://www.instagram.com/reel/DOq6eV6iIgD/"
    }
  ],
  "maxComments": 100,
  "maxPagesPerPost": 20,
  "providerOrder": "scrapecreators-first",
  "outputMode": "compact",
  "includeRawData": false
}
```

# Actor output Schema

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

Dataset API URL for saved Instagram comment rows.

## `runSummary` (type: `string`):

Per-target status summary and provider diagnostics.

# 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 = {
    "postUrls": [
        "https://www.instagram.com/reel/DOq6eV6iIgD/"
    ],
    "startUrls": [
        {
            "url": "https://www.instagram.com/reel/DOq6eV6iIgD/"
        }
    ],
    "maxComments": 100,
    "maxPagesPerPost": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("khadinakbar/instagram-comments-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 = {
    "postUrls": ["https://www.instagram.com/reel/DOq6eV6iIgD/"],
    "startUrls": [{ "url": "https://www.instagram.com/reel/DOq6eV6iIgD/" }],
    "maxComments": 100,
    "maxPagesPerPost": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("khadinakbar/instagram-comments-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 '{
  "postUrls": [
    "https://www.instagram.com/reel/DOq6eV6iIgD/"
  ],
  "startUrls": [
    {
      "url": "https://www.instagram.com/reel/DOq6eV6iIgD/"
    }
  ],
  "maxComments": 100,
  "maxPagesPerPost": 20
}' |
apify call khadinakbar/instagram-comments-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

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