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

Extract Instagram posts, reels, profiles, places, hashtags, carousels, and comments. Get data from Instagram using one or more Instagram URLs or search queries: content, context, metrics, metadata. Export scraped data, run the scraper via API, schedule and monitor runs or integrate with other tools.

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

## Pricing

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

Extract Instagram posts, reels, profiles, places, hashtags, carousels, and comments with structured metadata, metrics, and high detail.

Get data from Instagram using one or more Instagram URLs or search queries: content, context, metrics, and metadata. Export scraped data in JSON, CSV, Excel, or HTML format, run the scraper via API, schedule and monitor runs, or integrate with other automation tools.

***

### 🌟 Key Features

- **Multi-Entity Extraction**: Scrape Profiles, Posts, Reels, Carousels, Hashtags, Locations/Places, and Comments in a single run.
- **Flexible Input Support**: Input direct Instagram URLs (profile links, post permalinks, reel URLs, tag pages, place pages) or search keywords.
- **Dynamic Dataset Output**: Produces dynamic JSON output tailored to your selected `resultsType` (posts, comments, details, reels).
- **Rich Context & Metrics**: Collect likes count, comments count, video views, captions, user handles, timestamps, media URLs, carousel slide breakdowns, hashtags, and user mentions.
- **Comment Extraction**: Pull detailed comments per post including commenter handle, comment text, timestamp, and comment likes.
- **Apify Proxy Ready**: Built-in support for Apify Proxy to prevent rate limits and geo-restrictions.

***

### 📥 Input Parameters

| Parameter | Type | Default | Description |
| :--- | :--- | :--- | :--- |
| `directUrls` | Array | `["https://www.instagram.com/instagram/"]` | List of target Instagram URLs (Profile, Post, Reel, Hashtag, or Place). |
| `searchQueries` | Array | `["instagram"]` | Keywords or handles to search. |
| `searchType` | String | `"user"` | Search target type: `"user"`, `"hashtag"`, or `"place"`. |
| `resultsType` | String | `"posts"` | Desired dataset output type: `"posts"`, `"comments"`, `"details"`, or `"reels"`. |
| `resultsLimit` | Integer | `20` | Maximum number of items to scrape per URL/query. |
| `includeComments` | Boolean | `true` | Include top comments for posts/reels. |
| `proxyConfiguration` | Object | `{ "useApifyProxy": false }` | Apify proxy configuration options. |
| `debugLog` | Boolean | `false` | Enable verbose diagnostic logging. |

#### Example `input.json`

```json
{
  "directUrls": [
    "https://www.instagram.com/instagram/",
    "https://www.instagram.com/p/C-XyZ12345/",
    "https://www.instagram.com/reel/C-AbCd12345/",
    "https://www.instagram.com/explore/tags/photography/"
  ],
  "searchQueries": [
    "photography",
    "travel"
  ],
  "searchType": "user",
  "resultsType": "posts",
  "resultsLimit": 10,
  "includeComments": true,
  "debugLog": false
}
```

***

### 📤 Dataset Output Formats

Depending on the `resultsType` selected, the actor pushes dynamic records to the output dataset.

#### 1. Post / Reel / Carousel Item Output

```json
{
  "id": "post_C-XyZ12345",
  "type": "Image",
  "shortCode": "C-XyZ12345",
  "url": "https://www.instagram.com/p/C-XyZ12345/",
  "caption": "Exploring breathtaking views! #photography #travel",
  "likesCount": 14250,
  "commentsCount": 320,
  "videoViewCount": 0,
  "timestamp": "2026-08-01T12:00:00.000Z",
  "ownerUsername": "instagram_creator",
  "ownerId": "987654321",
  "displayUrl": "https://instagram.com/media/C-XyZ12345.jpg",
  "childPosts": [
    { "id": "slide_1", "displayUrl": "https://instagram.com/media/C-XyZ12345_1.jpg" },
    { "id": "slide_2", "displayUrl": "https://instagram.com/media/C-XyZ12345_2.jpg" }
  ],
  "hashtags": ["#photography", "#travel"],
  "mentions": ["@instagram"],
  "comments": [
    {
      "commentId": "c_C-XyZ12345_1",
      "text": "Awesome post! Keep it up 🔥",
      "timestamp": "2026-08-01T12:05:00.000Z",
      "ownerUsername": "fan_user_1",
      "ownerProfileUrl": "https://www.instagram.com/fan_user_1/",
      "likesCount": 14,
      "postId": "post_C-XyZ12345",
      "postShortCode": "C-XyZ12345"
    }
  ],
  "scrapedAt": "2026-08-06T15:03:00.000Z"
}
```

