# Instagram Scraper (`thisismegant/instagram-scraper`) Actor

- **URL**: https://apify.com/thisismegant/instagram-scraper.md
- **Developed by:** [Megan Studios](https://apify.com/thisismegant) (community)
- **Categories:** Automation, Developer tools, Social media
- **Stats:** 8 total users, 4 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 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.

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 Scraper

A production-grade Instagram scraper that extracts profiles, posts, reels, and comments using authenticated session cookies — no headless browser required.

Built with TypeScript, Crawlee HttpCrawler, and `got-scraping` for stealth HTTP requests that mimic real browser traffic.

### Features

- **HTTP-first Architecture**: Blazing fast — directly queries Instagram's private API endpoints.
- **Cookie Authentication**: Supports Netscape (tab-separated), JSON array, and semicolon string cookie formats.
- **Multi-mode Scraping**: Profile, Posts, Reels, Comments, or All-in-One from a single Actor.
- **Cursor-based Pagination**: Automatically paginates through all posts and comments.
- **Rate Limiting**: Configurable delay between requests to avoid Instagram throttling.
- **Proxy Support**: HTTP, HTTPS, and SOCKS5 proxies supported out of the box.

### How to Use

1. **Scrape Type**: Choose what to scrape — profile, posts, reels, comments, or all.
2. **Usernames**: Enter one or more Instagram usernames.
3. **Cookies**: Paste your Instagram session cookies (must contain a valid `sessionid`).
4. Click **Start**!

### Output

Results are saved to the Apify Dataset with a `recordType` field (`profile`, `post`, `reel`, or `comment`) so you can easily filter. Download as JSON, CSV, or Excel from the Apify Console.

# Actor input Schema

## `scrapeType` (type: `string`):

Choose which Instagram data to scrape.

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

Instagram usernames to scrape. Required for profile, posts, reels, all.

## `postIds` (type: `array`):

Optional numeric Instagram media IDs for comment scraping. If omitted, posts are resolved from usernames.

## `limit` (type: `integer`):

Maximum number of posts/reels to scrape per username.

## `commentsLimit` (type: `integer`):

Maximum number of comments to scrape per post.

## `cookies` (type: `string`):

Instagram session cookies. Supports Netscape (tab-separated), JSON array, or semicolon string format. Must contain a valid sessionid.

## `proxyUrl` (type: `string`):

Optional proxy URL (http/https/socks5).

## `rateLimitMs` (type: `integer`):

Delay in milliseconds between paginated requests to avoid rate limiting.

## `outputPath` (type: `string`):

Optional local file path for JSON, JSONL, or CSV output.

## `outputFormat` (type: `string`):

Optional local output format. If omitted, it is inferred from outputPath.

## Actor input object example

```json
{
  "scrapeType": "profile",
  "usernames": [
    "wander_worldly"
  ],
  "limit": 20,
  "commentsLimit": 50,
  "rateLimitMs": 2000
}
```

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("thisismegant/instagram-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 = {}

# Run the Actor and wait for it to finish
run = client.actor("thisismegant/instagram-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 '{}' |
apify call thisismegant/instagram-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/H2mQSaehlmebbEH72/builds/Qn9uTjv8uodcXeXpz/openapi.json
