# Instagram Keyword Posts Scraper (`data-slayer/instagram-keyword-posts-scraper`) Actor

Search public Instagram posts, Reels and carousels by keyword. Batch up to 10 phrases and export captions, engagement, creator details and media URLs with query attribution. No Instagram login required.

- **URL**: https://apify.com/data-slayer/instagram-keyword-posts-scraper.md
- **Developed by:** [Data Slayer](https://apify.com/data-slayer) (community)
- **Categories:** Social media, Marketing
- **Stats:** 6 total users, 3 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.50 / 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/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 Keyword Posts Scraper

Search public Instagram posts, carousels, and Reels by keyword. Batch up to 10 phrases and export structured records that retain the phrase responsible for each match.

### Watch the demo

YouTube video coming soon.

### What this Actor does

The Actor sends each phrase to Instagram keyword content search, follows continuation pages internally, removes repeated media IDs within that phrase, and writes one analysis-ready dataset row for each retained result. If the same media item appears for two different phrases, it is kept once for each phrase so attribution is not lost.

No Instagram account, cookie, proxy setting, or search token is requested in the input form.

### Choose the right Instagram discovery Actor

- Use **Instagram Keyword Posts Scraper** to discover public photos, carousels, and Reels around one or more free-form phrases.
- Use **Instagram Reels Search** when the work is specifically Reel research and you need Reel-focused video and audio fields.
- Use **Instagram Hashtag Posts & Reels Scraper** when your starting point is one or more hashtags rather than a free-form phrase.
- Use **Instagram User Search** when you want to find accounts rather than content.

### Quickstart

1. Add one or more phrases such as `specialty coffee` or `marathon training`.
2. Choose the maximum number of results to save for each phrase.
3. Start the Actor, then open the dataset or export it as JSON, CSV, or Excel.

### Input

| Field | Type | Required | Default | Description |
|---|---|---:|---:|---|
| `searchQueries` | array of strings | Yes | — | Add 1–10 non-empty phrases. Exact duplicate phrases are removed after whitespace normalization. |
| `maxResultsPerQuery` | integer | No | `50` | Maximum unique rows saved for each phrase. Accepted range: 1–500. Available results can be lower. |

Example:

```json
{
  "searchQueries": [
    "specialty coffee india",
    "marathon training india"
  ],
  "maxResultsPerQuery": 50
}
```

### Output

Every dataset item contains:

- `query`, `id`, `shortCode`, `url`, and normalized `mediaType`
- Caption and source posting time when available
- Like, comment, view, and play counts when returned by the source
- Creator username, ID, full name, and verification state
- Thumbnail, image, video, and normalized carousel media references when available
- Optional location data
- `retrievalMode` and the UTC `collectedAt` timestamp

IDs are stored as strings to avoid precision loss. Missing optional source fields remain `null` or an empty array rather than being guessed.

Example result:

```json
{
  "query": "specialty coffee",
  "id": "1234567890",
  "shortCode": "ABC123",
  "url": "https://www.instagram.com/p/ABC123/",
  "mediaType": "carousel",
  "caption": "A sample post caption",
  "takenAt": "2026-09-14T08:30:00Z",
  "likeCount": 42,
  "commentCount": 3,
  "viewCount": null,
  "playCount": null,
  "username": "sample_creator",
  "userId": "987654321",
  "fullName": "Sample Creator",
  "isVerified": false,
  "thumbnailUrl": "https://example.com/thumbnail.jpg",
  "imageUrls": ["https://example.com/image.jpg"],
  "videoUrl": null,
  "carouselMedia": [],
  "location": null,
  "retrievalMode": "native_keyword",
  "collectedAt": "2026-09-14T09:00:00Z"
}
```

The example is illustrative. Fields and available values depend on each public post.

### Use cases

- **Content and creative research:** compare which photos, carousels, and Reels surface for several topic phrases.
- **Creator discovery:** identify public creators whose content appears for a niche, campaign, or product category.
- **Campaign and category research:** review captions, engagement signals, and media references for a bounded set of keyword results.
- **Topic-labelled datasets:** export each result with its source phrase for grouping, analysis, or downstream automation.

### Pagination, limits, and duplicate handling

- Phrases run serially to preserve input order and keep request volume bounded.
- Continuation tokens are handled automatically.
- The runtime stops on a missing or repeated continuation token.
- Each phrase is capped at 50 request attempts.
- A run is capped at 100 request attempts across all phrases.
- A page receives exactly one request. Rate limits, server failures, and network failures are recorded immediately instead of being retried.
- `maxResultsPerQuery` is applied after duplicate removal.
- Deduplication uses the exact pair `query + Instagram media ID`.

These safety limits mean a request for 500 results is a ceiling, not a guarantee. The `OUTPUT` key-value-store record explains why each phrase stopped: natural end, result cap, repeated token, request limit, request failure, or customer charge limit.

### Coverage and search semantics

The Actor returns the photo posts, carousel containers, and Reels surfaced by keyword search at run time. It does not promise an exhaustive historical mention archive, comprehensive brand monitoring, Instagram Explore/Popular-page parity, or deterministic ranking. Available results, ordering, and coverage can change over time.

### Empty, partial, and failed searches

A query with no returned items produces no fabricated dataset row. Request failures and limit stops are recorded in `OUTPUT`; status records are never mixed into or billed as content results. Successfully persisted rows from other phrases remain available when one phrase fails.

If a continuation page fails, rows already saved from earlier pages remain in the dataset. The corresponding query entry in `OUTPUT` reports a neutral completion reason, successful page count, persisted-row count, and total request attempts so consumers can distinguish partial results from a natural end.

Example partial-run summary:

```json
{
  "totalPersisted": 1,
  "totalRequests": 2,
  "chargeLimitReached": false,
  "queryStates": [
    {
      "query": "specialty coffee",
      "persisted": 1,
      "duplicatesSkipped": 0,
      "invalidItemsSkipped": 0,
      "requestAttempts": 2,
      "pagesReceived": 1,
      "reason": "service_unavailable"
    }
  ]
}
```

### API example

```bash
curl -X POST \
  "https://api.apify.com/v2/acts/data-slayer~instagram-keyword-posts-scraper/runs?token=YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "searchQueries": ["specialty coffee india", "marathon training india"],
    "maxResultsPerQuery": 50
  }'
```

Results can be downloaded in JSON, CSV, Excel, XML, or another Apify dataset format, or connected to schedules, webhooks, Make, Zapier, Google Sheets, and other Apify integrations.

### Related Data Slayer Actors

- [Instagram Hashtag Posts & Reels Scraper](https://apify.com/data-slayer/instagram-hashtag-posts-reels-scraper-no-login) starts from hashtags rather than free-form phrases.
- [Instagram User Search](https://apify.com/data-slayer/instagram-search-users) finds accounts rather than posts.
- [Instagram Reels Search](https://apify.com/data-slayer/instagram-search-reels) focuses on Reel discovery.

### FAQ

#### Are the results exhaustive?

No. The Actor returns the bounded results available to keyword search at run time. It does not provide a complete historical archive or guaranteed ranking.

#### What happens if a later page fails?

Rows already saved remain available. Check `OUTPUT` for the affected phrase's status, successful page count, saved-row count, and request count.

#### Does the Actor require my Instagram login?

No. The input does not request an Instagram account, password, cookies, or session token.

#### Which Instagram discovery Actor should I use?

Choose this Actor for mixed public content found through free-form phrases. Choose Instagram Reels Search for Reel-only research, Instagram Hashtag Posts & Reels Scraper for hashtag-led discovery, and Instagram User Search for account discovery.

#### Is this an official Instagram tool?

No. This is an independent Actor and is not affiliated with, endorsed by, or sponsored by Instagram or Meta.

### Responsible use

Use the Actor and its output responsibly and in accordance with applicable laws, platform terms, and your organization’s data policies. Avoid using personal data for unsolicited, discriminatory, deceptive, or harmful activity.

This independent Actor is not affiliated with, endorsed by, or sponsored by Instagram or Meta. Instagram is a trademark of its respective owner.

### Support

If a public phrase produces an unexpected result, open an issue from the Actor’s **Issues** tab and include the run ID, phrase, and observed behavior. Do not include credentials or private data.

# Actor input Schema

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

Add 1–10 phrases. Each result keeps the exact phrase that found it.

## `maxResultsPerQuery` (type: `integer`):

Stop after this many unique results for each phrase. Available results can be lower.

## Actor input object example

```json
{
  "searchQueries": [
    "specialty coffee",
    "marathon training"
  ],
  "maxResultsPerQuery": 50
}
```

# Actor output Schema

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

One dataset item per unique query and Instagram media ID.

## `runSummary` (type: `string`):

Per-query completion reasons, duplicate counts, attempts, and budget state.

# 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": [
        "specialty coffee",
        "marathon training"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("data-slayer/instagram-keyword-posts-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": [
        "specialty coffee",
        "marathon training",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("data-slayer/instagram-keyword-posts-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": [
    "specialty coffee",
    "marathon training"
  ]
}' |
apify call data-slayer/instagram-keyword-posts-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,data-slayer/instagram-keyword-posts-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/iJApVCaH6mxZLjbUM/builds/Migrth9XvSjfupSKc/openapi.json
