# Instagram Scraper Pro (`agenscrape/instagram-scraper-pro`) Actor

Extract Instagram data at scale. Get user profiles, posts, reels, comments, hashtag feeds, and more with a simple API.

- **URL**: https://apify.com/agenscrape/instagram-scraper-pro.md
- **Developed by:** [Agenscrape](https://apify.com/agenscrape) (community)
- **Categories:** Social media, Agents, AI
- **Stats:** 44 total users, 2 monthly users, 92.3% runs succeeded, 3 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/platform/actors/running/actors-in-store#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 Pro

Extract Instagram data at scale. Get user profiles, posts, reels, comments, hashtag feeds, and more with a simple API.

### What can this actor do?

- **Get Profile Data** - Extract full profile information from any public Instagram account by username
- **Convert Username to User ID** - Look up the numeric user ID for any Instagram username
- **Get User Posts** - Fetch the latest posts from any public profile
- **Get User Reels** - Extract reels/short videos from Instagram profiles
- **Get Media Details** - Get complete information about any Instagram post or reel
- **Search Users** - Search for Instagram users by keyword
- **Get Hashtag Feed** - Extract posts from any hashtag
- **Get Explore Page** - Fetch trending content from Instagram's explore page
- **Get Comments** - Extract comments from any post
- **Get Reels Audio** - Get information about audio tracks used in reels

### Input Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `action` | string | Yes | The action to perform (see actions below) |
| `userId` | string | For some actions | Instagram numeric User ID |
| `username` | string | For some actions | Instagram username (without @) |
| `mediaId` | string | For some actions | Instagram Media/Post ID |
| `query` | string | For searchUsers | Search query |
| `audioClusterId` | string | For reelsAudio | Audio cluster ID |
| `hashtag` | string | For hashtagFeed | Hashtag (without #) |
| `count` | integer | No | Number of results (default: 12, max: 50) |
| `maxRetries` | integer | No | Retry attempts on failure (default: 3) |

### Available Actions

| Action | Required Input | Description |
|--------|----------------|-------------|
| `usernameToUserId` | username | Get full profile data from username |
| `userInfo` | userId | Get profile data from user ID |
| `userPosts` | userId | Get user's recent posts |
| `userReels` | userId | Get user's reels |
| `mediaInfo` | mediaId | Get details of a specific post |
| `searchUsers` | query | Search for users |
| `hashtagFeed` | hashtag | Get posts from a hashtag |
| `explorePage` | - | Get explore page content |
| `mediaComments` | mediaId | Get comments on a post |
| `reelsAudio` | audioClusterId | Get audio track info |

### Example Input

```json
{
  "action": "usernameToUserId",
  "username": "instagram"
}
```

### Example Output

```json
{
  "action": "usernameToUserId",
  "success": true,
  "username": "instagram",
  "userId": "25025320",
  "fullName": "Instagram",
  "biography": "Discover what's new on Instagram",
  "followersCount": 697458483,
  "followingCount": 290,
  "postsCount": 8246,
  "isPrivate": false,
  "isVerified": true,
  "profilePicUrl": "https://...",
  "profilePicUrlHd": "https://...",
  "externalUrl": "http://help.instagram.com/"
}
```

### Output Fields

Each response includes a `success` field indicating whether the request was successful.

**Profile Data:**

- `userId` - Numeric user ID
- `username` - Instagram handle
- `fullName` - Display name
- `biography` - Profile bio
- `followersCount` - Number of followers
- `followingCount` - Number following
- `postsCount` - Total posts
- `isPrivate` - Privacy status
- `isVerified` - Verification badge
- `profilePicUrl` - Profile picture URL
- `externalUrl` - Website link

**Post/Media Data:**

- `mediaId` - Post ID
- `mediaType` - photo/video/carousel
- `caption` - Post caption
- `likesCount` - Number of likes
- `commentsCount` - Number of comments
- `imageUrl` - Image URL
- `videoUrl` - Video URL (if applicable)

### Error Handling

When a profile or resource is not found, the actor returns a clear error message:

```json
{
  "action": "usernameToUserId",
  "success": false,
  "error": "User not found - profile does not exist or has been deleted",
  "username": "nonexistent_user"
}
```

### Tips

- Use `usernameToUserId` to get the richest profile data including follower counts
- The `userId` is required for fetching posts and reels - get it first using `usernameToUserId`
- Private accounts will return limited data
- Increase `maxRetries` if you're experiencing timeouts

# Actor input Schema

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

Select the scraping action to perform

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

Instagram User ID (required for userInfo, userPosts, userReels)

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

Instagram username without @ (required for usernameToUserId)

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

Instagram Media/Post ID (required for mediaInfo, mediaComments)

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

Search query for finding users (required for searchUsers)

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

Audio cluster ID for reels audio page (required for reelsAudio)

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

Hashtag without # (required for hashtagFeed)

## `count` (type: `integer`):

Number of results to fetch (where applicable)

## `maxRetries` (type: `integer`):

Maximum number of retries on failed requests

## Actor input object example

```json
{
  "action": "usernameToUserId",
  "userId": "25025320",
  "username": "instagram",
  "mediaId": "3525629751498956059",
  "query": "travel",
  "audioClusterId": "243313498203629",
  "hashtag": "photography",
  "count": 12,
  "maxRetries": 3
}
```

# 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 = {
    "action": "usernameToUserId",
    "userId": "25025320",
    "username": "instagram",
    "mediaId": "3525629751498956059",
    "query": "travel",
    "audioClusterId": "243313498203629",
    "hashtag": "photography",
    "count": 12,
    "maxRetries": 3
};

// Run the Actor and wait for it to finish
const run = await client.actor("agenscrape/instagram-scraper-pro").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 = {
    "action": "usernameToUserId",
    "userId": "25025320",
    "username": "instagram",
    "mediaId": "3525629751498956059",
    "query": "travel",
    "audioClusterId": "243313498203629",
    "hashtag": "photography",
    "count": 12,
    "maxRetries": 3,
}

# Run the Actor and wait for it to finish
run = client.actor("agenscrape/instagram-scraper-pro").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 '{
  "action": "usernameToUserId",
  "userId": "25025320",
  "username": "instagram",
  "mediaId": "3525629751498956059",
  "query": "travel",
  "audioClusterId": "243313498203629",
  "hashtag": "photography",
  "count": 12,
  "maxRetries": 3
}' |
apify call agenscrape/instagram-scraper-pro --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/cuCxyk3PO6aYVc8Y9/builds/iH0DEACg7Whlfja6j/openapi.json
