# Instagram Post Scraper (`leadsbrary/instagram-post-scraper`) Actor

Extract data from any public Instagram post by URL. Get caption, likes, comments, hashtags, mentions, author username, image URL & timestamp instantly. No account needed — stealth browser bypasses bot detection.

- **URL**: https://apify.com/leadsbrary/instagram-post-scraper.md
- **Developed by:** [Alexandre Manguis](https://apify.com/leadsbrary) (community)
- **Categories:** Automation, Social media, Integrations
- **Stats:** 16 total users, 10 monthly users, 98.6% runs succeeded, 1 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $1.00 / 1,000 instagram post scrapers

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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use 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

Extract complete data from any public Instagram post by URL — no login required. Get caption, likes, comments, hashtags, mentions, author info, image URL and timestamp in seconds.

Works headlessly using a stealth browser to bypass bot detection. For private posts or higher-volume usage, provide session cookies.

---

### Features

- ✅ No Instagram account required for public posts
- ✅ Works on `/p/`, `/reel/` and `/tv/` URLs
- ✅ Extracts hashtags and mentions automatically
- ✅ Supports multiple URLs in a single run
- ✅ Optional session cookies for private/restricted content
- ✅ Proxy support via Apify Proxy

---

### Input

```json
{
  "postUrls": [
    "https://www.instagram.com/p/DUJaVJMFbh6/",
    "https://www.instagram.com/reel/ABC123xyz/"
  ],
  "sessionCookies": "",
  "proxyConfig": {
    "useApifyProxy": true
  }
}
````

| Field | Type | Required | Description |
|---|---|---|---|
| `postUrls` | Array of strings | ✅ | Instagram post / reel URLs to scrape |
| `sessionCookies` | String | ❌ | Cookie string (`sessionid=...; csrftoken=...`) for private posts |
| `proxyConfig` | Object | ❌ | Apify proxy configuration |

***

### Output

Each scraped post is saved as one record in the dataset.

#### Example

```json
{
  "shortcode": "DUJaVJMFbh6",
  "url": "https://www.instagram.com/p/DUJaVJMFbh6/",
  "type": "Image",
  "caption": "Golden hour in Lisbon 🌇 One of my favourite spots. #travel #lisbon #portugal #goldenHour #streetphotography",
  "hashtags": ["travel", "lisbon", "portugal", "goldenHour", "streetphotography"],
  "mentions": [],
  "likesCount": 3847,
  "commentsCount": 112,
  "timestamp": "2025-11-14T17:32:05.000Z",
  "ownerUsername": "sofia.captures",
  "ownerId": "492837651",
  "imageUrl": "https://scontent.cdninstagram.com/v/t51.2885-15/..."
}
```

#### Output fields

| Field | Type | Description |
|---|---|---|
| `shortcode` | String | Unique post identifier (from URL) |
| `url` | String | Canonical post URL |
| `type` | String | `Image`, `Video` or `Carousel` |
| `caption` | String | Full post caption |
| `hashtags` | Array | Hashtags extracted from the caption |
| `mentions` | Array | Usernames mentioned in the caption |
| `likesCount` | Number | Number of likes (null if hidden) |
| `commentsCount` | Number | Number of comments |
| `timestamp` | String | Publication date in ISO 8601 |
| `ownerUsername` | String | Author's Instagram username |
| `ownerId` | String | Author's internal Instagram user ID |
| `imageUrl` | String | Direct URL to the post image or thumbnail |

***

### Session cookies (optional)

For private posts or to avoid rate limiting on large batches, provide your Instagram session cookies:

1. Open Instagram in your browser and log in
2. Open DevTools → Application → Cookies → `https://www.instagram.com`
3. Copy the value of `sessionid` and `csrftoken`
4. Paste them in the **Session Cookies** field as: `sessionid=YOUR_VALUE; csrftoken=YOUR_VALUE`

***

### FAQ

**Does it work without login?**
Yes — all public posts are accessible without any credentials.

**Can I scrape multiple posts at once?**
Yes — add as many URLs as needed to the `postUrls` list.

**What if a post is private?**
Private posts require valid session cookies. The actor will log a clear error if the post is inaccessible.

**Will this get my account banned?**
The actor uses a stealth headless browser that mimics human behaviour. For large-scale use, enable Apify Proxy to rotate IPs.

# Actor input Schema

## `postUrls` (type: `array`):

List of Instagram post URLs to scrape

## `sessionCookies` (type: `string`):

Instagram session cookies for accessing more data.

## Actor input object example

```json
{
  "postUrls": [
    "https://www.instagram.com/p/SHORTCODE/"
  ]
}
```

# Actor output Schema

## `shortcode` (type: `string`):

Unique post identifier extracted from the URL.

## `url` (type: `string`):

Canonical Instagram post URL.

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

Image, Video, or Carousel.

## `caption` (type: `string`):

Full post caption text.

## `hashtags` (type: `string`):

List of hashtags extracted from the caption.

## `mentions` (type: `string`):

List of usernames mentioned in the caption.

## `likesCount` (type: `string`):

Number of likes on the post. Null if hidden.

## `commentsCount` (type: `string`):

Number of comments on the post.

## `timestamp` (type: `string`):

Publication date and time in ISO 8601 format.

## `ownerUsername` (type: `string`):

Instagram username of the post author.

## `ownerId` (type: `string`):

Internal Instagram user ID of the post author.

## `imageUrl` (type: `string`):

Direct URL to the post image or video thumbnail.

# 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 = {
    "postUrls": [
        "https://www.instagram.com/p/SHORTCODE/"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("leadsbrary/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 = { "postUrls": ["https://www.instagram.com/p/SHORTCODE/"] }

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

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Instagram Post Scraper",
        "description": "Extract data from any public Instagram post by URL. Get caption, likes, comments, hashtags, mentions, author username, image URL & timestamp instantly. No account needed — stealth browser bypasses bot detection.",
        "version": "1.0",
        "x-build-id": "1I2WIwTOib5fnh5Mq"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/leadsbrary~instagram-post-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-leadsbrary-instagram-post-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/leadsbrary~instagram-post-scraper/runs": {
            "post": {
                "operationId": "runs-sync-leadsbrary-instagram-post-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/leadsbrary~instagram-post-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-leadsbrary-instagram-post-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "postUrls"
                ],
                "properties": {
                    "postUrls": {
                        "title": "Post URLs",
                        "type": "array",
                        "description": "List of Instagram post URLs to scrape",
                        "items": {
                            "type": "string"
                        }
                    },
                    "sessionCookies": {
                        "title": "Session Cookies (optional)",
                        "type": "string",
                        "description": "Instagram session cookies for accessing more data."
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
