# Insta Post Insight Fetcher (`barefoot_year/insta-post-insight-fetcher`) Actor

Scrape public Instagram post and reel metrics by username, usernames list, post URL, or reel URL. Get likes, comments, views, captions, timestamps, and media links in structured JSON.

- **URL**: https://apify.com/barefoot\_year/insta-post-insight-fetcher.md
- **Developed by:** [Ghost Rider](https://apify.com/barefoot_year) (community)
- **Categories:** Social media
- **Stats:** 37 total users, 19 monthly users, 99.9% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

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

## Insta-Post-Insight-Fetcher

Apify actor that scrapes publicly visible Instagram post and reel metrics by username, usernames list, or direct Instagram URLs.

### What it does

- Accepts an Instagram `username`, `@handle`, or full profile URL.
- Accepts bulk `usernames` input with up to `1000` usernames per run.
- Accepts direct Instagram `urls` for posts and reels.
- Scrapes recent public posts from a profile and/or direct media details from URLs.
- Returns public metrics such as likes, comments, views, caption, post URL, and timestamp.
- Uses `CheerioCrawler` with a request queue to process profile and pagination requests.
- Retries blocked requests with a fresh session, which is closer to how stable Apify marketplace actors behave.
- Uses cursor pagination to collect more than the default first page when Instagram allows it.

### Input

```json
{
  "username": "instagram",
  "usernames": [
    "instagram",
    "natgeo"
  ],
  "postCount": 12,
  "urls": [
    "https://www.instagram.com/p/ABC123XYZ/",
    "https://www.instagram.com/reel/XYZ123ABC/"
  ],
  "proxyConfig": {
    "useApifyProxy": true
  }
}
```

### Input fields

- `username` - optional Instagram username, `@handle`, or profile URL.
- `usernames` - optional list of up to `1000` usernames or profile URLs.
- `postCount` - optional number of recent posts to collect from the username profile, from `1` to `100`. Default is `12`.
- `urls` - optional list of direct Instagram post or reel URLs. The actor auto-detects the media type.
- `proxyConfig` - optional Apify proxy configuration for blocked or throttled requests.

### How it works

- The actor can start with one profile request, many profile requests, one or more direct media URL requests, or any combination of them.
- For usernames, it parses the first page of public posts from each profile response.
- If more profile posts are needed, it adds GraphQL pagination requests to the queue.
- For direct Instagram URLs, it extracts the shortcode and detects whether the URL is a post, reel, or TV media URL automatically.
- When Instagram blocks a request, the crawler retires that session and retries the request.
- After the queue is drained, the actor pushes the collected posts to the dataset.

### Output

Each dataset item contains one post or reel:

```json
{
  "sourceType": "profile_post",
  "inputUrl": null,
  "username": "instagram",
  "fullName": "Instagram",
  "userId": "25025320",
  "profileUrl": "https://www.instagram.com/instagram/",
  "postId": "1234567890",
  "shortcode": "ABC123XYZ",
  "postUrl": "https://www.instagram.com/p/ABC123XYZ/",
  "mediaType": "image",
  "isVideo": false,
  "caption": "Example caption",
  "hashtags": ["example"],
  "mentions": ["example_user"],
  "likeCount": 1000,
  "commentCount": 42,
  "firstComment": "",
  "latestComments": [],
  "viewCount": null,
  "playCount": null,
  "takenAt": "2026-05-25T10:00:00.000Z",
  "thumbnailUrl": "https://...",
  "dimensions": {
    "height": 1350,
    "width": 1080
  },
  "dimensionsHeight": 1350,
  "dimensionsWidth": 1080,
  "productType": "clips",
  "videoUrl": "https://...",
  "audioUrl": "https://...",
  "videoDuration": 58.266,
  "taggedUsers": [],
  "coauthorProducers": [],
  "isCommentsDisabled": false,
  "musicInfo": {
    "artist_name": "Example Artist",
    "song_name": "Example Song",
    "audio_id": "123456789"
  },
  "scrapedAt": "2026-05-25T11:00:00.000Z"
}
```

### Important notes

- This actor extracts **public web data only**.
- It does **not** return private creator insights such as reach, impressions, saves, or shares.
- Reel/video `viewCount` and `playCount` (`videoViewCount` / `videoPlayCount` in output) are best-effort public metrics and can differ from the live Instagram app UI.
- If only one of view/play is available from Instagram, the actor leaves the other field unset (they are different metrics — do not treat them as interchangeable).
- Instagram can throttle anonymous traffic. For better success, use `proxyConfig`.
- **Proxy cost tip:** do **not** enable Residential by default. Use plain Apify Proxy (`"useApifyProxy": true` with no `apifyProxyGroups`). Turn on Residential only when you see frequent blocks:
  ```json
  "proxyConfig": {
    "useApifyProxy": true,
    "apifyProxyGroups": ["RESIDENTIAL"]
  }
  ```
- For missing reel `videoViewCount` / `videoPlayCount`, the actor uses anonymous enrichment (no login):
  1. Browser in-page Polaris + profile **Reels tab** scroll
  2. Targeted **Residential** HTTP probe only when counts are still missing
  3. Residential browser as last resort
- Do **not** enable Residential for the whole crawl unless you need it; count fallback creates it automatically when needed.
- The actor is queue-based and session-aware, but Instagram can still change internal endpoints at any time.
- Direct URL scraping uses shortcode-based GraphQL lookup. If Instagram changes its `doc_id` or payload shape, that part may need maintenance.
- Pagination relies on Instagram's current web behavior, so long-range scraping may require maintenance if Instagram changes internal endpoints.
- The actor allows up to `1000` usernames per run, but large batches can still return partial results if Instagram blocks pagination.
- For large jobs, split profile scraping into smaller sequential batches such as `100` usernames per run for better reliability.

# Actor input Schema

## `username` (type: `array`):

Username (@natgeo or natgeo), profile URL, or direct post/reel URL. Add one or many — mixed input is supported.

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

How many recent posts or reels to collect from each profile. Ignored for direct post/reel URLs in the list above.

## `skipPinnedPosts` (type: `boolean`):

If enabled, pinned posts are excluded from profile scrapes.

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

Optional. Leave empty for anonymous mode. Actor tries profile Reels tab + targeted residential proxy for play/view counts without login.

## `proxyConfig` (type: `object`):

Use Apify Proxy without Residential for lower cost. Only enable Residential if you get frequent blocks/empty results.

## Actor input object example

```json
{
  "username": [
    "https://www.instagram.com/instagram/"
  ],
  "resultsLimit": 12,
  "skipPinnedPosts": false,
  "proxyConfig": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `results` (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 = {
    "username": [
        "https://www.instagram.com/instagram/"
    ],
    "resultsLimit": 12
};

// Run the Actor and wait for it to finish
const run = await client.actor("barefoot_year/insta-post-insight-fetcher").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 = {
    "username": ["https://www.instagram.com/instagram/"],
    "resultsLimit": 12,
}

# Run the Actor and wait for it to finish
run = client.actor("barefoot_year/insta-post-insight-fetcher").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 '{
  "username": [
    "https://www.instagram.com/instagram/"
  ],
  "resultsLimit": 12
}' |
apify call barefoot_year/insta-post-insight-fetcher --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=barefoot_year/insta-post-insight-fetcher",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

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