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

Scrape public Instagram posts for any hashtag without an Instagram login. Each result includes the post and the account that published it.

- **URL**: https://apify.com/datascrapers/instagram-hashtag-scraper.md
- **Developed by:** [Data Scrapers](https://apify.com/datascrapers) (community)
- **Features:** Limited permissions
- **Stats:** 1 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.20 / 1,000 posts

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

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

**Instagram Hashtag Scraper** creates a structured dataset of public posts collected from Instagram hashtag pages. Each dataset item can include the hashtag, post id, shortcode, caption, like count, comment count, and author username. Query the source with hashtags, search queries, or hashtag URLs, control the result limit with maxItems, and retrieve records through the Apify Dataset API or export them as JSON, CSV, Excel, XML, or another supported format.

[![Instagram Hashtag Scraper — input to structured data](https://raw.githubusercontent.com/faizanalii/apify-actor-assets/main/instagram-hashtag-scraper/instagram-hashtag-scraper-value-demo.gif)](https://apify.com/datascrapers/instagram-hashtag-scraper)

### Dataset at a glance

| Property | Value |
|---|---|
| Source | instagram.com |
| Record unit | One public hashtag post |
| Input methods | hashtags, searchQueries, startUrls |
| Main identifiers | post_id, shortcode |
| Delivery | Apify Dataset and API |
| Export formats | JSON, CSV, Excel, XML |
| Update model | Fresh records per Actor run |
| Pricing | $1.50 per 1,000 posts on the free plan |

### Coverage and available records

The Actor reads public hashtag results. It does not log in. A hashtag with no public posts yields nothing. searchQueries and hashtags accept the tag with or without a leading #. startUrls accepts Instagram hashtag URLs.

Each post row includes media type, counts, caption, thumbnail, and the public username. Private accounts and login walls are not collected. resultsPerHashtag limits one tag. maxItems limits the whole run. Both default to 0, which means no cap.

### Data dictionary

| Field | Type | Nullable | Description | Example |
|---|---|---:|---|---|
| hashtag | string | no | Hashtag that produced the post, without requiring a hash sign in the output. | exams |
| sourceQuery | string | yes | Input string that led to this tag. | exams |
| post_id | string | no | Instagram media id. Use this field to deduplicate. | 3975569312739622875 |
| shortcode | string | yes | Shortcode used in the post URL. | DcsDzn5yf_b |
| url | string | yes | Public post URL. | https://www.instagram.com/reel/DcsDzn5yf_b/ |
| media_type | string | yes | video, image, or carousel. | video |
| caption | string | yes | Post caption. | |
| like_count | number | yes | Public like count. | 334170 |
| comment_count | number | yes | Public comment count. | 2003 |
| play_count | number | yes | Play count when the media exposes one. | |
| username | string | yes | Public author username. | ashtoon_yt |
| taken_at | string | yes | Publish time in ISO 8601 UTC. | 2026-08-31T02:57:54+00:00 |
| is_verified | boolean | yes | Whether the author is verified. | false |

### Example dataset record

```json
{
  "hashtag": "exams",
  "post_id": "3975569312739622875",
  "shortcode": "DcsDzn5yf_b",
  "url": "https://www.instagram.com/reel/DcsDzn5yf_b/",
  "media_type": "video",
  "like_count": 334170,
  "comment_count": 2003,
  "username": "ashtoon_yt",
  "is_verified": false,
  "taken_at": "2026-08-31T02:57:54+00:00"
}
```

This row is a public reel stored from a hashtag query for exams. The saved record also includes the caption and thumbnail URL.

### Query and input reference

| Input | Type | Required | Default | Accepted values | Description |
|---|---|---:|---|---|---|
| hashtags | array | no | empty | tag strings | Hashtags to open. |
| searchQueries | array | no | empty | tag strings | Same role as hashtags. |
| startUrls | array | no | empty | hashtag URLs | Direct hashtag links. |
| resultsPerHashtag | integer | no | 0 | 0 or a positive integer | Cap per hashtag. 0 means no cap. |
| maxItems | integer | no | 0 | 0 or a positive integer | Cap for the run. |
| proxyConfiguration | object | no | Apify proxy off | Apify proxy input | Optional proxy. |

Minimal request:

```json
{"hashtags": ["exams"], "maxItems": 5}
```

### Retrieve the data through the API

Start the Actor with JSON input, wait for the run, then read the default dataset.

```python
from apify_client import ApifyClient

client = ApifyClient("<YOUR_API_TOKEN>")
run = client.actor("datascrapers/instagram-hashtag-scraper").call(run_input={
    "hashtags": ["exams"],
    "maxItems": 5,
})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item["post_id"], item.get("like_count"))
```

### Data quality and record handling

Deduplicate on post_id. The same post can appear under more than one hashtag in a single run when you pass several tags. like_count and comment_count are the public counts at request time. A hidden like count stays null rather than zero.

### Pricing and cost examples

Pay per event. The posts event is $1.50 per 1,000 on Free, $1.40 on Bronze, $1.30 on Silver, and $1.20 on Gold. Platinum and Diamond use the Gold price. Apify platform usage is billed separately. Saving 1,000 posts costs $1.50 in event fees on Free, plus platform usage.

### Limitations and responsible data use

The Actor collects public hashtag posts. It does not post, follow, or send messages. Instagram can hide counts or block a session. Use the data in line with Instagram terms and privacy rules.

### Dataset questions

#### What is one record?

One public post from a hashtag page, keyed by post_id.

#### Which field should I use to deduplicate?

post_id.

#### Do I need an Instagram account?

No. The Actor reads public hashtag results.

### Related datasets from Data Scrapers

- [Instagram Email Scraper](https://apify.com/datascrapers/instagram-email-scraper)
- [YouTube Channel Scraper](https://apify.com/datascrapers/youtube-channel-scraper)
- [Reddit Scraper](https://apify.com/datascrapers/reddit-scraper)
- [Trustpilot Scraper](https://apify.com/datascrapers/trustpilot-scraper)

### Data Scrapers support

Questions about this dataset: stardustspotlight@gmail.com.

# Actor input Schema

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

Hashtags to scrape, with or without #. For example: exams or #exams.

## `hashtags` (type: `array`):

Same as Hashtags. For example: exams. Use this or searchQueries.

## `startUrls` (type: `array`):

Optional Instagram hashtag URLs, such as https://www.instagram.com/explore/tags/exams/.

## `resultsPerHashtag` (type: `integer`):

Maximum posts to scrape for each hashtag. 0 means no per-hashtag cap (still bounded by Max items).

## `maxItems` (type: `integer`):

Maximum posts to scrape across all hashtags. 0 means unlimited.

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

Proxy settings. Residential proxies are recommended.

## Actor input object example

```json
{
  "searchQueries": [
    "exams"
  ],
  "resultsPerHashtag": 100,
  "maxItems": 100,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

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

JSON array of scraped posts

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

Record count and timestamps for this run

# 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": [
        "exams"
    ],
    "resultsPerHashtag": 100,
    "maxItems": 100,
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("datascrapers/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 = {
    "searchQueries": ["exams"],
    "resultsPerHashtag": 100,
    "maxItems": 100,
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
    },
}

# Run the Actor and wait for it to finish
run = client.actor("datascrapers/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 '{
  "searchQueries": [
    "exams"
  ],
  "resultsPerHashtag": 100,
  "maxItems": 100,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}' |
apify call datascrapers/instagram-hashtag-scraper --silent --output-dataset

```

## MCP server setup

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