# Instagram Posts Scraper (`alien_force/instagram-posts-scraper`) Actor

Turn public Instagram post and reel links into structured data. No login. One row per URL, with the caption, photos, video, likes, comment count, author, and audio. Works for photos, carousels, videos, and Reels.

- **URL**: https://apify.com/alien_force/instagram-posts-scraper.md
- **Developed by:** [Alien Force](https://apify.com/alien_force) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 92.3% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.60 / 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.
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?

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 Scraper

### Overview

The **Instagram Posts Scraper** collects public Instagram posts and reels from post URLs. Paste `/p/` or `/reel/` links and get structured rows with captions, media URLs, stats, and author details.

This actor does **not** take profile usernames or scrape a profile grid. Each input URL becomes one dataset row.

#### Key Features

- **Post URL input**: Accepts `/p/`, `/reel/`, `/reels/`, `/tv/`, and `instagram.com/{user}/p|reel/{code}` links.
- **Photos, carousels, videos, and reels**: Detects media type from the public post payload.
- **Caption and tags**: Caption text plus hashtags and @mentions parsed from it.
- **Engagement**: Likes and comment counts when Instagram includes them for logged-out viewers.
- **Author details**: Username, display name, verified flag, and profile URL.
- **Proxy support**: Datacenter proxies by default; switch to residential if Instagram starts blocking.
- **Fast and lightweight**: HTTP fetch with browser TLS impersonation. No login.

***

### Input Schema

#### Input Properties

1. **`startUrls`** (required)

   - **Type**: `array`
   - **Description**: Public Instagram post or reel URLs.
   - **Example**:
     ```json
     [
         { "url": "https://www.instagram.com/p/Cs9iEotsiGY/" }
     ]
     ```

2. **`proxyConfiguration`**

   - **Type**: `object`
   - **Description**: Proxy settings for the run. Apify Proxy datacenter IPs are used by default. If Instagram starts returning empty pages, switch to the `RESIDENTIAL` group.
   - **Example**:
     ```json
     { "useApifyProxy": true }
     ```

At least one `startUrls` entry must be a valid Instagram post or reel URL.

#### Input Example

```json
{
    "startUrls": [
        { "url": "https://www.instagram.com/p/Cs9iEotsiGY/" },
        { "url": "https://www.instagram.com/p/Csthn7EO99u/" },
        { "url": "https://www.instagram.com/reel/Cs9iEotsiGY/" }
    ],
    "proxyConfiguration": {
        "useApifyProxy": true
    }
}
```

***

### Output

One dataset row per post URL.

| Field | Type | Description |
| --- | --- | --- |
| `inputUrl` | string | URL as given in the input |
| `postUrl` | string | Canonical post or reel URL |
| `postId` | string | Instagram media ID |
| `shortcode` | string | Shortcode from the URL |
| `mediaType` | string | `photo`, `video`, `carousel`, or `reel` |
| `caption` | string | Post caption |
| `hashtags` | string\[] | Hashtags in the caption |
| `mentions` | string\[] | @mentions in the caption |
| `takenAt` | integer | Post time (Unix timestamp, seconds) |
| `displayUrl` | string | Cover image or first media URL |
| `imageUrls` | string\[] | Image URLs, including carousel slides |
| `videoUrl` | string | Best available video URL |
| `videoDuration` | number | Video duration in seconds (DASH / CDN metadata when Instagram omits `video_duration`) |
| `width` | integer | Original media width |
| `height` | integer | Original media height |
| `likeCount` | integer | Likes |
| `commentCount` | integer | Comments |
| `playCount` | integer | Plays / views. Logged-out post pages usually omit this, so it is often `null` |
| `commentsDisabled` | boolean | Whether comments are disabled |
| `locationName` | string | Location name when tagged |
| `ownerId` | string | Author user ID |
| `ownerUsername` | string | Author username |
| `ownerFullName` | string | Author display name |
| `ownerVerified` | boolean | Verified author |
| `ownerProfileUrl` | string | Author profile URL |
| `taggedUsers` | string\[] | Usernames tagged in the media |
| `coauthorUsernames` | string\[] | Coauthor usernames |
| `audioId` | string | Instagram audio / original sound ID |
| `audioUrl` | string | Public audio page, e.g. `https://www.instagram.com/reels/audio/{id}/` |
| `audioTitle` | string | Reel / clip audio title |
| `audioArtist` | string | Reel / clip audio artist |
| `audioIsOriginal` | boolean | Whether the audio is original sound |
| `isPaidPartnership` | boolean | Paid partnership flag when present |
| `scrapedAt` | string | When the post was scraped |

Media CDN URLs expire. Treat `displayUrl` / `videoUrl` as short-lived.

#### Handling of missing and blocked inputs

Inputs that yield no post are kept out of the dataset and reported in the **`RUN_REPORT`** record in the run's key-value store, alongside a warning in the log. Each entry lists the original `input`, the resolved `postUrl` and `shortcode`, a `reason` (`empty`, `gated`, `notAvailable`, `invalidInput`, or `requestFailed`), and a human-readable `message`.

- **Private or gated post**: skipped as `gated`. A logged-out page that does not actually mark the post as private or gated is retried first. `gated` is reported when the page marks it that way, or when those retries are used up.
- **Removed or unavailable post**: skipped as `notAvailable`, with no retries. This covers a "Post isn't available" page and the same outcome from the page payload or status.
- **Input without a usable shortcode**: skipped as `invalidInput`. If *no* input yields a post URL, the run fails with an input error.
- **Blocked request**: automatically retried. If every retry fails, the input is skipped as `requestFailed`. A run where *all* targets were blocked fails with a clear message.

The run's status message always reports how many posts were scraped and how many inputs were skipped.

# Actor input Schema

## `startUrls` (type: `array`):

Public Instagram post or reel URLs, for example https://www.instagram.com/p/Cs9iEotsiGY/ or https://www.instagram.com/reel/Cs9iEotsiGY/.

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

Select proxies to be used by your crawler. Datacenter proxies are used by default; switch to RESIDENTIAL if Instagram starts blocking requests.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://www.instagram.com/p/Cs9iEotsiGY/"
    }
  ],
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `overview` (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 = {
    "startUrls": [
        {
            "url": "https://www.instagram.com/p/Cs9iEotsiGY/"
        }
    ],
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("alien_force/instagram-posts-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 = {
    "startUrls": [{ "url": "https://www.instagram.com/p/Cs9iEotsiGY/" }],
    "proxyConfiguration": { "useApifyProxy": True },
}

# Run the Actor and wait for it to finish
run = client.actor("alien_force/instagram-posts-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 '{
  "startUrls": [
    {
      "url": "https://www.instagram.com/p/Cs9iEotsiGY/"
    }
  ],
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call alien_force/instagram-posts-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,alien_force/instagram-posts-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/HkzSwfPdAplOubyaS/builds/0s7E3WeaFCcRw6idi/openapi.json
