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

Scrape public Instagram profile posts back to a date. Returns likes, comments, captions, hashtags, media URLs, owner info, follower counts, and optional play counts.

- **URL**: https://apify.com/plummy\_bookbag/instagram-profile-scraper.md
- **Developed by:** [Mark Pandit](https://apify.com/plummy_bookbag) (community)
- **Stats:** 1 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / 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/actors/running/actors-in-store.md#pay-per-event

## 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 Profile Posts Scraper

Scrape public Instagram profile posts from newest to a cutoff date. Each dataset row is one post, with engagement, media, and profile context.

### Input

| Field | Description |
|---|---|
| **Profiles** | One profile per line — URL, `@handle`, or username |
| **Scrape till date** | Inclusive lower bound (calendar / `YYYY-MM-DD`). Scraping stops once posts older than this date appear. |
| **Include video play counts** | On by default. Fills `videoPlayCount` via an extra clips API pass. Turn off for faster scrapes. |
| **Max posts per profile** | Cap per profile |
| **Max posts for the entire run** | Cap across all profiles |
| **Session proxy (warm + scrape)** | Sticky Residential for the full guest session. Required to avoid Instagram 401. |
| **Fallback scrape proxy** | Only used if Session proxy is off. |

Example:

```text
https://www.instagram.com/bjp4india/
@natgeo
```

#### Optional auth

Runs as a guest session by default. For higher rate limits and more reliable follower counts, set `IG_SESSIONID` in the Actor environment variables to a logged-in Instagram `sessionid` cookie.

### Output

One dataset item per post. Field names follow the data (camelCase), similar to common Instagram post scrapers.

| Field | Description |
|---|---|
| `id` | Media id (pk) |
| `type` | `Image`, `Video`, or `Sidecar` |
| `shortCode` | Short code used in the post URL |
| `url` | Public post / reel URL |
| `caption` | Caption text |
| `hashtags` | Hashtags from the caption |
| `mentions` | `@mentions` from the caption |
| `commentsCount` | Comment count |
| `likesCount` | Like count |
| `videoPlayCount` | Play count for reels/videos when **Include video play counts** is on and Instagram returns it |
| `timestamp` | Publish time (UTC, ISO 8601) |
| `displayUrl` | Thumbnail / primary image URL |
| `videoUrl` | Direct video URL when present |
| `images` | Carousel image URLs (when present) |
| `ownerUsername` | Post owner username |
| `ownerFullName` | Owner display name |
| `ownerId` | Owner user id |
| `productType` | Instagram product type (`clips`, `feed`, …) |
| `isPaidPartnership` | Paid partnership flag |
| `isCommentsDisabled` | Comments disabled flag |
| `hasAudio` | Audio flag when Instagram reports it |
| `dimensionsHeight` / `dimensionsWidth` | Original media size |
| `locationName` | Location name when set |
| `musicInfo` | Reel audio metadata when exposed |
| `followersCount` | Exact profile follower count when available |
| `inputUrl` | Profile URL requested for the run |

Pinned posts are skipped (they break chronological order).

#### What this Actor does **not** scrape

To keep runs fast and results readable, these are intentionally omitted:

- Full comment threads (`latestComments` / `firstComment`)
- Nested profile extras (related accounts, highlights, IGTV catalogs)
- Fields Instagram does not return on the guest timeline/clips APIs

### How it works

1. Resolves the public profile (followers, owner metadata).
2. Walks the profile timeline newest → oldest until the date cutoff or max limits.
3. Optionally fills `videoPlayCount` from the clips/reels connection when **Include video play counts** is enabled.
4. Pushes posts to the dataset in chunks as each profile completes.

### Limits

- Private / restricted profiles are not supported.
- Both max-post limits apply; remaining profiles are skipped when the run cap is hit.
- Media URLs can expire — download promptly if you need long-term storage.
- Counts can change after collection as engagement continues.
- Heavy rate limits (HTTP 429) are eased by setting `IG_SESSIONID`.

### Responsible use

Collects publicly visible Instagram data only. Use results in line with applicable law, privacy rules, and Instagram’s terms.

# Actor input Schema

## `profiles` (type: `string`):

One profile per line — full URL (https://www.instagram.com/user) or bare @handle/username.

## `scrapeTillDate` (type: `string`):

Lower date boundary from the latest post. Scraping stops once posts get older than this date. Only posts on/after this date are saved.

## `includeViews` (type: `boolean`):

When enabled, fetches play counts for reels/videos via an extra clips API pass (slower). Turn off for faster scrapes; videoPlayCount will be null.

## `maxPostsPerProfile` (type: `integer`):

Record cap per profile. Stops that profile's scraping when reached.

## `maxPostsPerRun` (type: `integer`):

Total record cap for the whole run. When hit, remaining profiles are skipped and the run ends.

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

Used only when Session proxy is off. Prefer leaving this off and using Residential Session proxy for the full run — Instagram rejects guest cookies if the IP changes after warm.

## `sessionProxyConfiguration` (type: `object`):

Sticky proxy for guest session warm AND all scraping. Use Apify Residential. Do not switch to a different IP after warm — that causes HTTP 401.

## Actor input object example

```json
{
  "profiles": "https://www.instagram.com/bjp4india/\nhttps://www.instagram.com/natgeo/",
  "scrapeTillDate": "2026-09-10",
  "includeViews": true,
  "maxPostsPerProfile": 100,
  "maxPostsPerRun": 3000,
  "proxyConfiguration": {
    "useApifyProxy": false
  },
  "sessionProxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

## `results` (type: `string`):

The default dataset containing scraped post records.

# 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 = {
    "profiles": `https://www.instagram.com/bjp4india/
https://www.instagram.com/natgeo/`,
    "proxyConfiguration": {
        "useApifyProxy": false
    },
    "sessionProxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("plummy_bookbag/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 = {
    "profiles": """https://www.instagram.com/bjp4india/
https://www.instagram.com/natgeo/""",
    "proxyConfiguration": { "useApifyProxy": False },
    "sessionProxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
    },
}

# Run the Actor and wait for it to finish
run = client.actor("plummy_bookbag/instagram-profile-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 '{
  "profiles": "https://www.instagram.com/bjp4india/\\nhttps://www.instagram.com/natgeo/",
  "proxyConfiguration": {
    "useApifyProxy": false
  },
  "sessionProxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}' |
apify call plummy_bookbag/instagram-profile-scraper --silent --output-dataset

```

## MCP server setup

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