# Instagram Search Scraper - Keywords & Hashtags (`dataspryva/instagram-search-scraper-keywords-and-hashtags`) Actor

Scrape Instagram posts and reels by keyword or hashtag. Add one or more search terms and get post links, captions, hashtags, usernames, photos, videos, likes and comments. Export to JSON, CSV or Excel. Good for trend research, content ideas and brand monitoring.

- **URL**: https://apify.com/dataspryva/instagram-search-scraper-keywords-and-hashtags.md
- **Developed by:** [Dataspryva](https://apify.com/dataspryva) (community)
- **Categories:** Social media, Automation, Lead generation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 results

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/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 Search Scraper - Keywords & Hashtags

Type in a topic, a phrase or a hashtag and get back the public Instagram posts that show up for it. Every post comes with its link, caption, hashtags and mentions, photos and videos, likes and comments, tagged accounts and details about the account that posted it. Run several keywords in one go and each result is labelled with the keyword that found it. It suits marketers, social media managers, agencies and researchers who want to see what Instagram surfaces for a subject without scrolling through the app.

### What this actor does

- **Searches by keyword or hashtag:** single words (`travel`), multi-word phrases (`sunset photography`) and hashtags (`#nature`) all work, and you can list as many as your plan allows in one run.
- **Labels every post with its keyword:** the `input_keyword` field tells you which search produced which post, so one dataset can hold a whole topic list.
- **Returns full post details, not just links:** caption, hashtags, mentions, media files, likes, comments, tagged users, collaborators and location.
- **Shows who posted it:** a nested author block with name, verified badge and profile link.
- **Clear status for every post:** posts that are deleted, private or age-restricted come back with a clear `status` instead of silently vanishing.

### Output per post

Each result is one Instagram post that appeared for a keyword.

- `input_keyword` – the keyword or hashtag that produced this post
- `post_url` – link to the post on Instagram
- `shortcode` – the short code in the post link
- `post_id` – Instagram's numeric ID for the post
- `username` – the account that published the post
- `author_meta` – details about the author: `id`, `username`, `full_name`, `is_verified`, `profile_pic_url`, `profile_url`
- `caption` – the caption text
- `hashtags` – hashtags found in the caption
- `mentions` – accounts @mentioned in the caption
- `pub_date` – when the post was published (ISO 8601)
- `media_type` – `Photo`, `Video`, `Reel`, `Carousel` or `IGTV`
- `media_count` – number of photos/videos in the post (more than 1 for carousels)
- `thumbnail_url` – link to the cover or display image
- `media_items` – one entry per photo or video with its `index`, `type`, `url`, `width` and `height`; videos also carry `duration` and `has_audio`
- `accessibility_caption` – Instagram's image description text, when there is one (otherwise an empty string)
- `like_count` – number of likes (empty when the author hides likes)
- `comment_count` – number of comments
- `likes_hidden` – `true` if the author hides the like count
- `comments_disabled` – `true` if comments are turned off
- `tagged_users` – accounts tagged in the post
- `collaborators` – co-authors of the post
- `caption_is_edited` – `true` if the caption was changed after posting
- `location` – the tagged place (name, ID, coordinates), or empty when none is tagged
- `music` – the audio attached to a Reel (artist, title, audio ID and similar), or empty when there is none
- `status` – `success` for a collected post, otherwise the reason there is none (see "Status values")
- `scraped_at` – when the post was collected (UTC)

#### Status values

A post that was found and collected is `success`. Anything else is a record with a `status` that names the cause; the reason, which keyword or post it was and what you can do about it, is written in the run log.

For a post:

- `post_not_found` – the post is deleted or unavailable.
- `post_age_restricted` – the post sits behind an age restriction on the account.
- `post_is_private` – the post belongs to a private account.
- `error` / `blocked` – the post could not be loaded after several attempts.
- `invalid_url` – the link found for the post did not look like a valid Instagram post link.

For a keyword that gave no posts:

- `no_results` – Instagram's search returned no posts for the keyword.
- `cookies_unusable` – Instagram did not accept the cookies used for the search, so the keyword could not be searched.
- `blocked` – Instagram kept refusing the search requests; run it again later.
- `error` – the search could not be completed; run it again later.

A record of a post that could not be collected holds only `post_url`, `input_keyword` and `status`. A record of a keyword that gave no posts holds only `input_keyword` and `status`.

The run log shows one block per keyword, with the posts found for it listed underneath, and ends with a `Done:` summary. While the run is going, the status message shows a live count such as `Searched 2/5 keywords`.

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `keywords` | array | – | **Required.** Keywords, phrases or hashtags to search. Each entry can be up to 100 characters; duplicates are skipped. |
| `maxPosts` | integer | `100` | Maximum number of posts to collect per keyword (1 to 10000). |
| `cookies` | string | – | Optional. Your Instagram cookies as a JSON array. Leave empty to use a managed session (see Authentication). |

#### Example: one broad topic

```json
{
  "keywords": ["travel"],
  "maxPosts": 100
}
```

#### Example: compare several topics in one run

```json
{
  "keywords": ["sunset photography", "streetfood", "#nature"],
  "maxPosts": 50
}
```

#### Example: watch a campaign hashtag

```json
{
  "keywords": ["#nikeairmax", "#justdoit"],
  "maxPosts": 300
}
```

#### Example: large crawl with your own cookies

```json
{
  "keywords": ["architecture"],
  "maxPosts": 10000,
  "cookies": "<your cookies JSON>"
}
```

### Authentication

Instagram's keyword search only works for signed-in visitors, so this actor needs Instagram session cookies for the search step. You can either:

1. **Add your own cookies:** open Instagram while logged in, export your instagram.com cookies as JSON with any cookie-export extension, then drop the JSON into the `cookies` field before you start the run.
2. **Leave the cookies field blank:** the actor will automatically use a managed pool of shared Instagram sessions. This is the recommended option for most users.

Collecting the details of each post, the second step after posts are found, does not need cookies. If your cookies expire mid-run, export them again from your browser and restart the actor.

### Free plan

The free Apify plan runs the same search as a paid plan: every keyword you list and every page of results, up to your `maxPosts` value (large crawls are subject to your plan limits).

### Example output

```json
{
  "input_keyword": "travel",
  "post_url": "https://www.instagram.com/p/ABC123/",
  "shortcode": "ABC123",
  "post_id": "3711296250294340356",
  "username": "john_travels",
  "author_meta": {
    "id": "123456789",
    "username": "john_travels",
    "full_name": "John Smith",
    "is_verified": false,
    "profile_pic_url": "https://scontent.cdninstagram.com/v/example.jpg",
    "profile_url": "https://www.instagram.com/john_travels/"
  },
  "caption": "Exploring the streets of Lisbon #travel #portugal",
  "hashtags": ["travel", "portugal"],
  "mentions": [],
  "pub_date": "2024-11-15T14:23:10",
  "media_type": "Photo",
  "media_count": 1,
  "thumbnail_url": "https://scontent.cdninstagram.com/v/example-thumb.jpg",
  "media_items": [
    {
      "index": 0,
      "type": "Photo",
      "url": "https://scontent.cdninstagram.com/v/example-full.jpg",
      "width": 1080,
      "height": 1350
    }
  ],
  "accessibility_caption": "",
  "like_count": 1842,
  "comment_count": 34,
  "likes_hidden": false,
  "comments_disabled": false,
  "tagged_users": [],
  "collaborators": [],
  "caption_is_edited": false,
  "location": null,
  "music": null,
  "status": "success",
  "scraped_at": "2026-07-03T10:00:00"
}
```

### Use cases

- **Social media managers** – see which posts and creators come up for the hashtags your brand competes on.
- **Agency strategists** – collect the posts behind a trend before pitching a campaign idea to a client.
- **Influencer marketers** – see which accounts post popular content in a niche and compare their reach at a glance.
- **Brand and PR teams** – search your product name or campaign hashtag to see how creators are talking about it.
- **Academic and market researchers** – build a topic-based sample of captions, hashtags and engagement for analysis.

### Responsible use

Search results are made of what real people chose to post, and a public caption, username or follower count can still identify someone. Before you collect it, make sure you have a lawful basis (for example under the GDPR) for gathering and storing it, keep only what your project needs, and respect the people behind the posts, including requests to delete their data. Do not use the results to profile, track or target minors, and do not use them to pick out or infer special categories of personal data such as health, religion, political views or sexual orientation.

### FAQ

#### Do I need an Instagram account?

No. If you leave the cookies field empty, the actor uses a managed session for the search. You can paste your own cookies instead if you prefer to search from your own account.

#### Does it work with hashtags?

Yes. Enter a word with or without the leading `#` (for example `#nature`) or a multi-word phrase. Each entry is searched as you typed it, so try both forms if you want to compare what comes back.

#### Can it return posts from private accounts?

No. Only posts that Instagram shows publicly in its search can be collected. If a post turns out to be private, it appears with the `post_is_private` status and no other details.

#### How many posts can I get per keyword?

Up to 10,000, set with `maxPosts`. If a keyword runs out of new posts before it reaches that number, the actor moves on to the next keyword. Large crawls are subject to your plan limits.

#### Why are some like counts empty?

Some authors hide the like count on their posts. In that case `likes_hidden` is `true` and `like_count` has no value. Fields such as `location` and `music` are also empty when the post has none.

#### Why do some rows only have a link and a status?

Posts that could not be collected in full (deleted, private, age-restricted or failed to load) are still listed so you can see what happened to them, and a keyword that gave no posts is listed with its own status. Filter on `status` equal to `success` if you only want complete posts.

#### How fresh is the data?

Everything is read live during the run, so likes, comments and captions reflect Instagram at the moment of collection. The `scraped_at` field records when that was.

#### Do I need to set up a proxy?

No. The actor handles its connection to Instagram automatically. Just fill in your keywords and run it.

#### Is this affiliated with Instagram or Meta?

No. It is an independent tool and is not affiliated with, endorsed by or sponsored by Instagram or Meta Platforms, Inc.

# Actor input Schema

## `keywords` (type: `array`):

List of keywords to search. Works for both single-word (e.g. "photography") and multi-word (e.g. "sunset photography") queries.

## `maxPosts` (type: `integer`):

Maximum number of post URLs to collect per keyword.

## `cookies` (type: `string`):

Instagram authentication cookies in JSON format. If not provided, a managed Instagram session is used for the search. Format: \[{"name":"sessionid","value":"...","domain":".instagram.com"}, ...]. See README for extraction instructions.

## Actor input object example

```json
{
  "keywords": [
    "football",
    "architecture",
    "food photography"
  ],
  "maxPosts": 10
}
```

# Actor output Schema

## `posts` (type: `string`):

Dataset with one record per post found for a keyword, including the status of posts that could not be read and of keywords that gave no 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 = {
    "keywords": [
        "messi"
    ],
    "maxPosts": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("dataspryva/instagram-search-scraper-keywords-and-hashtags").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 = {
    "keywords": ["messi"],
    "maxPosts": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("dataspryva/instagram-search-scraper-keywords-and-hashtags").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 '{
  "keywords": [
    "messi"
  ],
  "maxPosts": 10
}' |
apify call dataspryva/instagram-search-scraper-keywords-and-hashtags --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,dataspryva/instagram-search-scraper-keywords-and-hashtags"
        }
    }
}
```

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/VNkT7Z8e5YQihcHWp/builds/69kMxPSpns4hkoIpq/openapi.json
