# Instagram Posts by User (`opspilot.cc/instagram-posts-by-user`) Actor

📸 Instagram Posts by User | Recent posts with real engagement numbers Give it usernames, profile URLs or numeric ids — get one row per post: likes, comments, views, media type, publish time, caption, thumbnail and video URL, plus a per-account summary (median likes, median views, share of posts wi…

- **URL**: https://apify.com/opspilot.cc/instagram-posts-by-user.md
- **Developed by:** [wang wei](https://apify.com/opspilot.cc) (community)
- **Features:** Limited permissions
- **Stats:** 3 total users, 2 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.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 Posts by User

> Recent posts for any list of accounts — one row per post, with real engagement numbers and media URLs.

### ✨ What you get

One dataset row per post:

| Field | What it is |
|---|---|
| `shortcode` / `postId` / `mediaId` | identifiers, plus the `mediaId` the comments leg expects |
| `username` / `userId` / `followers` | account context (the follower count is captured when the run resolves the account) |
| `mediaType` | `image` / `video` / `carousel` |
| `likeCount` / `commentCount` / `playCount` | engagement, with `engagement` (likes + comments) pre-summed |
| `hasPlayCount` / `viewsReported` | separates "photo post has no views" and "video post whose view count came back empty" from a genuine zero |
| `caption` / `takenAt` / `isVideo` | content and timing |
| `thumbnailUrl` / `videoUrl` / `url` | media links |

The run summary carries per-account stats: post counts by type, median likes, median comments, median views, total views, how many posts had no view data, and the top post.

### 💼 Use cases

- **Benchmarking your own feed against a competitor's** — pull 24 posts each for `natgeo` and your brand account, then compare the median likes, median comments and median views in the summary. Medians, not averages, because one Reel would otherwise decide the comparison.
- **Sizing up a creator's video reach before booking them** — `playCount` plus `viewsReported` on the video rows tells you whether a Reel's view count is real or simply absent from the response. A video with 0 views and `viewsReported: false` is missing data, not a flop.
- **Deciding what to repost from a partner's account** — filter by `mediaType` to see whether a creator's last 60 posts are image, video or carousel, then pick the format that already performs for them rather than the one you prefer.
- **Feeding a content audit with raw media** — `thumbnailUrl`, `videoUrl` and `takenAt` on up to 50 accounts at once give you a dated content inventory, not just a metric list.

### ✅ Who this is for

- **In-house social teams**— running a monthly competitive feed audit and needing per-post rows they can pivot themselves, without a listening platform contract.
- **Agencies producing creator shortlists**— who must show a client what a creator actually publishes and what it earned.
- **Video and Reels teams**— checking whether view counts on a Reel are a real number or an unreturned field before reporting reach internally.
- **Cross-border sellers auditing supplier or partner accounts**— who need posts, captions and media URLs in bulk for a product listing decision.

### ❌ Who this is NOT for

- **Private accounts** — they expose no posts and appear in `warnings`. There is no row and no estimate for them here.
- **A media-kit total post count** — the profile endpoint itself flips between 32,039 and 0 for the same account, so `mediaCount` from Instagram is not trustworthy. Count the rows this Actor returns instead, and treat them as a capped sample (1–60, default 24).
- **Reading `playCount: 0` as zero views** — check `viewsReported` first. On a video it means the field came back empty and the post is excluded from the median; on an image or carousel it is `null` because Instagram does not report views there at all. Only `viewsReported: true` rows belong in a view statistic.
- **Comment text or audience composition** — this is a post-level dataset. For what people said under a post, use the `mediaId` with the Instagram Comments Scraper; for follower composition, use the Instagram Followers Scraper.
- **A historical trend or a non-Instagram platform** — paging stops at the cap or when the feed runs out, so a single run is one recent snapshot, never a growth series. TikTok, TikTok-style short-video platforms and YouTube feeds are different endpoints entirely.

### 🚀 Quick start

1. Open the Actor and press **Start** (defaults pull 12 posts for `instagram`).
2. Paste accounts — `natgeo`, `@natgeo`, `https://www.instagram.com/natgeo/` or a raw numeric id all work.
3. Read the **Dataset** tab (one row per post) and the per-account medians in the run summary.

### 📥 Input parameters

| Parameter | Type | Default | What it does |
|---|---|---|---|
| `usernames` | list | `instagram` | Handles, profile URLs or numeric ids, one per line, up to 50 per run. |
| `maxPostsPerAccount` | number | `24` | 1–60 posts per account. A run-wide request budget (12 free / 40 paid) also caps total upstream calls; see Billing. |
| `includeProfileContext` | checkbox | on | Resolves each account once to capture username + follower count. Turn off only if you pass numeric ids and do not need that context. |

### 📤 Output

- **Dataset** — one row per post (or a notice when nothing was collected)
- **SUMMARY** — per-account medians, request counts and warnings

### ⚙️ How it works

1. Every input is resolved to a numeric user id (Instagram's posts leg only accepts ids): handles and URLs go through a profile lookup, raw ids are used directly.
2. Posts are paged 12 at a time until the cap or until the feed runs out.
3. `caption` is an object Data provider, so the text is unwrapped; media URLs are read from both the flat and the `image_versions2` / `video_versions` shapes.
4. View counts get explicit honesty flags because the same account returned video rows with and without `play_count` across two calls.

### 💰 Billing

**Billed per result.** Every row written to the default dataset is one `apify-default-dataset-item` charge, on top of the one-off `actor-start` charge when the run begins. A run that returns 300 rows costs 300 item charges; a run that returns 3 costs 3. Per-item price is on this Actor's pricing card. Rows of `type: "notice"` (a capped or empty run) are dataset rows too and are billed the same way. There is no daily run cap.

**Free plan limit.** One run collects **5 accounts over 3 pages, 60 posts each**. That is a hard ceiling on the upstream cost, so it cannot be raised from the input form. A capped run still succeeds: it writes a `notice` row to the dataset, sets `appliedLimits.capped: true` in `SUMMARY`, and logs why. Any paid Apify plan lifts the cap to 50 accounts over 6 pages.

**Run-wide request budget.** On top of the per-item caps, every run has a fixed ceiling on upstream requests in total — **12 on the free plan, 40 on paid Apify plans** — shared by all accounts, keywords, hashtags or posts in that run, and counting retries. A single item can still walk all of its pages; only wide multi-item runs are compressed. Hitting the ceiling is reported, not hidden: the run still succeeds, delivers everything fetched so far, writes a `type: "notice"` row, and sets `SUMMARY.budgetExhausted: true` alongside `SUMMARY.maxRequestsPerRun` and `SUMMARY.upstreamRequests`.

The per-item figures above are upper bounds, not a promise for every run: when a run supplies the maximum number of items, the shared budget is reached first and fewer items are completed. `SUMMARY.upstreamRequests` reports exactly how many upstream requests were used.

### ❓ FAQ

**Why do some video posts show 0 views?**
Either the post really has no view count yet, or Instagram left the field out of that response (both happen). Check `viewsReported`: `false` on a video means the number is missing, and those posts are excluded from the median instead of dragging it to zero.

**Photo posts show 0 views — is that a bug?**
No. Instagram does not report views for image or carousel posts, so `viewsReported` is `null` for them and they are excluded from view statistics.

**Can I get an account's total post count?**
Not reliably from the profile endpoint (Instagram itself flips it between 32,039 and 0 for the same account). Count the rows this Actor returns instead.

**Does it work on private accounts?**
No — private accounts expose no posts. They are listed in `warnings` rather than silently skipped.

### 📚 Resources

- Apify free plan: monthly credit covers usage, no separate daily cap

# Changelog

This Actor's version history is a separate document: https://apify.com/opspilot.cc/instagram-posts-by-user/changelog.md

# Actor input Schema

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

Accepts natgeo, @natgeo, https://www.instagram.com/natgeo/ or a raw numeric user id — one per line, up to 50 accounts per run.

## `maxPostsPerAccount` (type: `integer`):

How many recent posts to collect per account. Each page of 12 posts is one upstream call ($0.001).

## `includeProfileContext` (type: `boolean`):

Look up each handle once to capture its follower count and numeric id. Turn off only if you already pass numeric ids.

## Actor input object example

```json
{
  "usernames": [
    "instagram"
  ],
  "maxPostsPerAccount": 24,
  "includeProfileContext": true
}
```

# Actor output Schema

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

One row per post, or a single notice when nothing was collected.

## `summary` (type: `string`):

Per-account medians, post counts, upstream calls, cost and warnings.

# 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("opspilot.cc/instagram-posts-by-user").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("opspilot.cc/instagram-posts-by-user").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 '{}' |
apify call opspilot.cc/instagram-posts-by-user --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,opspilot.cc/instagram-posts-by-user"
        }
    }
}
```

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/rQlMQIEuCvauVsbgd/builds/zHcJWHb5OJ8DrygW8/openapi.json
