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

Scrape Instagram comments from public posts and reels. Exact total comment count on every result, nested replies included, honest guest-visibility reporting.

- **URL**: https://apify.com/cravl/instagram-comments-scraper.md
- **Developed by:** [Cravl](https://apify.com/cravl) (community)
- **Categories:** Social media
- **Features:** Limited permissions
- **Stats:** 86 total users, 2 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.71 / 1,000 comments

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

Scrape comments from public Instagram posts and reels: with the **exact total comment count** stated on every result, not just the subset that could be fetched.

### What you get

**Per post/reel: one header item:**

| Field | Meaning |
|---|---|
| `commentCountExact` | The post's **true total comment count** (from Instagram's own counter) |
| `guestVisibleCount` | How many comments are visible without login (what this run fetched) |
| `guestHasMore` | `true` when the exact total exceeds the guest-visible count: stated honestly, never silently truncated |
| `owner`, `likes`, `postDate`, `caption`, `kind` | Post context |

**Per comment: one item each:**
`pk`, `user`, `verified`, `text`, `createdAt` (unix timestamp), `likes`, `childCount` (nested reply count), plus `url` and `postOwner` for joining.

### Features

- **Nested replies included by default**: every comment carries its `childCount`.
- **Exact totals on every post**: know what you're getting, including on viral threads with tens of thousands of comments.
- **Guest-mode extraction**: no login, no cookies, no account. Comments are those visible to logged-out users (we tell you when the remainder is login-only instead of pretending).
- **Cheap runs**: the engine is a ~30 MB native binary, not a full browser.

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `directUrls` | array |: | Post or reel URLs (`/p/CODE/`, `/reel/CODE/`, or username-prefixed forms; `/reels/` is normalized automatically) |
| `apiPages` | integer | `5` | Guest pagination pages per post (12 comments/page). Higher = deeper threads. |
| `resultsLimit` | integer | `0` | Max comments per post. `0` = all guest-visible comments. |
| `proxyConfiguration` | object |: | **Residential proxies strongly recommended.** Instagram guest access requires an exit IP with guest reputation. |

### Output

One **header item** per URL (post metadata + exact/guest-visible counts), followed by one item per comment. Error items carry an honest `error` field (e.g. login wall on that exit IP) instead of silent truncation.

### Notes

- Only **public** posts/reels are supported. Login-walled or deleted posts produce an explicit error item.
- Comment counts drift live (Instagram counts in real time); `commentCountExact` is the count at fetch time.
- Requires a proxy exit IP with Instagram guest reputation: residential proxies recommended.

### Pricing

Pay-per-event: you are charged per comment item delivered. The post header (with the exact total) is not charged.

### Migrating from other Apify Actors

Cravl Actors accept Apify-style inputs and emit familiar field names alongside Cravl-specific fields, so most pipelines migrate with minimal changes.

#### Input compatibility

- `startUrls` (array of URLs, or objects with a `url` key) is accepted as an alias for `directUrls`.
- `maxItems` is accepted as an alias for `resultsLimit`.
- `includeHeader` (boolean, default true) controls the header item. Set false to emit only comment items.

#### Output compatibility

| Cravl field | Compatible alias | Notes |
|---|---|---|
| header `owner` | `ownerUsername` | |
| header `commentCountExact` | `commentsCount` | |
| header `likes` | `likesCount` | numeric when parseable |
| (new) | `shortCode` | derived from the post URL |
| comment `pk` | `commentId` | |
| comment `user` | `ownerUsername` | |
| comment `createdAt` (unix) | `timestamp` | ISO 8601 |
| comment `likes` | `likesCount` | |
| comment `childCount` | `repliesCount` | |
| comment `url` | `postUrl` | |

Structure: one header item per URL (record `post`) followed by one item per comment (record `comment`). Every item carries `inputUrl`.

#### Limitations

- Extraction runs in guest mode: results reflect what the source displays to logged-out visitors. Where the source reports a total (for example, a comment count), results state both the returned count and the source total, so partial visibility is always explicit.
- Extraction depends on the reputation of the exit IP with the source. A run may occasionally return an explicit error item for a URL; re-running typically succeeds.
- Instagram rate-limits per IP. For very large runs (hundreds of URLs), split the input into batches for best throughput.

#### Changelog

- **0.1.24** — Every header record now carries `commentsApiStatus` and `commentsApiStatusReason` (also added to the dataset schema), so the dataset itself proves the distinction between a confirmed empty and a failed fetch: `ok` = guest comments collected; `empty` = pagination ran and the source confirmed zero guest-visible comments; `unavailable` = pagination failed or could not run, always paired with an `error` item. Callers reading only `guestVisibleCount: 0` can now check `commentsApiStatus` instead of inferring.
- **0.1.23** — Dataset schema fix: `guestHasMore` in the post summary is nullable (`null` = source did not confirm pagination state). Previously a non-nullable schema rejected the fixed wrapper's indeterminate records.
- **0.1.22** — Silent-zero fix. The engine now reports comment pagination status for every post/reel fetch and reports `guestHasMore: false` only when the source confirmed it; the wrapper classifies every fetch as ok / confirmed-empty / indeterminate / wall and emits an explicit `error` item for anything not confirmed. Before this build, a failed or indeterminate fetch could surface as a zero-comment header with no error. Confirmed empties (including posts whose page-level count includes deleted or hidden comments the guest API never returns) remain a distinct, non-error outcome.

# Actor input Schema

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

One or more Instagram post or reel URLs (e.g. https://www.instagram.com/reel/CODE/ or /p/CODE/). The /reels/ form is normalized automatically.

## `apiPages` (type: `integer`):

How many guest pagination pages to fetch per post (12 comments per page). Higher = deeper threads, slower run.

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

Cap comments per post. 0 = return every guest-visible comment.

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

Residential proxies recommended. Instagram guest access requires an exit IP with guest reputation. Extraction depends on exit-IP reputation with the source. See the Limitations section in the README.

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

Optional alias for directUrls, accepted for compatibility with common Apify Actor inputs. Items may be URLs or objects with a url key.

## `maxItems` (type: `integer`):

Optional alias for the primary result limit field. Accepted for compatibility with common Apify Actor inputs.

## `includeHeader` (type: `boolean`):

Emit one header item per URL with post metadata and exact totals. Set false to emit only comment items; each comment still carries the post-level counts.

## Actor input object example

```json
{
  "directUrls": [
    "https://www.instagram.com/reel/DdF953azYK1/"
  ],
  "apiPages": 5,
  "resultsLimit": 0,
  "includeHeader": true
}
```

# Actor output Schema

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

The default dataset contains one post summary per input URL followed by the comments visible to the guest session.

# 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/reel/DdF953azYK1/"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("cravl/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 = { "directUrls": ["https://www.instagram.com/reel/DdF953azYK1/"] }

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

```

## MCP server setup

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