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

Turn public Instagram post and reel links into structured data. No login. One row per URL, with the caption, photos, video, likes, comment count, author, and audio. Works for photos, carousels, videos, and Reels.

- **URL**: https://apify.com/alien_force/instagram-comments-scraper.md
- **Developed by:** [Alien Force](https://apify.com/alien_force) (community)
- **Features:** Limited permissions
- **Stats:** 3 total users, 0 monthly users, 93.8% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / 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/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

### Overview

The **Instagram Comments Scraper** collects public comments from Instagram post and reel URLs. Paste `/p/` or `/reel/` links and get one dataset row per top-level comment, with the comment text, author, likes, and timestamp.

This actor does **not** log in and does **not** take profile usernames. Replies are not included: Instagram's logged-out comments query returns top-level comments only, and it leaves the reply count empty.

#### Key Features

- **Post URL input**: Accepts `/p/`, `/reel/`, `/reels/`, `/tv/`, and `instagram.com/{user}/p|reel/{code}` links.
- **Pagination**: Follows the public comments cursor until the requested limit, or until Instagram says there is no next page.
- **Per-post limit**: `maxComments` caps each post. Set it to `0` to collect every top-level comment.
- **Author details**: Username, user ID, verified flag, profile URL, and profile picture.
- **Proxy support**: Datacenter proxies by default; switch to residential if Instagram starts blocking.
- **Fast and lightweight**: HTTP fetch with browser TLS impersonation. No login.

***

### Input Schema

#### Input Properties

1. **`startUrls`** (required)

   - **Type**: `array`
   - **Description**: Public Instagram post or reel URLs.
   - **Example**:
     ```json
     [
         { "url": "https://www.instagram.com/reel/DffMLSDhUm6/" }
     ]
     ```

2. **`maxComments`**

   - **Type**: `integer`
   - **Default**: `100`
   - **Description**: Maximum number of top-level comments to save for each post. `0` collects every top-level comment the public query returns.

3. **`proxyConfiguration`**

   - **Type**: `object`
   - **Description**: Proxy settings for the run. Apify Proxy datacenter IPs are used by default. If Instagram starts returning empty pages, switch to the `RESIDENTIAL` group.

At least one `startUrls` entry must be a valid Instagram post or reel URL.

#### Input Example

```json
{
    "startUrls": [
        { "url": "https://www.instagram.com/reel/DffMLSDhUm6/" }
    ],
    "maxComments": 100,
    "proxyConfiguration": {
        "useApifyProxy": true
    }
}
```

***

### Output

One dataset row per comment.

| Field | Type | Description |
| --- | --- | --- |
| `inputUrl` | string | URL as given in the input |
| `postUrl` | string | Canonical post or reel URL |
| `postId` | string | Instagram media ID |
| `shortcode` | string | Shortcode from the URL |
| `commentId` | string | Comment ID |
| `commentUrl` | string | Permalink. Posts use `/p/{shortcode}/c/{id}/`, reels use `/reel/`, TV uses `/tv/` |
| `text` | string | Comment text |
| `createdAt` | integer | Comment time (Unix timestamp, seconds) |
| `likeCount` | integer | Likes on the comment |
| `replyCount` | integer | Replies. Logged-out responses usually leave this `null` |
| `authorId` | string | Comment author user ID |
| `authorUsername` | string | Comment author username |
| `authorVerified` | boolean | Verified comment author |
| `authorProfileUrl` | string | Comment author profile URL |
| `authorProfilePicUrl` | string | Comment author profile picture |
| `parentCommentId` | string | Parent comment ID when the row is a reply. Top-level comments are `null` |
| `scrapedAt` | string | When the comment was scraped |

The post's own comment count can be higher than the number of rows. That count includes replies, and this actor only receives top-level comments.

Profile picture URLs expire. Treat `authorProfilePicUrl` as short-lived.

#### Handling of missing and blocked inputs

Inputs that yield no comments are kept out of the dataset and reported in the **`RUN_REPORT`** record in the run's key-value store, alongside a warning in the log. Each entry lists the original `input`, the resolved `postUrl` and `shortcode`, a `reason`, and a human-readable `message`.

- **No comments**: skipped as `noComments`.
- **Comments turned off**: skipped as `commentsDisabled`.
- **Private or gated post**: skipped as `empty`.
- **Deleted / missing post**: skipped as `notFound`.
- **Input without a usable shortcode**: skipped as `invalidInput`. If *no* input yields a post URL, the run fails with an input error.
- **Blocked request**: automatically retried. If every retry fails, the input is skipped as `requestFailed`. A run where *all* targets were blocked fails with a clear message.

The run's status message always reports how many comments were scraped and how many inputs were skipped.

# Actor input Schema

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

Public Instagram post or reel URLs, for example https://www.instagram.com/reel/DffMLSDhUm6/ or https://www.instagram.com/p/Cs9iEotsiGY/.

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

Maximum number of top-level comments to save for each post. Set to 0 to collect every top-level comment the public query returns. Replies are not included.

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

Select proxies to be used by your crawler. Datacenter proxies are used by default; switch to RESIDENTIAL if Instagram starts blocking requests.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://www.instagram.com/reel/DffMLSDhUm6/"
    }
  ],
  "maxComments": 100,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `overview` (type: `string`):

No description

# 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 = {
    "startUrls": [
        {
            "url": "https://www.instagram.com/reel/DffMLSDhUm6/"
        }
    ],
    "maxComments": 100,
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("alien_force/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 = {
    "startUrls": [{ "url": "https://www.instagram.com/reel/DffMLSDhUm6/" }],
    "maxComments": 100,
    "proxyConfiguration": { "useApifyProxy": True },
}

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

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,alien_force/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/pmPLSz1ejrO01YIiK/builds/9r7BT7d86GQSfhl7C/openapi.json
