# Instagram Reels Engagement Scraper (`dwi_wahyu/instagram-reels-engagement-scraper`) Actor

Collects engagement metrics (views, likes, shares, saves, and publisher username) for Instagram Reels.

- **URL**: https://apify.com/dwi_wahyu/instagram-reels-engagement-scraper.md
- **Developed by:** [Dwi Wahyu](https://apify.com/dwi_wahyu) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

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

## 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 Reels Engagement Scraper

An Apify Actor built in TypeScript with the Apify SDK and Crawlee that collects engagement metrics for Instagram Reels.

### Features & Scope

Accepts one or more Instagram Reel URLs (`https://www.instagram.com/reel/<id>/` or `/reels/<id>/`) and returns strictly the following engagement metrics per Reel:

- **`publisherUsername`** — Account username of the Reel creator
- **`views`** — Video view / play count
- **`likes`** — Like count
- **`shares`** — Share / reshare count (`null` when not publicly available)
- **`saves`** — Save / bookmark count (`null` when not publicly available)

#### Strict Scope Guarantees

- **No extraneous data**: Does not scrape or store captions, comments, audio tracks, hashtags, or media files.
- **No fabricated numbers**: Any metric that is not publicly available or is hidden by the creator is returned as `null` — values are never estimated or guessed.
- **URL normalization & deduplication**: Strips query parameters, hash fragments, and trailing slashes (`https://www.instagram.com/reel/<id>`), deduplicating repeated Reel URLs in a single run.
- **Every input accounted for**: Invalid URLs (non-Instagram domains, profile links, regular `/p/` posts, stories) or deleted/private Reels do not crash the run — they produce a structured dataset item with a descriptive `error` field and `null` metrics.

***

### Input

The Actor input is defined in [`.actor/input_schema.json`](./.actor/input_schema.json) (and [`INPUT_SCHEMA.json`](./INPUT_SCHEMA.json)):

| Field | Type | Required | Default | Description |
| :--- | :--- | :---: | :---: | :--- |
| `reelUrls` | `string[]` | Yes | — | One or more Instagram Reel URLs (`https://www.instagram.com/reel/<id>/` or `/reels/<id>/`). |
| `proxyConfiguration` | `object` | No | `{ "useApifyProxy": true }` | Apify Proxy configuration. Use Residential proxies if plain requests are blocked or rate-limited. |
| `maxConcurrency` | `integer` | No | `4` | Number of Reel URLs processed in parallel (`1`–`10`). |
| `sessionCookie` | `string` (secret) | No | — | Optional Instagram `sessionid` cookie value if login is required for restricted targets. Encrypted and never logged or stored. |

#### Example Input

```json
{
    "reelUrls": [
        "https://www.instagram.com/reel/DQWxAjPjI32/",
        "https://www.instagram.com/reel/C5QuBSkux6R/",
        "https://www.instagram.com/reel/DTq4oW2kfPx/"
    ],
    "proxyConfiguration": {
        "useApifyProxy": true
    },
    "maxConcurrency": 4
}
```

***

### Output

The Actor stores one item per deduplicated Reel URL in the default Apify Dataset, rendered as a table in the Apify Console via [`.actor/dataset_schema.json`](./.actor/dataset_schema.json).

#### Output Schema

```json
{
    "reelUrl": "string",
    "publisherUsername": "string | null",
    "views": "number | null",
    "likes": "number | null",
    "shares": "number | null",
    "saves": "number | null",
    "scrapedAt": "ISO 8601 string",
    "error": "string | null"
}
```

#### Example Output

```json
[
    {
        "reelUrl": "https://www.instagram.com/reel/DQWxAjPjI32",
        "publisherUsername": "iammattjupp",
        "views": 2595,
        "likes": 99,
        "shares": null,
        "saves": null,
        "scrapedAt": "2026-10-18T14:55:00.000Z",
        "error": null
    },
    {
        "reelUrl": "https://www.instagram.com/reel/C5QuBSkux6R",
        "publisherUsername": "shinewithnatasha",
        "views": 1536,
        "likes": 150,
        "shares": null,
        "saves": null,
        "scrapedAt": "2026-10-18T14:55:01.000Z",
        "error": null
    },
    {
        "reelUrl": "https://www.instagram.com/reel/DTq4oW2kfPx",
        "publisherUsername": "itszachford",
        "views": 179,
        "likes": 6,
        "shares": null,
        "saves": null,
        "scrapedAt": "2026-10-18T14:55:02.000Z",
        "error": null
    },
    {
        "reelUrl": "https://www.instagram.com/p/INVALID_POST_URL/",
        "publisherUsername": null,
        "views": null,
        "likes": null,
        "shares": null,
        "saves": null,
        "scrapedAt": "2026-10-18T14:55:00.000Z",
        "error": "Invalid Instagram Reel URL: path must match /reel/<id>/ or /reels/<id>/."
    }
]
```

***

### How It Works

1. **Input Normalization & Deduplication**: Validates each URL against Instagram Reel path patterns (`/reel/<id>` and `/reels/<id>`), strips query strings and trailing slashes, and deduplicates URLs.
2. **Embedded JSON & GraphQL Extraction (Primary)**:
   - Fetches Instagram's embed endpoint (`/p/<id>/embed/captioned/`) and extracts the embedded `contextJSON` (`gql_data.shortcode_media`) and DOM metadata.
   - Queries the main Reel page (`/reel/<id>/`) and Instagram's GraphQL endpoint (`/graphql/query`) when additional fields are needed or when an optional `sessionCookie` is provided.
3. **Browser Fallback (Secondary)**:
   - Falls back to headless Puppeteer only if plain HTTP requests are blocked or fail to return embedded data.
4. **Retries with Exponential Backoff**:
   - Processes URLs in parallel (default concurrency `4`) and retries failed requests up to `3` times with exponential backoff.

***

### Local Development & Testing

```bash
## Install dependencies
npm install

## Run unit tests
npm test

## Build TypeScript
npm run build

## Run Actor locally using Apify CLI
apify run
```

***

### Deployment to Apify Platform

```bash
## 1. Authenticate with your Apify account
apify login

## 2. Deploy the Actor to the Apify platform
apify push
```

***

### Summary of Metric Availability

| Metric | Public Availability | Notes |
| :--- | :--- | :--- |
| `publisherUsername` | **Obtainable** | Extracted from `shortcode_media.owner.username`, Embed DOM, or OpenGraph/Twitter meta tags. |
| `views` | **Obtainable** | Extracted as exact integer from `shortcode_media.video_view_count` / `video_play_count` (`null` if hidden by creator). |
| `likes` | **Obtainable** | Extracted as exact integer from `shortcode_media.edge_liked_by.count` / `like_count` (`null` if hidden by creator). |
| `shares` | **Returns `null` publicly** | Instagram does not expose `reshare_count` publicly without creator/authenticated API access; returns `null` when unavailable. |
| `saves` | **Returns `null` publicly** | Instagram does not expose `save_count` publicly outside Instagram Insights; returns `null` when unavailable. |

# Actor input Schema

## `reelUrls` (type: `array`):

List of Instagram Reel URLs (e.g. https://www.instagram.com/reel/<id>/ or https://www.instagram.com/reels/<id>/) to collect views, likes, shares, saves, and publisher username for.

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

Apify Proxy settings. Residential proxies are recommended if plain requests are blocked by Instagram.

## `maxConcurrency` (type: `integer`):

Maximum number of Reel URLs to process in parallel (conservative default between 3 and 5).

## `sessionCookie` (type: `string`):

Optional Instagram 'sessionid' cookie value if authenticated access is needed. Stored encrypted and never logged.

## Actor input object example

```json
{
  "reelUrls": [
    "https://www.instagram.com/reel/DQWxAjPjI32/",
    "https://www.instagram.com/reel/C5QuBSkux6R/",
    "https://www.instagram.com/reel/DTq4oW2kfPx/"
  ],
  "proxyConfiguration": {
    "useApifyProxy": true
  },
  "maxConcurrency": 4
}
```

# 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 = {
    "reelUrls": [
        "https://www.instagram.com/reel/DQWxAjPjI32/",
        "https://www.instagram.com/reel/C5QuBSkux6R/",
        "https://www.instagram.com/reel/DTq4oW2kfPx/"
    ],
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("dwi_wahyu/instagram-reels-engagement-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 = {
    "reelUrls": [
        "https://www.instagram.com/reel/DQWxAjPjI32/",
        "https://www.instagram.com/reel/C5QuBSkux6R/",
        "https://www.instagram.com/reel/DTq4oW2kfPx/",
    ],
    "proxyConfiguration": { "useApifyProxy": True },
}

# Run the Actor and wait for it to finish
run = client.actor("dwi_wahyu/instagram-reels-engagement-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 '{
  "reelUrls": [
    "https://www.instagram.com/reel/DQWxAjPjI32/",
    "https://www.instagram.com/reel/C5QuBSkux6R/",
    "https://www.instagram.com/reel/DTq4oW2kfPx/"
  ],
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call dwi_wahyu/instagram-reels-engagement-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,dwi_wahyu/instagram-reels-engagement-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/ePMK4TRj7bUSXCfTn/builds/TZfma7cpzAFJXwEGj/openapi.json
