# Instagram Hashtag Scraper (`eben002/instagram-hashtag-scraper`) Actor

API-based, high-speed Instagram hashtag scraper powered by Crawlee & Playwright with proxy rotation and no DOM dependency.

- **URL**: https://apify.com/eben002/instagram-hashtag-scraper.md
- **Developed by:** [Ezek O](https://apify.com/eben002) (community)
- **Categories:** Social media, AI
- **Stats:** 2 total users, 1 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$3.00 / 1,000 result-items

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 Hashtag Scraper

A high-performance, production-ready Apify Actor for extracting Instagram posts by hashtag. Built using **Crawlee** for Python and **Playwright**, this actor features **API-first network interception**, eliminating reliance on volatile HTML DOM classes.

> **Updated for 2026: Uses internal API sniffing for 10x faster results and zero DOM-dependency issues.**

***

### ⚡ Features

- **🚀 API-First Architecture**: Intercepts direct XHR/Fetch GraphQL and REST responses (`graphql/query` & `api/v1/tags/web_info`). No fragile HTML scraping or DOM selector reliance.
- **⚡ High-Speed & Lightweight**: Rapid JSON parsing directly from intercepted network payloads.
- **🛡️ Proxy Rotation & Session Pool**: Full Apify Proxy integration (Residential proxies recommended) with automatic IP rotation to bypass Instagram anti-bot checks.
- **🔄 Robust 429 Handling**: Automatically detects HTTP 429 Rate Limited responses, retires affected proxy sessions, and safely retries requests.
- **💰 Pay-per-Result Billing**: Built-in `Actor.charge('result-item', count=N)` monetization model. You only pay for valid extracted posts.

***

### 📥 Input Parameters

| Parameter | Type | Required | Default | Description |
| :--- | :--- | :--- | :--- | :--- |
| `hashtag` | String | **Yes** | — | Instagram hashtag to scrape (without `#` symbol, e.g. `photography`). |
| `max_items` | Integer | No | `50` | Maximum number of posts to extract. |
| `proxy_configuration` | Object | No | `{"useApifyProxy": true}` | Apify Proxy configuration. Residential proxies are strongly recommended. |

#### Example Input

```json
{
  "hashtag": "nature",
  "max_items": 50,
  "proxy_configuration": {
    "useApifyProxy": true,
    "apifyProxyGroups": ["RESIDENTIAL"]
  }
}
```

***

### 📤 Output Data Schema

Each extracted item in the dataset follows a standardized, clean JSON schema:

```json
{
  "url": "https://www.instagram.com/p/C_xY1z2S345/",
  "caption": "Exploring the majestic mountains! #nature #landscape #photography",
  "shortcode": "C_xY1z2S345",
  "owner_username": "photographer_john",
  "like_count": 1420,
  "comment_count": 89,
  "timestamp": 1722355200
}
```

#### Output Fields

- `url` (*string*): Direct URL to the Instagram post.
- `caption` (*string*): Full caption text of the post.
- `shortcode` (*string*): Unique Instagram post shortcode ID.
- `owner_username` (*string*): Username of the post creator.
- `like_count` (*integer*): Total number of likes.
- `comment_count` (*integer*): Total number of comments.
- `timestamp` (*integer*): Post publication Unix epoch timestamp.

***

### 🛠️ Local Development & Deployment

#### Run Locally

1. Install dependencies:
   ```bash
   pip install -r requirements.txt
   ```
2. Run Playwright browser install:
   ```bash
   playwright install chromium
   ```
3. Execute the actor locally:
   ```bash
   apify run
   ```

#### Deploy to Apify

Deploy directly using the Apify CLI:

```bash
apify push
```

***

### 📜 License

Apache-2.0

# Actor input Schema

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

Instagram hashtag to scrape (without the # symbol, e.g. 'nature').

## `max_items` (type: `integer`):

Maximum number of posts to extract.

## `proxy_configuration` (type: `object`):

Select proxies to be used by your crawler. Residential proxies are strongly recommended for Instagram.

## Actor input object example

```json
{
  "hashtag": "photography",
  "max_items": 50,
  "proxy_configuration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

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

Default dataset containing extracted Instagram posts

# 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 = {
    "hashtag": "photography"
};

// Run the Actor and wait for it to finish
const run = await client.actor("eben002/instagram-hashtag-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 = { "hashtag": "photography" }

# Run the Actor and wait for it to finish
run = client.actor("eben002/instagram-hashtag-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 '{
  "hashtag": "photography"
}' |
apify call eben002/instagram-hashtag-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,eben002/instagram-hashtag-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/OMjon1Ylikq66lHCa/builds/dZj0AsippCOcBOzb2/openapi.json
