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

Search Instagram by hashtag or keyword for matching posts and reels. Get post code, like count, comment count, post date, and media type for every hit, with full media detail available for thin results. No Instagram login or cookies needed to search public content.

- **URL**: https://apify.com/toolzerhub/instagram-hashtag-keyword-scraper.md
- **Developed by:** [ToolzerHub](https://apify.com/toolzerhub) (community)
- **Categories:** Social media, Marketing, Automation
- **Stats:** 1 total users, 1 monthly users, 90.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.85 / 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.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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 & Keyword Search Scraper

Search Instagram by hashtag or by keyword and export the public media it returns. No login, no cookie, no session.

This is the discovery entry point — it starts from a subject rather than an account, so you don't need to know who posts about something to find the posts.

### Input

| Field | Type | Default | What it does |
|---|---|---|---|
| `scraperType` | enum | `hashtagMedia` | **Required.** See the table below. |
| `hashtag` | string | — | Hashtag to search, no `#`. Hashtag mode only. |
| `keyword` | string | — | Search term. Keyword modes only. |
| `tab` | enum | `recent` | `recent` or `top`. Hashtag mode only. |
| `limit` | integer | `100` | Rows to save. `0` pulls everything available. |
| `addonMediaDetails` | boolean | `false` | Swaps each thin hit for its full media record. |

| `scraperType` | Searches | Uses |
|---|---|---|
| `hashtagMedia` | A hashtag | `hashtag`, `tab` |
| `postsByKeyword` | Posts matching a keyword | `keyword` |
| `reelsByKeyword` | Reels matching a keyword | `keyword` |

```json
{
  "scraperType": "hashtagMedia",
  "hashtag": "streetphotography",
  "tab": "recent",
  "limit": 200
}
```

**Fill the field the mode reads.** Hashtag mode ignores `keyword`; the keyword modes ignore `hashtag` and `tab`. Filling the wrong one leaves the run with nothing to search.

### Output

| Field | What it holds |
|---|---|
| `pk` | Instagram media ID |
| `code` | Shortcode — the identifier in a post URL |
| `like_count` | Likes |
| `comment_count` | Comments |
| `taken_at` | When it was posted |
| `media_type` | Image, video, or carousel |
| `enriched` | Whether full media details were fetched |

```json
{
  "pk": "3412987456123456789",
  "code": "DDPp2UWzWEm",
  "like_count": 4821,
  "comment_count": 63,
  "taken_at": 1785312000,
  "enriched": false
}
```

Keep `code` — it feeds [Instagram Media Engagement](https://apify.com/toolzerhub/instagram-media-engagement-scraper) for comments and likers.

### `recent` vs `top`

`recent` is chronological: what's being posted under the tag right now. Use it for monitoring, and for diffing one run against the next — the ordering is stable.

`top` is Instagram's ranking of the tag's best-performing posts. Use it for research into what works. It reshuffles between runs, so it's poor for tracking change.

### Questions

**Is this every post using the hashtag?**
No. Instagram serves a bounded window rather than a full tag archive. A hashtag with 40 million posts will not return 40 million rows, whatever `limit` says. You get a substantial slice in Instagram's ordering.

**Hashtag or keyword — what's the difference?**
Hashtag mode searches the tag itself, so it only finds posts the author explicitly tagged. Keyword modes search more broadly and catch posts that discuss a subject without tagging it — which is often where the honest conversation is, since tags are chosen for reach.

**Why did my run return nothing?**
Almost always the wrong field for the mode. `hashtagMedia` reads `hashtag`; `postsByKeyword` and `reelsByKeyword` read `keyword`. A keyword sitting in `hashtag` while the mode is Keyword Posts gives the run nothing to search.

**Should the hashtag include `#`?**
No — pass it bare. `streetphotography`, not `#streetphotography`.

**What does `addonMediaDetails` add, and what does it cost?**
Search and hashtag results come back thin. The addon swaps each for its full media record — like and comment counts, owner details. One extra request and one billable event per item, so 500 results is 500 extra requests. Search thin first, enrich the subset worth it.

**Do keyword reels and keyword posts overlap?**
They can. Instagram surfaces reels in general results too, so `postsByKeyword` may include reels. `reelsByKeyword` is the reliable way to isolate them.

**Do I need an Instagram login?**
No. Nothing logs in and no session is passed.

### Other Instagram Actors

| Actor | Use when |
|---|---|
| [Instagram Media Engagement](https://apify.com/toolzerhub/instagram-media-engagement-scraper) | You want comments and likers (needs `code`) |
| [Instagram User Search](https://apify.com/toolzerhub/instagram-user-search-scraper) | You want accounts rather than posts |
| [Instagram Profile Content](https://apify.com/toolzerhub/instagram-profile-content-scraper) | You want one account's whole output |
| [Instagram Followers & Following](https://apify.com/toolzerhub/instagram-profile-follower-followee-scraper) | You want an account's audience |

### Support

Questions, bugs, or feature requests: **contact@toolzerhub.com**

Browse the rest: [apify.com/toolzerhub](https://apify.com/toolzerhub)

# Actor input Schema

## `scraperType` (type: `string`):

Search by hashtag, or by keyword across posts or reels.

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

Hashtag to search for, without the # prefix. Only used when Search Mode is Hashtag.

## `keyword` (type: `string`):

Search keyword. Only used when Search Mode is Keyword Posts, Keyword Reels, or for User Search.

## `tab` (type: `string`):

Recent or top posts for the hashtag. Only used when Search Mode is Hashtag.

## `limit` (type: `integer`):

Stop after this many rows per account (0 = pull the whole list)

## `addonMediaDetails` (type: `boolean`):

Swap each thin search/hashtag hit for its full media details (likes, comments count, owner). Adds a billable event per item.

## Actor input object example

```json
{
  "scraperType": "hashtagMedia",
  "hashtag": "tokyo",
  "keyword": "tokyo",
  "tab": "recent",
  "limit": 100,
  "addonMediaDetails": false
}
```

# Actor output Schema

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

Every record collected during 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 = {
    "hashtag": "tokyo",
    "keyword": "tokyo"
};

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

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

```

## MCP server setup

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