# Instagram Scraper - Public Profile & Recent Posts (`santamaria-automations/instagram-scraper`) Actor

Scrape public Instagram profiles: bio, follower count, following count, post count, verification status, business category, website, and up to 12 recent posts per profile with captions, thumbnails and post URLs. No likes or timestamps (anonymous access). No login required. Pay-per-result.

- **URL**: https://apify.com/santamaria-automations/instagram-scraper.md
- **Developed by:** [NanoScrape](https://apify.com/santamaria-automations) (community)
- **Categories:** Social media, Lead generation
- **Features:** Limited permissions
- **Stats:** 13 total users, 2 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 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/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 Scraper

Extract public [Instagram](https://www.instagram.com/) profile data in bulk. No API key, no login. Supply a list of usernames or profile URLs and get structured profile records back: bio, follower and following counts, verification status, business category, external website, and up to 12 recent posts per profile with captions, thumbnails, media type, and post URLs.

HTTP-only, ~128 MB RAM, pay-per-result.

### What It Does

For every public Instagram handle in the input, the actor returns one dataset row with:

- Identity: username, user_id, full_name, profile_url, profile_pic_url
- Bio: biography, external website
- Stats: follower_count, following_count, post_count
- Signals: is_verified, is_private, is_business_account, category_name
- Recent posts: up to 12 per profile, each with shortcode, caption, media_type (photo, video, carousel), media_url (thumbnail), post_url

**Note on engagement metrics:** Instagram does not expose like counts, comment counts, or post timestamps to anonymous access. Those fields are not returned by this actor. Private accounts return the profile row without post details. Not-found handles and profiles that trip Instagram's auth wall are logged and skipped so the rest of the batch keeps running.

### Input

Accepts bare handles, `@handle`, or full profile URLs. Mix and match freely.

```json
{
  "usernames": [
    "example_handle",
    "@another_example",
    "https://www.instagram.com/third_example/"
  ],
  "maxPostsPerProfile": 12
}
```

#### Input Fields

| Field | Type | Required | Default | Description |
|-------|------|----------|---------|-------------|
| `usernames` | string\[] | No | `["nasa"]` | Instagram handles or profile URLs to scrape |
| `maxPostsPerProfile` | integer | No | `12` | Recent posts per profile (0 to 12). Set to 0 to skip posts and run faster |

### Output

One row per input handle, pushed to the default dataset.

```json
{
  "username": "example_handle",
  "user_id": "1234567890",
  "full_name": "Example Company",
  "biography": "Example bio for a public Instagram profile.",
  "website": "https://example.com",
  "follower_count": 125000,
  "following_count": 420,
  "post_count": 1830,
  "is_verified": true,
  "is_private": false,
  "is_business_account": true,
  "category_name": "Retail Company",
  "profile_pic_url": "https://scontent.cdninstagram.com/example.jpg",
  "posts": [
    {
      "shortcode": "Dci8yDORzci",
      "caption": "Example post caption.",
      "media_type": "video",
      "media_url": "https://scontent.cdninstagram.com/example_thumb.jpg",
      "post_url": "https://www.instagram.com/p/Dci8yDORzci/"
    }
  ],
  "profile_url": "https://www.instagram.com/example_handle/",
  "scraped_at": "2026-07-18T09:00:00Z"
}
```

`profile_url` echoes the input identifier and is safe to use as a merge key when joining back to your CRM or another actor's output.

Post fields available on anonymous access: `shortcode`, `caption`, `media_type`, `media_url`, `post_url`. Instagram does not include `like_count`, `comment_count`, or `posted_at` in its public HTML responses, so those fields are absent from the output.

### Pricing

Pay-per-result via Apify Pay-Per-Event billing:

| Event | Price | Description |
|-------|-------|-------------|
| Actor start | $0.001 | Charged once per run |
| Profile scraped | $0.005 | Charged per profile row returned |

Scraping 1,000 profiles costs about $5. No monthly fees, no minimum spend.

### Use with AI Agents (MCP)

Connect this actor to any MCP-compatible AI client: Claude Desktop, Claude.ai, Cursor, VS Code, LangChain, LlamaIndex, or custom agents.

Apify MCP server URL:

```
https://mcp.apify.com?tools=santamaria-automations/instagram-scraper
```

Example prompt once connected:

> "Use `instagram-scraper` to fetch the profile and last 12 posts for two example handles. Return a table with username, follower count, verification status, and each post's caption and media type."

Clients that support dynamic tool discovery (Claude.ai, VS Code) receive the full input schema automatically via `add-actor`.

### Tips

- Bare handles run fastest. If you pass full URLs the actor strips them down to the handle for you.
- Set `maxPostsPerProfile` to `0` when you only need profile stats. Cuts response size and speeds up big runs.
- Every handle is scraped once per run even if it appears multiple times in the input list.
- One run processes about 400 profiles per hour at the default settings. For larger lists, raise the run timeout; if a run is restarted it continues where it stopped.
- Proxying is handled for you: the actor uses residential IPs (Instagram blocks datacenter IPs) and rotates them automatically. No proxy settings are needed.

### FAQ

**What does "public profile" mean?**
Instagram profiles set to public are visible without logging in. This actor can only scrape public accounts. Private accounts return profile stats but no post details.

**Why are like counts and comment counts missing?**
Instagram does not include engagement metrics in the HTML it serves to anonymous (non-logged-in) visitors. That data is only available to authenticated sessions, which this actor does not use. The fields are absent from output rather than returned as zero to avoid misleading downstream systems.

**What happens if a handle does not exist?**
The actor logs a warning for that handle and continues. Not-found handles are not written to the dataset.

**What if Instagram requires login?**
Individual profiles that hit Instagram's auth wall are skipped with a warning so the rest of the batch still completes. The actor only fails if every profile in the run is blocked.

**Are results deduplicated?**
Each handle is scraped once per run regardless of how many times it appears in the input.

### Related Actors

Discovery:

- [Google Maps Scraper](https://apify.com/santamaria-automations/google-maps-scraper) - collect places and companies in bulk
- [Website Email Scraper](https://apify.com/santamaria-automations/website-email-scraper) - pull emails, phones and social handles from company sites

Enrichment:

- [LinkedIn Company Scraper](https://apify.com/santamaria-automations/linkedin-company-scraper) - enrich companies with LinkedIn data
- [AI Icebreaker Generator](https://apify.com/santamaria-automations/ai-icebreaker) - one personalized cold-outreach line per business
- [GBP Completeness Audit](https://apify.com/santamaria-automations/gbp-completeness-audit) - score Google Business Profiles for lead prioritization

### Changelog

- v1.8 (2026-11-04): A restarted run now continues where it stopped instead of starting again from the first username, and a username is never saved or charged twice in one run.
- v1.7 (2026-10-15): Cut proxy traffic per profile by about 90%. Profiles now try the public profile page first and the API only once as a fallback, with at most 4 attempts per profile (previously up to 12 API attempts, each downloading the Instagram homepage before the real request). Output fields are unchanged.
- v1.6 (2026-10-15): Proxy is now managed by the actor (the `proxyConfiguration` input is ignored if sent). Blocked or failed profiles are listed in the `FAILED_URLS` key-value record instead of the dataset, and a run where every profile is blocked now fails instead of reporting success.
- v1.5 (2026-09-10): Rewrote HTML post extraction to use Instagram's new XIGPolarisMedia SSR shape (2026-09-08 format). The "code" anchor scan reliably returns 12 posts on anonymous HTML. Profile extraction now uses completeness-scored candidate ranking so the real profile object (containing follower_count) is selected over sidebar widgets that share the same username. Engagement fields (like_count, comment_count, posted_at) removed from promised output as they are not present in anonymous SSR. API path retained as primary (may recover); HTML is primary fallback and now populates posts. Added automatic HTML post supplement when API returns profile but 0 posts.
- v1.4 (2026-09-07): Expanded IP rotation to 12 attempts across US/GB/DE with User-Agent variation to reduce Instagram auth walls on aggressively-crawled handles.
- v1.3 (2026-09-07): Increased IP rotation attempts from 2 to 6 and pinned residential proxy to US by default to reduce Instagram auth-wall hits and restore posts\[] population on Apify QA runs.
- v1.2 (2026-09-07): Added HTML embedded-JSON fallback. When the API returns 401, the actor now parses profile data from the public profile page. Login wall is only declared if both the API and HTML paths fail on the same IP.
- v1.1: Added per-profile residential IP rotation; deduplicated usernames; improved post edge extraction for both legacy graphql and current API shapes.
- v1.0: Initial release.

### Issues & Feature Requests

If a field is missing or looks off for a given profile, open an issue on the actor's [Issues tab](https://apify.com/santamaria-automations/instagram-scraper/issues) and we will take a look.

# Actor input Schema

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

List of public Instagram usernames or profile URLs to scrape. Accepts bare usernames ('nasa'), '@nasa', or full URLs like 'https://www.instagram.com/nasa/'. Defaults to \['nasa'] when omitted.

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

Maximum number of recent posts to include per profile. Set to 0 to return profile data only (no posts). Default is 12.

## Actor input object example

```json
{
  "usernames": [
    "nasa",
    "nike"
  ],
  "maxPostsPerProfile": 12
}
```

# Actor output Schema

## `defaultDataset` (type: `string`):

Dataset containing scraped Instagram profile records with bio, stats, and recent posts.

# 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": [
        "nasa",
        "nike"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("santamaria-automations/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 = { "usernames": [
        "nasa",
        "nike",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("santamaria-automations/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 '{
  "usernames": [
    "nasa",
    "nike"
  ]
}' |
apify call santamaria-automations/instagram-scraper --silent --output-dataset

```

## MCP server setup

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