# 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
- **Stats:** 3 total users, 2 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$1.00 / 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.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#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

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

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

## `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/yyjOQd47aT2LuOVrM/openapi.json
