# Instagram Scraper (`logical_variety/instagram`) Actor

Scrape Instagram profiles, posts, reels, stories, highlights, followers, and followings. Get comments and likers for any post, plus tagged posts. Fetch by username, user ID, or post URL — raw JSON output with full metadata, pagination support, and API-ready results for automation.

- **URL**: https://apify.com/logical\_variety/instagram.md
- **Developed by:** [Logical Variety](https://apify.com/logical_variety) (community)
- **Categories:** Social media
- **Stats:** 1 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

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

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 Scraper

Fetch structured Instagram data through a single Actor. Pick an **action** and
provide its inputs — the Actor returns the raw JSON for that request in the
dataset.

### What you can fetch

| Action             | Fetches                    | Required input            | Optional        |
|--------------------|----------------------------|---------------------------|-----------------|
| `userInfo`         | User profile / account info | `userId` or `username`    | —               |
| `stories`          | Active stories             | `userId` or `username`    | —               |
| `highlights`       | Highlight tray             | `userId` or `username`    | —               |
| `highlightStories` | Items inside a highlight   | `highlightId`             | —               |
| `posts`            | Timeline posts             | `userId` or `username`    | `maxId`         |
| `reels`            | Reels                      | `userId` or `username`    | `maxId`         |
| `taggedPosts`      | Tagged posts               | `userId` or `username`    | `maxId`         |
| `followers`        | Followers                  | `userId` or `username`    | `maxId`         |
| `followings`       | Followings                 | `userId` or `username`    | `maxId`, `count`|
| `likers`           | Users who liked a post     | `url` or `shortcode`      | —               |
| `comments`         | Comments on a post         | `url` or `shortcode`      | `minId`         |

### Input

Provide `action` plus the fields it needs (see the table above). Example:

```json
{ "action": "posts", "username": "nasa" }
```

```json
{ "action": "comments", "shortcode": "C1a2b3c4d5", "minId": "..." }
```

### Output

The run's dataset contains **one item** — the raw response for your request,
under a `result` key:

```json
{ "result": { "count": 4849, "items": [ ... ], "page_info": { "end_cursor": "..." } } }
```

- List endpoints (`stories`, `highlights`, `highlightStories`) return an array
  in `result`.
- The shape of `result` matches the underlying Instagram data for that action.

#### Pagination

Paginated actions return a cursor (`next_max_id` / `next_min_id` /
`end_cursor`). To fetch the next page, run the Actor again passing that cursor as
`maxId` (or `minId` for comments). Each run returns a single page.

### Run via API

```bash
curl -X POST \
  "https://api.apify.com/v2/acts/<ORG>~instagram/run-sync-get-dataset-items?token=<APIFY_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{ "action": "posts", "username": "nasa" }'
```

The response is an array of dataset items; your data is in `items[0].result`.

### Pricing

This Actor is offered on a **monthly rental** basis. Platform usage (compute)
is billed to your Apify account as usual.

### Notes

- Validation happens before any network call: an unknown `action` or a missing
  required field returns a clear error.
- Business responses from Instagram (e.g. "page not found", private account) are
  returned as-is in the dataset (`{ "success": false, "message": ... }`), so you
  can handle them programmatically.

# Actor input Schema

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

What to fetch. Each option lists the fields it requires.

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

Instagram username (e.g. "nasa").

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

Numeric Instagram user ID.

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

Instagram post URL. Used by the likers and comments actions.

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

Instagram post shortcode. Alternative to Post URL for the likers and comments actions.

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

Instagram highlight ID. Used by the highlightStories action.

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

Forward pagination cursor. Pass the next\_max\_id from a previous response to fetch the next page. Optional.

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

Pagination cursor for comments. Pass the next\_min\_id from a previous response. Optional.

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

Number of items to request. Applies to the followings action only. Optional.

## Actor input object example

```json
{}
```

# 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("logical_variety/instagram").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("logical_variety/instagram").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 logical_variety/instagram --silent --output-dataset

```

## MCP server setup

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

```

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/csefwzZW6nrlaTi4S/builds/t6QBSDJyhHKXcifRW/openapi.json
