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

Download the OpenAPI definition: https://api.apify.com/v2/actors/LWTfNp8norel7Oehr/builds/tOCIzA0hND6HAUuxb/openapi.json
