# Instagram Profile Hastag Scraper (`compx_pro/instagram-profile-hastag-scraper`) Actor

xtract public Instagram profile, hashtag, and post data including followers, engagement, bios, websites, contact details, and recent content. Perfect for lead generation, influencer research, competitor analysis, and social media monitoring.

- **URL**: https://apify.com/compx\_pro/instagram-profile-hastag-scraper.md
- **Developed by:** [Sonjoy Bairagee](https://apify.com/compx_pro) (community)
- **Categories:** Social media, Lead generation
- **Stats:** 2 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-usage

## 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 Profile & Hashtag Scraper

An Apify Actor that scrapes **Instagram profiles** and **hashtag posts** without requiring the official API.

---

### Features

- **Profile Scraper**: Extracts username, full name, bio, followers, following, post count, verification status, and individual post data
- **Hashtag Scraper**: Extracts top posts and recent posts for any hashtag with likes, captions, timestamps, and more
- **Post Details**: Image URL, caption, likes, comments count, timestamp, location, hashtags, mentions
- **Optional Comments**: Scrape comments on each post (configurable limit)
- **Anti-detection**: Random delays, fingerprint spoofing, proxy support
- **Proxy Support**: Works with Apify Residential Proxies (recommended) or your own proxies
- **Session Cookies**: Optionally provide login cookies for better access

---

### Input Configuration

| Field | Type | Default | Description |
|---|---|---|---|
| `scrapeType` | string | `"both"` | `"profile"`, `"hashtag"`, or `"both"` |
| `usernames` | array | `[]` | Instagram usernames (without @) |
| `hashtags` | array | `[]` | Hashtags to scrape (without #) |
| `maxPostsPerProfile` | integer | `12` | Max posts per profile (1–200) |
| `maxPostsPerHashtag` | integer | `20` | Max posts per hashtag (1–500) |
| `scrapeComments` | boolean | `false` | Whether to scrape post comments |
| `maxCommentsPerPost` | integer | `10` | Max comments per post |
| `proxy` | object | Apify Residential | Proxy configuration |
| `loginCookies` | array | `[]` | Optional Instagram session cookies |

---

### Example Input

```json
{
  "scrapeType": "both",
  "usernames": ["natgeo", "nasa"],
  "hashtags": ["travel", "photography"],
  "maxPostsPerProfile": 20,
  "maxPostsPerHashtag": 30,
  "scrapeComments": false,
  "proxy": {
    "useApifyProxy": true,
    "apifyProxyGroups": ["RESIDENTIAL"]
  }
}
````

***

### Output Data Format

#### Profile Result

```json
{
  "type": "profile",
  "scrapedAt": "2024-01-15T10:30:00.000Z",
  "username": "natgeo",
  "fullName": "National Geographic",
  "biography": "The official Instagram of National Geographic...",
  "followers": 280500000,
  "following": 152,
  "postsCount": 30800,
  "isVerified": true,
  "isPrivate": false,
  "profilePicUrl": "https://...",
  "externalUrl": "https://www.nationalgeographic.com",
  "isBusiness": true,
  "posts": [
    {
      "postId": "123456",
      "shortCode": "ABC123",
      "postUrl": "https://www.instagram.com/p/ABC123/",
      "type": "GraphImage",
      "imageUrl": "https://...",
      "caption": "Amazing photo caption #nature",
      "likesCount": 150000,
      "commentsCount": 1200,
      "timestamp": "2024-01-14T12:00:00.000Z",
      "isVideo": false,
      "locationName": "Yellowstone National Park",
      "hashtags": ["#nature", "#wildlife"],
      "mentions": []
    }
  ]
}
```

#### Hashtag Result

```json
{
  "type": "hashtag",
  "scrapedAt": "2024-01-15T10:30:00.000Z",
  "hashtag": "travel",
  "hashtagUrl": "https://www.instagram.com/explore/tags/travel/",
  "totalPostsCount": 650000000,
  "posts": [
    {
      "postId": "789012",
      "shortCode": "XYZ789",
      "postUrl": "https://www.instagram.com/p/XYZ789/",
      "hashtag": "travel",
      "imageUrl": "https://...",
      "caption": "Beautiful destination! #travel #adventure",
      "likesCount": 5200,
      "commentsCount": 89,
      "timestamp": "2024-01-15T08:00:00.000Z",
      "ownerUsername": "someuser",
      "isVideo": false
    }
  ]
}
```

***

### Setup on Apify

1. Go to [Apify Console](https://console.apify.com) → **Actors** → **Create new**
2. Upload all files from this folder
3. Set the Dockerfile as the build source
4. Configure your input in the **Input** tab
5. Click **Run**

### Getting Instagram Cookies (Optional but Recommended)

For better scraping results, provide your Instagram session cookies:

1. Log into Instagram in your browser
2. Open DevTools → Application → Cookies → `instagram.com`
3. Copy cookies (especially `sessionid`, `csrftoken`, `ds_user_id`)
4. Paste them as an array in the `loginCookies` input field

***

### Important Notes

- **Rate Limiting**: Instagram aggressively rate-limits scrapers. Use residential proxies and keep delays between requests.
- **Private Profiles**: Private profiles cannot be scraped without being a follower.
- **Terms of Service**: Scraping Instagram may violate their ToS. Use responsibly and for personal/research purposes only.
- **Proxy**: Using Apify Residential Proxies (`RESIDENTIAL` group) is strongly recommended to avoid blocks.

***

### Troubleshooting

| Issue | Solution |
|---|---|
| Empty results | Add session cookies or use residential proxy |
| Rate limit errors | Increase delays, reduce concurrency |
| Private profile | Must follow the account first |
| Login wall | Provide `loginCookies` in input |

# Actor input Schema

## `searchQueries` (type: `array`):

YouTube search keywords

## `channelUrls` (type: `array`):

YouTube channel URLs to scrape

## `videoUrls` (type: `array`):

Direct YouTube video URLs

## `maxVideosPerChannel` (type: `integer`):

Maximum videos to scrape per channel

## `maxResultsPerSearch` (type: `integer`):

Maximum videos per search query

## `scrapeComments` (type: `boolean`):

Extract top comments from each video

## `maxCommentsPerVideo` (type: `integer`):

Maximum comments per video

## `scrapeChannel` (type: `boolean`):

Extract channel details (subscribers, description, etc)

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

Proxy settings

## Actor input object example

```json
{
  "searchQueries": [
    "python tutorial 2024"
  ],
  "channelUrls": [],
  "videoUrls": [],
  "maxVideosPerChannel": 30,
  "maxResultsPerSearch": 20,
  "scrapeComments": false,
  "maxCommentsPerVideo": 20,
  "scrapeChannel": true,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# 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 = {
    "searchQueries": [
        "python tutorial 2024"
    ],
    "channelUrls": [],
    "videoUrls": [],
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("compx_pro/instagram-profile-hastag-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 = {
    "searchQueries": ["python tutorial 2024"],
    "channelUrls": [],
    "videoUrls": [],
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("compx_pro/instagram-profile-hastag-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 '{
  "searchQueries": [
    "python tutorial 2024"
  ],
  "channelUrls": [],
  "videoUrls": [],
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call compx_pro/instagram-profile-hastag-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Instagram Profile Hastag Scraper",
        "description": "xtract public Instagram profile, hashtag, and post data including followers, engagement, bios, websites, contact details, and recent content. Perfect for lead generation, influencer research, competitor analysis, and social media monitoring.",
        "version": "0.0",
        "x-build-id": "rfqCgxg8RROLtmOSK"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/compx_pro~instagram-profile-hastag-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-compx_pro-instagram-profile-hastag-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/compx_pro~instagram-profile-hastag-scraper/runs": {
            "post": {
                "operationId": "runs-sync-compx_pro-instagram-profile-hastag-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/compx_pro~instagram-profile-hastag-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-compx_pro-instagram-profile-hastag-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",
                "properties": {
                    "searchQueries": {
                        "title": "Search Queries",
                        "type": "array",
                        "description": "YouTube search keywords",
                        "items": {
                            "type": "string"
                        }
                    },
                    "channelUrls": {
                        "title": "Channel URLs",
                        "type": "array",
                        "description": "YouTube channel URLs to scrape",
                        "items": {
                            "type": "string"
                        }
                    },
                    "videoUrls": {
                        "title": "Video URLs",
                        "type": "array",
                        "description": "Direct YouTube video URLs",
                        "items": {
                            "type": "string"
                        }
                    },
                    "maxVideosPerChannel": {
                        "title": "Max Videos Per Channel",
                        "minimum": 1,
                        "maximum": 500,
                        "type": "integer",
                        "description": "Maximum videos to scrape per channel",
                        "default": 30
                    },
                    "maxResultsPerSearch": {
                        "title": "Max Results Per Search",
                        "minimum": 1,
                        "maximum": 100,
                        "type": "integer",
                        "description": "Maximum videos per search query",
                        "default": 20
                    },
                    "scrapeComments": {
                        "title": "Scrape Comments",
                        "type": "boolean",
                        "description": "Extract top comments from each video",
                        "default": false
                    },
                    "maxCommentsPerVideo": {
                        "title": "Max Comments Per Video",
                        "minimum": 1,
                        "maximum": 100,
                        "type": "integer",
                        "description": "Maximum comments per video",
                        "default": 20
                    },
                    "scrapeChannel": {
                        "title": "Scrape Channel Info",
                        "type": "boolean",
                        "description": "Extract channel details (subscribers, description, etc)",
                        "default": true
                    },
                    "proxyConfiguration": {
                        "title": "Proxy Configuration",
                        "type": "object",
                        "description": "Proxy settings"
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
