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

Scrape comments from public Instagram posts and reels: text, author, likes, time. Works without login for about 15 comments per post; add your own cookies to request more comments and replies.

- **URL**: https://apify.com/muhammad_noman_riaz/instagram-comments-super-scraper.md
- **Developed by:** [Muhammad Noman Riaz](https://apify.com/muhammad_noman_riaz) (community)
- **Categories:** Automation, Developer tools, Social media
- **Features:** Limited permissions
- **Stats:** 99 total users, 0 monthly users, 100.0% runs succeeded, 2 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $2.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Instagram Comments Scraper

Get the comments of public Instagram posts and reels: comment text, author username and ID, profile picture, likes, reply count and time posted.

**Do you need cookies?** No, not to start.

- **Without cookies** you get the first page of top-level comments that Instagram shows to logged-out visitors, which is about 15 comments per post. Replies are not included.
- **With cookies** from your own Instagram account the scraper can page through more comments and fetch replies (up to your limits).

### What you get

| Field | Description |
|-------|-------------|
| `postUrl` | The post or reel the comment belongs to |
| `commentUrl` | Direct link to the comment |
| `id` | Comment ID |
| `text` | Comment text |
| `ownerUsername`, `ownerProfilePicUrl` | Who wrote it |
| `timestamp` | When it was posted (ISO 8601) |
| `likesCount` | Likes on the comment |
| `repliesCount`, `replies` | Reply count and replies (replies only with cookies) |
| `parentCommentId` | Only on replies |
| `owner` | Author details: `id`, `username`, `is_verified`, `profile_pic_url`; with cookies also `full_name`, `fbid_v2`, `is_private` |

Example item:

```json
{
  "postUrl": "https://www.instagram.com/p/CJWTsUMjjiM/",
  "commentUrl": "https://www.instagram.com/p/CJWTsUMjjiM/c/18030198328749378",
  "id": "18030198328749378",
  "text": "Amazing post!",
  "ownerUsername": "user123",
  "ownerProfilePicUrl": "https://...",
  "timestamp": "2024-03-10T13:24:37.000Z",
  "repliesCount": 0,
  "replies": [],
  "likesCount": 1,
  "owner": {
    "fbid_v2": "",
    "full_name": "",
    "id": "48544088177",
    "is_mentionable": true,
    "is_private": false,
    "is_verified": false,
    "latest_reel_media": 0,
    "profile_pic_id": "573323465",
    "profile_pic_url": "https://...",
    "username": "user123"
  }
}
```

Only posts that return comments are saved and charged. Posts that fail (removed, private, no comments, rejected cookies) are listed with the reason in `FAILED_ITEMS` in the run's key-value store.

### Input

| Parameter | Type | Description | Default |
|-----------|------|-------------|---------|
| `directUrls` | Array | Instagram post or reel URLs | Required |
| `resultsLimit` | Integer | Max comments per post (0 = no limit) | 50 |
| `includeReplies` | Boolean | Include replies (needs cookies) | true |
| `maxRepliesPerComment` | Integer | Max replies per comment | 10 |
| `cookies` | Array | Optional Instagram cookies, see below | None |
| `proxy` | Object | Proxy for runs without cookies | Apify residential |

```json
{
  "directUrls": [
    "https://www.instagram.com/p/CJWTsUMjjiM/",
    "https://www.instagram.com/reel/DDIJAfeyemG/"
  ],
  "resultsLimit": 100,
  "includeReplies": true,
  "maxRepliesPerComment": 20
}
```

Without cookies the proxy matters: Instagram often shows a login wall to datacenter IPs, so residential proxies work best. With cookies, requests go out without the proxy so your account keeps one IP.

### How to get your Instagram cookies

1. Use a secondary Instagram account, not your main one. Scraping can get an account rate-limited or asked to verify itself.
2. In Chrome or Edge, log in to that account at https://www.instagram.com.
3. Press F12 to open developer tools.
4. Open the **Application** tab, then **Storage**, then **Cookies**, then **https://www.instagram.com**.
5. Copy the values of `sessionid`, `ds_user_id` and `csrftoken`.
6. Put them in one line in this format: `sessionid=...; ds_user_id=...; csrftoken=...`
7. Paste that line into the **Instagram cookies** field as a list item, for example `["sessionid=...; ds_user_id=...; csrftoken=..."]`.

Or, easier:

1. Install the **Cookie-Editor** browser extension.
2. Open https://www.instagram.com while logged in to your secondary account.
3. Click the Cookie-Editor icon, then **Export**, then **Export as JSON**.
4. Paste the result into the **Instagram cookies** field as is.

To rotate several accounts, add one entry per account, for example `["sessionid=...; ds_user_id=...; csrftoken=...", "sessionid=...; ds_user_id=...; csrftoken=..."]`, or a list of Cookie-Editor exports.

Good to know:

- **Cookies work like a password.** Anyone who has them can act as that account. Only paste them into this field.
- **Apify stores this field encrypted**, and the scraper never writes cookie values to the log.
- **Cookies expire.** When that happens, log in again and copy them again.
- **Heavy use can rate-limit the account.** Keep limits reasonable and spread work over several accounts.
- **To revoke them**, change the account password, or in Instagram open Settings, Accounts Center, Password and security, Where you're logged in, and log out of all sessions.

### FAQ

#### Do I need cookies?

No. Without cookies you get about 15 top-level comments per post and no replies. Add cookies when you need more comments or replies.

#### Why did my run fail with expired cookies?

The message "Your Instagram cookies expired or were rejected; refresh them" means Instagram answered with a login page, a 401, `login_required` or `checkpoint_required`. The session was logged out, expired or needs a security check. Log in to the account in your browser, clear any check Instagram shows, then copy fresh cookies. If you gave several sessions, the rejected one is dropped and the others keep working.

#### Is my account safe?

Use a secondary account. Instagram can rate-limit or challenge any account that loads many pages quickly, and that is outside this scraper's control. The cookies field is stored encrypted and its values are never logged.

#### How many comments can I get?

Without cookies, about 15 per post: the first page Instagram shows to logged-out visitors. With cookies, up to `resultsLimit` per post (0 means no limit), plus up to `maxRepliesPerComment` replies per comment.

### Notes

- Only comments on public posts and reels can be scraped.
- Use the data in line with Instagram's terms and data protection laws (GDPR, CCPA and others).

# Actor input Schema

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

Instagram post or reel URLs to scrape comments from (e.g., https://www.instagram.com/p/ABC123/)

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

Maximum number of comments to extract per post (0 = unlimited). Without cookies Instagram shows only about 15 top-level comments per post, whatever this is set to.

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

Whether to include comment replies in the output. Replies need cookies; without cookies no replies are returned.

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

Maximum number of replies to extract per comment (0 = unlimited)

## `cookies` (type: `array`):

Optional. Without cookies you get about 15 top-level comments per post and no replies. With cookies the scraper can page through all comments and replies. Paste one or more sessions: either a text like "sessionid=...; ds_user_id=...; csrftoken=..." or the JSON exported by the Cookie-Editor extension. Use a secondary account. See "How to get your Instagram cookies" in the README.

## `proxy` (type: `object`):

Proxy used only when no cookies are given. Instagram often shows a login wall to datacenter IPs, so residential proxies work best. Requests with cookies go out directly so the account keeps one IP.

## Actor input object example

```json
{
  "directUrls": [
    "https://www.instagram.com/p/CJWTsUMjjiM/",
    "https://www.instagram.com/reel/DDIJAfeyemG/"
  ],
  "resultsLimit": 50,
  "includeReplies": true,
  "maxRepliesPerComment": 10,
  "proxy": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

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

The dataset containing all scraped Instagram comments

# 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 = {
    "directUrls": [
        "https://www.instagram.com/p/CJWTsUMjjiM/"
    ],
    "proxy": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("muhammad_noman_riaz/instagram-comments-super-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 = {
    "directUrls": ["https://www.instagram.com/p/CJWTsUMjjiM/"],
    "proxy": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
    },
}

# Run the Actor and wait for it to finish
run = client.actor("muhammad_noman_riaz/instagram-comments-super-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 '{
  "directUrls": [
    "https://www.instagram.com/p/CJWTsUMjjiM/"
  ],
  "proxy": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}' |
apify call muhammad_noman_riaz/instagram-comments-super-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,muhammad_noman_riaz/instagram-comments-super-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/1Y7KDag9BpKkDcrWn/builds/gisdOQ2NukHYGkA3o/openapi.json
