# Instagram Profile Scraper (`mighty_monk/instagram-profile-scraper`) Actor

Extract public Instagram profile metadata and recent posts for creator research, influencer lists, and competitor social intel. Includes followers, bio, verification, and optional post captions/likes.

- **URL**: https://apify.com/mighty\_monk/instagram-profile-scraper.md
- **Developed by:** [Harsh](https://apify.com/mighty_monk) (community)
- **Categories:** Social media, Lead generation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 profile or post results

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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js/docs.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python/docs.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/integrations/mcp.md).

If your project is in a different language, use 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 Profile Scraper

**Extract public Instagram profile metadata and recent posts** for creator research, influencer lists, and competitor social intelligence. Built with **TypeScript**, **Crawlee CheerioCrawler** (HTTP-first, no browser), and multi-strategy extraction (meta tags, JSON-LD, embedded GraphQL/`_sharedData`, DOM).

Run it on the [Apify platform](https://apify.com) for scheduling, API access, **residential proxy rotation**, monitoring, and dataset exports (JSON, CSV, Excel).

> **Legal / ToS notice:** This Actor is intended for **publicly available data only**. Respect [Instagram Terms of Use](https://help.instagram.com/581066165581870), robots rules, and applicable privacy laws (GDPR/CCPA). Do not use this tool to scrape private content, bypass authentication, or harass users. You are responsible for how you use the data.

### What does Instagram Profile Scraper do?

Given usernames and/or profile URLs, this Actor:

1. Deduplicates usernames (from `usernames` + `profileUrls`)
2. Loads each public profile page over HTTP (Cheerio)
3. Extracts **profile details**: username, full name, bio, followers, following, posts count, verified/business/private flags, external URL, profile picture
4. Optionally extracts **recent posts**: shortcode, URL, caption, likes, comments, timestamp, video flag, display image
5. Handles private / blocked / not-found profiles **gracefully** (dataset row with `error`)
6. Pushes dataset items (`type: "profile"` and `type: "post"`)
7. Exports **PROFILES.csv** and **SUMMARY.md** to the key-value store

### Why use this Actor?

- **Influencer research** — build creator lists with follower counts and bios
- **Competitor social intel** — track public brand accounts and posting patterns
- **Lead generation** — collect public business profile metadata (external links)
- **Automation-ready** — JSON dataset + CSV export + Apify API / webhooks

### Proxy necessity (important)

**Instagram aggressively blocks scrapers**, especially datacenter IPs. For production runs:

| Setting | Recommendation |
| ------- | -------------- |
| Proxy | **Apify Proxy RESIDENTIAL** (default in input schema) |
| `maxConcurrency` | `1`–`2` |
| `requestDelayMs` | `1500`–`3000`+ |
| `maxRequestRetries` | `3`+ |

Without residential proxies you will often see login walls, empty shells, or HTTP 429/403. The Actor detects these and writes an `error` on the profile record instead of crashing.

### How to scrape Instagram profiles

1. Open the Actor in [Apify Console](https://console.apify.com)
2. Enter usernames (e.g. `natgeo`) and/or full profile URLs
3. Choose **results type**: `details`, `posts`, or `details_and_posts`
4. Keep **residential proxy** enabled
5. Click **Start**
6. Download results from the **Dataset** tab or key-value store (`PROFILES.csv`, `SUMMARY.md`)

### Input

| Field | Type | Default | Description |
| ----- | ---- | ------- | ----------- |
| `usernames` | string[] | `["natgeo","instagram"]` | Usernames without `@` |
| `profileUrls` | string[] | `[]` | Full profile URLs |
| `resultsType` | string | `"details"` | `details` \| `posts` \| `details_and_posts` |
| `resultsLimit` | integer | `12` | Max recent posts per profile |
| `maxConcurrency` | integer | `2` | Concurrent requests (keep low) |
| `maxRequestRetries` | integer | `3` | HTTP retry count |
| `requestDelayMs` | integer | `1500` | Used for rate limiting |
| `proxyConfiguration` | object | Residential on | Apify Proxy settings |

Example:

```json
{
    "usernames": ["natgeo", "instagram"],
    "profileUrls": [],
    "resultsType": "details",
    "resultsLimit": 12,
    "maxConcurrency": 2,
    "maxRequestRetries": 3,
    "requestDelayMs": 1500,
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": ["RESIDENTIAL"]
    }
}
````

See [`examples/input.json`](examples/input.json).

### Output

#### Profile record

```json
{
    "type": "profile",
    "username": "natgeo",
    "fullName": "National Geographic",
    "biography": "Experience the world through the eyes of National Geographic photographers.",
    "followers": 281000000,
    "following": 140,
    "postsCount": 28500,
    "isVerified": true,
    "isBusiness": true,
    "isPrivate": false,
    "externalUrl": "https://www.nationalgeographic.com/",
    "profilePicUrl": "https://…/profile.jpg",
    "profileUrl": "https://www.instagram.com/natgeo/",
    "scrapedAt": "2026-07-13T12:00:00.000Z",
    "error": null
}
```

#### Post record

```json
{
    "type": "post",
    "username": "natgeo",
    "shortcode": "CxAbc12345",
    "url": "https://www.instagram.com/p/CxAbc12345/",
    "caption": "A lion rests on the savanna at sunset. #wildlife",
    "likes": 450000,
    "comments": 3200,
    "timestamp": "2023-09-18T02:40:00.000Z",
    "isVideo": false,
    "displayUrl": "https://…/media.jpg",
    "profileUrl": "https://www.instagram.com/natgeo/",
    "scrapedAt": "2026-07-13T12:00:00.000Z",
    "error": null
}
```

#### Key-value store exports

| Key | Description |
| --- | ----------- |
| `PROFILES.csv` | CSV of all `type=profile` rows |
| `SUMMARY.md` | Markdown summary of profiles + sample posts |

### Extraction strategy

Instagram does not offer a stable public HTML API. This Actor tries, in order:

1. **Open Graph / meta description** — often includes follower/following/posts counts
2. **JSON-LD** (`ProfilePage` / `Person`) when present
3. **Embedded page JSON** — classic `window._sharedData`, GraphQL-like user objects, timeline media edges
4. **DOM fallbacks** — private badge, verified icon, `/p/{shortcode}` anchors

Optional JSON endpoints such as `?__a=1&__d=dis` are intentionally **not required**; they are frequently blocked. The HTML/embedded-JSON approach is more resilient for public profiles when combined with residential proxies.

### Limitations

- **Heavy blocking** — Instagram may return login walls, challenges, or empty app shells even with proxies
- **Public data only** — private accounts yield limited metadata and no posts
- **No login / no cookies** — this Actor does not authenticate as a user
- **No stories, reels feed, DMs, or full archive** — recent posts from the profile page only
- **Counts may be approximate** — meta descriptions sometimes use abbreviated figures (`281M`)
- **Layout changes** — Instagram changes markup frequently; extraction methods may need updates
- **Rate limits** — high concurrency will increase failures; prefer slow + residential
- **Compliance** — bulk scraping may violate platform ToS; use responsibly and for legitimate purposes

### Pricing

Charged via **Pay-per-event** on the primary dataset item (`apify-default-dataset-item`) at **$0.005 per profile or post result**, plus a small actor-start fee.

### Development

```bash
cd factory/instagram-profile-scraper
npm install
npm test
npm run build
## local run (needs APIFY_TOKEN for residential proxy):
apify run
```

Fixture-based unit and integration tests live in `test/` (no live Instagram calls required for CI).

### Changelog

#### 1.0.0

- Initial release: profile details + optional posts, CSV/Markdown export, residential proxy default, graceful private/block handling

### License

Apache-2.0

# Actor input Schema

## `usernames` (type: `array`):

Instagram usernames to scrape (without @). Combined with profileUrls and deduplicated.

## `profileUrls` (type: `array`):

Full Instagram profile URLs (e.g. https://www.instagram.com/natgeo/). Combined with usernames and deduplicated.

## `resultsType` (type: `string`):

What to extract: profile details only, recent posts only, or both.

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

Maximum number of recent posts to extract per profile when resultsType includes posts.

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

Maximum concurrent HTTP requests. Keep low (1–3) for Instagram; residential proxies strongly recommended.

## `maxRequestRetries` (type: `integer`):

How many times to retry a failed request before giving up.

## `requestDelayMs` (type: `integer`):

Approximate delay between requests used for rate limiting (max requests per minute).

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

Apify Proxy settings. RESIDENTIAL proxies are strongly recommended — Instagram blocks datacenter IPs aggressively.

## Actor input object example

```json
{
  "usernames": [
    "natgeo",
    "instagram"
  ],
  "profileUrls": [],
  "resultsType": "details",
  "resultsLimit": 12,
  "maxConcurrency": 2,
  "maxRequestRetries": 3,
  "requestDelayMs": 1500,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

## `dataset` (type: `string`):

No description

## `profilesCsv` (type: `string`):

No description

## `summary` (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 = {
    "usernames": [
        "natgeo",
        "instagram"
    ],
    "resultsType": "details"
};

// Run the Actor and wait for it to finish
const run = await client.actor("mighty_monk/instagram-profile-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 = {
    "usernames": [
        "natgeo",
        "instagram",
    ],
    "resultsType": "details",
}

# Run the Actor and wait for it to finish
run = client.actor("mighty_monk/instagram-profile-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "usernames": [
    "natgeo",
    "instagram"
  ],
  "resultsType": "details"
}' |
apify call mighty_monk/instagram-profile-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=mighty_monk/instagram-profile-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Instagram Profile Scraper",
        "description": "Extract public Instagram profile metadata and recent posts for creator research, influencer lists, and competitor social intel. Includes followers, bio, verification, and optional post captions/likes.",
        "version": "1.0",
        "x-build-id": "tOCIzA0hND6HAUuxb"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/mighty_monk~instagram-profile-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-mighty_monk-instagram-profile-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/mighty_monk~instagram-profile-scraper/runs": {
            "post": {
                "operationId": "runs-sync-mighty_monk-instagram-profile-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/mighty_monk~instagram-profile-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-mighty_monk-instagram-profile-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "usernames": {
                        "title": "Usernames",
                        "type": "array",
                        "description": "Instagram usernames to scrape (without @). Combined with profileUrls and deduplicated.",
                        "default": [
                            "natgeo",
                            "instagram"
                        ],
                        "items": {
                            "type": "string"
                        }
                    },
                    "profileUrls": {
                        "title": "Profile URLs",
                        "type": "array",
                        "description": "Full Instagram profile URLs (e.g. https://www.instagram.com/natgeo/). Combined with usernames and deduplicated.",
                        "default": [],
                        "items": {
                            "type": "string"
                        }
                    },
                    "resultsType": {
                        "title": "Results type",
                        "enum": [
                            "details",
                            "posts",
                            "details_and_posts"
                        ],
                        "type": "string",
                        "description": "What to extract: profile details only, recent posts only, or both.",
                        "default": "details"
                    },
                    "resultsLimit": {
                        "title": "Posts limit per profile",
                        "minimum": 1,
                        "maximum": 50,
                        "type": "integer",
                        "description": "Maximum number of recent posts to extract per profile when resultsType includes posts.",
                        "default": 12
                    },
                    "maxConcurrency": {
                        "title": "Max concurrency",
                        "minimum": 1,
                        "maximum": 10,
                        "type": "integer",
                        "description": "Maximum concurrent HTTP requests. Keep low (1–3) for Instagram; residential proxies strongly recommended.",
                        "default": 2
                    },
                    "maxRequestRetries": {
                        "title": "Max request retries",
                        "minimum": 0,
                        "maximum": 10,
                        "type": "integer",
                        "description": "How many times to retry a failed request before giving up.",
                        "default": 3
                    },
                    "requestDelayMs": {
                        "title": "Request delay (ms)",
                        "minimum": 0,
                        "maximum": 60000,
                        "type": "integer",
                        "description": "Approximate delay between requests used for rate limiting (max requests per minute).",
                        "default": 1500
                    },
                    "proxyConfiguration": {
                        "title": "Proxy configuration",
                        "type": "object",
                        "description": "Apify Proxy settings. RESIDENTIAL proxies are strongly recommended — Instagram blocks datacenter IPs aggressively.",
                        "default": {
                            "useApifyProxy": true,
                            "apifyProxyGroups": [
                                "RESIDENTIAL"
                            ]
                        }
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
