# Instagram Post Scraper — Details, Comments & oEmbed (`thenetaji/instagram-post-scraper`) Actor

Fetch a post's full media object, its comments, or its oEmbed metadata, by shortcode, media ID, or URL, with optional author profile enrichment.

- **URL**: https://apify.com/thenetaji/instagram-post-scraper.md
- **Developed by:** [The Netaji](https://apify.com/thenetaji) (community)
- **Categories:** Social media, For creators, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.75 / 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.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#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 Post Scraper — Details, Comments & oEmbed

The Actor resolves individual public Instagram posts. One field selects what to return — the full media object, a page of comments, or oEmbed embedding metadata — and posts can be identified by shortcode, media ID, or URL.

### Selecting a mode

`scraperType` is required and determines what a run returns.

| Value | Label | Returns |
|---|---|---|
| `postDetails` | Post Details | The full public media object and its first page of comments |
| `postComments` | Comments | A page of comments for each post |
| `oembed` | oEmbed | Embedding metadata: HTML block, author name, thumbnail |

### Accepted input

Each mode reads a different input field. Filling the wrong one leaves the run with nothing to fetch.

| Field | Type | Used by | Accepts |
|---|---|---|---|
| `scraperType` | enum | — | Required. `postDetails`, `postComments`, `oembed`. |
| `posts` | array of strings | `postDetails` | Shortcode, numeric media ID, or full URL |
| `codes` | array of strings | `postComments` | Shortcode only |
| `urls` | array of strings | `oembed` | Full post or reel URL |
| `enrichAuthorProfile` | boolean | all | Attaches the author's profile to each post. |
| `fullProfileDetails` | boolean | all | Extends the attached profile to the complete payload. |

```json
{
  "scraperType": "postDetails",
  "posts": [
    "C9xY2zAqBcD",
    "https://www.instagram.com/p/C9xY2zAqBcD/"
  ],
  "enrichAuthorProfile": false
}
```

A shortcode is the segment after `/p/` or `/reel/` in a post URL. Only `postDetails` accepts all three forms; **comments require the shortcode specifically and will not resolve a numeric media ID**, and oEmbed requires a complete URL.

### Response fields

| Field | Contents |
|---|---|
| `pk` | Instagram media ID |
| `code` | Shortcode |
| `like_count` | Likes |
| `comment_count` | Comments |
| `taken_at` | Publication timestamp |
| `media_type` | Image, video, or carousel |
| `caption` | Caption text |
| `author_profile` | Author's profile, with `enrichAuthorProfile` |
| `author_enriched` | Whether the author profile was fetched |
| `source_code` | The identifier supplied for this row |

In oEmbed mode the record instead carries `html`, `author_name`, and `thumbnail_url`.

```json
{
  "pk": "3412987456123456789",
  "code": "C9xY2zAqBcD",
  "like_count": 184220,
  "comment_count": 1204,
  "taken_at": 1785312000,
  "author_enriched": false
}
```

### Behaviour on partial results

Posts are fetched one request each. A post that returns nothing — deleted, made private, or a bad identifier — is logged as a warning and skipped; a request that fails outright is logged as an error. The run continues either way, so the number of records can be lower than the number of posts supplied.

Author enrichment runs after all posts are fetched rather than per post, so a run enriches once across the whole set. Posts sharing an author therefore do not each incur a separate lookup.

### Frequently asked questions

**Which mode returns all the comments on a post?**
None of them. `postComments` returns a page of comments, and `postDetails` includes the first page alongside the media object. Instagram paginates comments and does not expose a complete thread for heavily commented posts. `comment_count` reports the true total, so the count and the returned comments are expected to disagree — the count is authoritative and the comments are a sample.

**What is oEmbed mode for?**
Embedding rather than analysis. It returns the HTML block Instagram publishes for putting a post on another page, plus the author name and thumbnail. It does not return like counts, captions, or comments; if those are the goal, `postDetails` is the mode.

**Where does a shortcode come from?**
The post URL, as the segment after `/p/` or `/reel/`. It is also the `code` field on every row returned by [Instagram Profile Content Scraper](https://apify.com/thenetaji/instagram-profile-content-scraper) and [Instagram Popular Search Scraper](https://apify.com/thenetaji/instagram-popular-search-scraper), which is the practical way to obtain them in quantity.

**Why did a comments run return nothing when the same posts worked in Post Details?**
Two reasons, both about which field was filled. Comments read `codes` rather than `posts`, so identifiers left in `posts` are ignored in that mode. And `codes` accepts the shortcode only — a numeric media ID, which `postDetails` resolves happily, will not resolve here. The `code` field on rows from the content and search Actors is already the right form.

**What does `enrichAuthorProfile` cost when several posts share an author?**
Enrichment happens once for the batch after all posts are fetched, rather than once per post, so a set of posts from a single account does not multiply the cost by the number of posts.

**Why is `caption` empty on some posts?**
The author published without one. The field is empty rather than absent, and the post is otherwise complete.

**Can posts from a private account be fetched?**
No. Only public posts are readable, and no logged-in session is used.

### Related Actors

| Actor | Purpose |
|---|---|
| [Instagram Profile Content Scraper](https://apify.com/thenetaji/instagram-profile-content-scraper) | An account's posts and reels, which supply shortcodes |
| [Instagram Popular Search Scraper](https://apify.com/thenetaji/instagram-popular-search-scraper) | Posts by hashtag or keyword |
| [Instagram User Info Scraper](https://apify.com/thenetaji/instagram-user-info-scraper) | Full profile details for post authors |
| [Instagram Location Scraper](https://apify.com/thenetaji/instagram-location-scraper) | Metadata for locations tagged on posts |

# Actor input Schema

## `posts` (type: `array`):

Instagram post/reel shortcode, numeric media ID, or full post URL — one per line. Only used when Fetch Mode is Post Details.

## `codes` (type: `array`):

Paste the post's or reel's Instagram link, or just the code at the end of it. Only used when Fetch Mode is Comments.

## `urls` (type: `array`):

Full public Instagram post or reel URLs. Only used when Fetch Mode is oEmbed.

## `scraperType` (type: `string`):

Full post details, a page of comments, or oEmbed metadata.

## `enrichAuthorProfile` (type: `boolean`):

Fetch and attach the post author's full public profile. Costs an extra event per post.

## `fullProfileDetails` (type: `boolean`):

Off by default, which returns follower/following counts, biography, bio links and core identity — the fields most runs need, at a fraction of the cost. Turn on to also collect post previews, media count, business category and contact fields. Note that Instagram's full-profile source is currently broken for a sizeable minority of accounts; for those, turning this on costs more and still returns the reduced set.

## Actor input object example

```json
{
  "posts": [
    "DZpQwxqimz2"
  ],
  "codes": [
    "DZpQwxqimz2"
  ],
  "urls": [
    "https://www.instagram.com/p/DZpQwxqimz2/"
  ],
  "scraperType": "postDetails",
  "enrichAuthorProfile": false,
  "fullProfileDetails": false
}
```

# Actor output Schema

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

All records scraped by this run

# 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 = {
    "posts": [
        "DZpQwxqimz2"
    ],
    "codes": [
        "DZpQwxqimz2"
    ],
    "urls": [
        "https://www.instagram.com/p/DZpQwxqimz2/"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("thenetaji/instagram-post-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 = {
    "posts": ["DZpQwxqimz2"],
    "codes": ["DZpQwxqimz2"],
    "urls": ["https://www.instagram.com/p/DZpQwxqimz2/"],
}

# Run the Actor and wait for it to finish
run = client.actor("thenetaji/instagram-post-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 '{
  "posts": [
    "DZpQwxqimz2"
  ],
  "codes": [
    "DZpQwxqimz2"
  ],
  "urls": [
    "https://www.instagram.com/p/DZpQwxqimz2/"
  ]
}' |
apify call thenetaji/instagram-post-scraper --silent --output-dataset

```

## MCP server setup

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