#### 2. Profile Details Item Output

```json
{
  "id": "1029384756",
  "username": "instagram",
  "fullName": "Instagram",
  "biography": "Discover what's next on Instagram 💫",
  "externalUrl": "https://about.instagram.com",
  "followersCount": 670000000,
  "followsCount": 85,
  "postsCount": 7400,
  "profilePicUrl": "https://instagram.com/p/instagram/avatar.jpg",
  "isVerified": true,
  "isPrivate": false,
  "url": "https://www.instagram.com/instagram/",
  "scrapedAt": "2026-08-06T15:03:00.000Z"
}
```

***

### 🚀 How to Run

#### Via Apify CLI

```bash
## Validate input schema
apify validate-schema

## Run actor locally with simulated platform storage
apify run
```

#### Via npm

```bash
## Install dependencies
npm install

## Execute main script
npm start
```

#### Via Apify API (Node.js SDK)

```javascript
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: 'YOUR_APIFY_TOKEN' });
const run = await client.actor('username/instagram-scraper').call({
    directUrls: ['https://www.instagram.com/instagram/'],
    resultsType: 'posts',
    resultsLimit: 20
});

const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);
```

***

### 🔒 Proxy & Compliance

When scraping public data at scale, it is recommended to enable **Apify Proxy** (`useApifyProxy: true`) to avoid request throttling and ensure smooth data retrieval.

# Actor input Schema

## `directUrls` (type: `array`):

List of Instagram URLs to scrape. Supports profiles, posts, reels, hashtags, or location/place URLs.

## `searchQueries` (type: `array`):

List of usernames, hashtag names, or place names to search and scrape.

## `searchType` (type: `string`):

Target entity type for search queries.

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

Specify what content type to extract into output dataset.

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

Maximum number of items to extract per URL or search query.

## `includeComments` (type: `boolean`):

Fetch top comments alongside post items.

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

Proxy settings for requests to avoid rate limiting and geo-restrictions.

## `debugLog` (type: `boolean`):

Output verbose diagnostic logs.

## Actor input object example

```json
{
  "directUrls": [
    "https://www.instagram.com/instagram/",
    "https://www.instagram.com/p/C-XyZ12345/",
    "https://www.instagram.com/reel/C-AbCd12345/",
    "https://www.instagram.com/explore/tags/photography/"
  ],
  "searchQueries": [
    "instagram",
    "photography"
  ],
  "searchType": "user",
  "resultsType": "posts",
  "resultsLimit": 20,
  "includeComments": true,
  "proxyConfiguration": {
    "useApifyProxy": false
  },
  "debugLog": false
}
```

# Actor output Schema

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

Dataset containing scraped Instagram posts, reels, profiles, comments, and locations.

# 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 = {
    "directUrls": [
        "https://www.instagram.com/instagram/",
        "https://www.instagram.com/p/C-XyZ12345/",
        "https://www.instagram.com/reel/C-AbCd12345/",
        "https://www.instagram.com/explore/tags/photography/"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("scrapeai/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 = { "directUrls": [
        "https://www.instagram.com/instagram/",
        "https://www.instagram.com/p/C-XyZ12345/",
        "https://www.instagram.com/reel/C-AbCd12345/",
        "https://www.instagram.com/explore/tags/photography/",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("scrapeai/instagram-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 '{
  "directUrls": [
    "https://www.instagram.com/instagram/",
    "https://www.instagram.com/p/C-XyZ12345/",
    "https://www.instagram.com/reel/C-AbCd12345/",
    "https://www.instagram.com/explore/tags/photography/"
  ]
}' |
apify call scrapeai/instagram-scraper --silent --output-dataset

```

## MCP server setup

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