# Instagram Comment Scraper (`crawlerbros/instagram-comment-scraper`) Actor

Extract comments from Instagram posts and reels with complete metadata including replies, likes, and author details. Features smart pagination, reply threading, and safe browser automation.

- **URL**: https://apify.com/crawlerbros/instagram-comment-scraper.md
- **Developed by:** [Crawler Bros](https://apify.com/crawlerbros) (community)
- **Categories:** Social media, Other, Developer tools
- **Stats:** 126 total users, 11 monthly users, 100.0% runs succeeded, 3 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $5.00 / 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.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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 Comment Scraper

Scrape comments from any Instagram post or reel with complete metadata — author info, likes, reply threading, timestamps, mentions, hashtags, and media attachments. Supports both `/p/` post URLs and `/reel/` URLs. Handles all comment types including text, images, GIFs, stickers, and shared reels.

### What this actor does

- **Posts & Reels** — Works with both `/p/` and `/reel/` Instagram URL formats
- **Full comment metadata** — Text, author details, likes, timestamps, mentions, hashtags, edit status
- **Reply threading** — Expands nested reply threads and links each reply back to its parent comment and author
- **Smart pagination** — Automatically fetches all available comment pages up to your configured limit
- **Media comments** — Detects and labels image, video, reel, GIF, and sticker comments with readable placeholders when URLs are unavailable
- **Multiple posts** — Process a batch of URLs in a single run
- **Reliable** — Built-in retry logic and automatic managed session rotation

### Authentication

This actor requires Instagram session cookies to access post comments (Instagram does not expose comment data to logged-out users). You can either:

1. **Paste your own cookies** — export from a logged-in browser session using a tool such as [Cookie-Editor](https://cookie-editor.cgagnier.ca/) and paste the JSON into the `cookies` field.
2. **Leave the cookies field blank** — the actor will automatically use a managed pool of shared Instagram sessions. This is the recommended option for most users.

If your cookies expire mid-run, re-export them from your browser and restart the actor.

### Output per comment record

**Always present**

- `commentId` — unique numeric identifier for the comment
- `text` — comment text; media-only comments show a readable placeholder such as `[Image]`, `[GIF:id]`, `[Reel: url]`, or `[Photo unavailable]`
- `commentType` — content type: `text`, `image`, `video`, `reel`, `photo_share`, `album_share`, `gif`, `sticker`
- `isGif` — `true` if the comment is a GIF reaction
- `authorUsername` — Instagram handle of the commenter
- `authorId` — numeric Instagram user ID of the commenter
- `authorIsVerified` — `true` if the commenter has a blue verification badge
- `authorProfilePic` — CDN URL of the commenter's profile picture
- `timestamp` — when the comment was posted (ISO 8601)
- `likesCount` — number of likes on the comment
- `replyCount` — number of replies to this comment
- `isReply` — `true` if this is a reply to another comment
- `isEdited` — `true` if the comment was edited after posting
- `mentions` — list of @mentioned usernames extracted from the comment text
- `hashtags` — list of #hashtags extracted from the comment text
- `postUrl` — URL of the Instagram post being scraped
- `postShortcode` — short alphanumeric identifier of the source post
- `commentUrl` — direct URL to this specific comment
- `scrapedAt` — ISO 8601 timestamp of when the record was collected

**Present only for replies**

- `parentCommentId` — ID of the top-level comment this reply belongs to
- `parentCommentAuthor` — username of the top-level comment author

**Present when a media URL is available**

- `mediaUrl` — CDN URL of the attached media file; currently only populated for GIF comments, where Instagram's API returns a direct link

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `postUrls` | array | required | Instagram post or reel URLs to scrape |
| `maxCommentsPerPost` | integer | `100` | Max comments per post, up to 10000 |
| `includeReplies` | boolean | `true` | Expand and include reply threads |
| `maxRepliesPerComment` | integer | `0` | Max replies to fetch per individual comment thread. `0` = unlimited. Applied to every thread when `includeReplies` is `true` |
| `cookies` | string | — | Instagram cookies in JSON format. Leave blank to use the managed session pool |
| `sessionName` | string | — | Key-value store key for a previously saved session (advanced use) |

#### Example: scrape comments from a single post

```json
{
  "postUrls": ["https://www.instagram.com/p/ABC123xyz/"],
  "maxCommentsPerPost": 100,
  "includeReplies": true,
  "maxRepliesPerComment": 20
}
```

#### Example: multiple posts, top-level comments only

```json
{
  "postUrls": [
    "https://www.instagram.com/p/ABC123xyz/",
    "https://www.instagram.com/reel/DEF456uvw/"
  ],
  "maxCommentsPerPost": 200,
  "includeReplies": false
}
```

#### Example: large crawl with your own cookies

```json
{
  "postUrls": ["https://www.instagram.com/p/ABC123xyz/"],
  "maxCommentsPerPost": 10000,
  "includeReplies": true,
  "maxRepliesPerComment": 50,
  "cookies": "[{\"name\":\"sessionid\",\"value\":\"YOUR_SESSION_ID\",...}]"
}
```

### Example output

```json
{
  "commentId": "17843670504683182",
  "text": "Congrats! 🎉 @friendname check this out",
  "commentType": "text",
  "isGif": false,
  "authorUsername": "user123",
  "authorId": "427553890",
  "authorIsVerified": false,
  "authorProfilePic": "https://scontent.cdninstagram.com/...",
  "timestamp": "2025-05-01T14:32:10",
  "likesCount": 12,
  "replyCount": 3,
  "isReply": false,
  "isEdited": false,
  "mentions": ["friendname"],
  "postUrl": "https://www.instagram.com/p/ABC123xyz/",
  "postShortcode": "ABC123xyz",
  "commentUrl": "https://www.instagram.com/p/ABC123xyz/c/17843670504683182/",
  "scrapedAt": "2025-12-04T13:06:03.499460"
}
```

### Media comment limitation

Instagram's web API withholds the direct CDN URL for most attached media (image, video, reel) and only returns a placeholder string (e.g. `"Photo unavailable"`) or, in some cases, no field at all — GIF comments are the exception, where a real CDN URL is available.

| Situation | `text` field | `mediaUrl` |
|---|---|---|
| Regular text comment | Full comment text | — |
| Image comment (web API restricted) | `[Photo unavailable]` or `[Image]` | — |
| Reel/video comment (web API restricted) | `[Reel unavailable]` or `[Video unavailable]` | — |
| GIF (Giphy) comment | `[GIF:id]` | CDN URL ✓ |
| Shared reel or post | `[Reel: url]` or `[Post: url]` | — |

The `commentType` field is always set (`image`, `video`, `reel`, `gif`, etc.) so you can identify what kind of media was attached even when no URL is available. Comments with no text and no matching media field from Instagram default to `commentType: "image"`, since that's the most common cause of this pattern.

### Use cases

- **Sentiment analysis** — collect comment text at scale to understand audience reaction to a post or campaign
- **Community moderation** — monitor comments on your own posts to identify spam, toxicity, or rule violations
- **Influencer research** — analyse engagement quality on an influencer's posts before signing a collaboration
- **Competitor benchmarking** — compare comment volume and engagement patterns across competing accounts
- **Trend detection** — track which topics and hashtags are being mentioned in comments on viral posts
- **Lead generation** — identify users who have commented on relevant posts in your niche
- **Content research** — see what questions and feedback audiences leave on posts similar to yours

### FAQ

**Do I need an Instagram account to use this actor?**
The actor accesses Instagram as a logged-in user because comment data is not fully accessible to logged-out visitors. You can either provide your own cookies or leave the field blank and use the built-in managed session pool.

**Will this work on private accounts?**
Comments on private posts are only accessible if the session used belongs to an account that follows the private profile. If the session does not follow the account, the actor will return zero comments for that post.

**How many comments can I scrape per run?**
Up to 10000 comments per post — set `maxCommentsPerPost` accordingly. Unlimited scraping isn't supported, so very popular posts with more comments than that will be capped at the first 10000.

**What does `maxRepliesPerComment` control?**
When `includeReplies` is `true`, replies are fetched for every comment thread that has them. `maxRepliesPerComment` caps how many replies are returned per individual thread — for example, `5` means at most 5 replies per parent comment. Set it to `0` (the default) to fetch all replies for every thread.

**Why do some comments show `[Photo unavailable]` instead of an image?**
Instagram's web API withholds media file URLs for certain comment types and only returns a placeholder string. The `commentType` field will still show `image` so you know a media comment was present. See the [Media comment limitation](#media-comment-limitation) section for full details.

**How fresh is the data?**
Data is scraped live at the time of the run. Comments reflect the current state of the post at the moment of scraping.

**Is this actor affiliated with Instagram or Meta?**
No. This is an independent third-party tool that automates interaction with the public Instagram website. It is not endorsed by or affiliated with Meta Platforms, Inc.

### Other Instagram Scrapers

Want to get other data from Instagram? Check out our complete suite of Instagram scrapers:

| Actor | Description |
|---|---|
| [Instagram Post Scraper](https://apify.com/crawlerbros/instagram-post-scraper) | Scrape public posts, reels, IGTV, and carousel posts from direct URLs — no login or cookies required |
| [Instagram Profile Scraper](https://apify.com/crawlerbros/instagram-profile-scraper) | Extract profile data, bio, follower counts, and more |
| [Instagram Followers & Following Scraper](https://apify.com/crawlerbros/instagram-follower-scraper) | Scrape followers and following lists from any profile |
| [Instagram Tagged Posts Scraper](https://apify.com/crawlerbros/instagram-tagged-posts-scraper) | Collect posts where a user has been tagged |
| [Instagram Hashtag Scraper](https://apify.com/crawlerbros/instagram-hashtag-scraper) | Scrape posts and profiles by hashtag |
| [Instagram Story Downloader](https://apify.com/crawlerbros/instagram-story-downloader) | Download stories from Instagram profiles |
| [Instagram Downloader API](https://apify.com/crawlerbros/instagram-downloader-api) | Download photos, videos, and reels from Instagram |
| [Instagram Keyword Scraper](https://apify.com/crawlerbros/instagram-keyword-scraper) | Search and scrape posts by keyword |
| [Instagram Keyword Search Scraper](https://apify.com/crawlerbros/instagram-keyword-search-scraper) | Search Instagram accounts and posts by keyword |
| [Instagram Transcript Scraper](https://apify.com/crawlerbros/instagram-transcript-scraper) | Extract transcripts from Instagram video content |

# Actor input Schema

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

List of Instagram post or reel URLs to scrape comments from. Supports formats: /p/, /reel/, /tv/, /share/, or direct shortcodes.

## `maxCommentsPerPost` (type: `integer`):

Maximum number of comments to scrape per post, up to 10000. Higher values may take longer.

## `includeReplies` (type: `boolean`):

Include comment replies (nested comments). Enabling this will expand reply threads.

## `maxRepliesPerComment` (type: `integer`):

Maximum number of replies to fetch per individual comment thread (when Include Replies is enabled). For example, 5 means at most 5 replies are returned per parent comment. Set to 0 for unlimited replies per thread.

## `cookies` (type: `string`):

Instagram authentication cookies in JSON format. Optional — if not provided, authentication is handled automatically. Format: \[{"name":"sessionid","value":"...","domain":".instagram.com"}, ...]

## `sessionName` (type: `string`):

If you've saved cookies to key-value storage, enter the session name here instead of pasting cookies.

## Actor input object example

```json
{
  "postUrls": [
    "https://www.instagram.com/p/ABC123xyz/",
    "https://www.instagram.com/reel/DEF456uvw/"
  ],
  "maxCommentsPerPost": 100,
  "includeReplies": true,
  "maxRepliesPerComment": 0,
  "cookies": "[{\"name\":\"sessionid\",\"value\":\"your_session_id\",\"domain\":\".instagram.com\",\"path\":\"/\",\"secure\":true,\"httpOnly\":true}]"
}
```

# Actor output Schema

## `comments` (type: `string`):

One dataset item per comment or reply. Includes text, author details, likes, timestamps, media attachments, reply threading, mentions, and hashtags.

# 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/p/DRaAMuaiTZR/"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("crawlerbros/instagram-comment-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/p/DRaAMuaiTZR/"] }

# Run the Actor and wait for it to finish
run = client.actor("crawlerbros/instagram-comment-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/p/DRaAMuaiTZR/"
  ]
}' |
apify call crawlerbros/instagram-comment-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/FrgUpisckX7vGO1fL/builds/8PXU51qDre8G0TOXB/openapi.json
