# Instagram Keyword Scraper (`crawlerbros/instagram-keyword-scraper`) Actor

Search Instagram by keywords and extract detailed post data at scale. Get usernames, captions, engagement metrics, media URLs, hashtags, mentions, location data, music info, and more for every matching post.

Perfect for market research, brand monitoring, competitor analysis and etc.

- **URL**: https://apify.com/crawlerbros/instagram-keyword-scraper.md
- **Developed by:** [Crawler Bros](https://apify.com/crawlerbros) (community)
- **Categories:** Automation, Videos, Social media
- **Stats:** 16 total users, 9 monthly users, 100.0% runs succeeded, 12 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $3.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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use 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 Keyword Scraper

Search Instagram by keywords and extract detailed post data at scale. Get usernames, captions, engagement metrics, media URLs, hashtags, mentions, location data, music info, and more for every matching post.

Perfect for market research, brand monitoring, competitor analysis, influencer discovery, and trend tracking on Instagram.

### What data can you extract from Instagram keyword search?

For every post found, the scraper returns:

| Field            | Type      | Description                                              |
| ---------------- | --------- | -------------------------------------------------------- |
| `username`       | `string`  | Instagram username of the post author                    |
| `full_name`      | `string`  | Full display name of the post author                     |
| `profile_url`    | `string`  | URL to the author's Instagram profile                    |
| `collaborators`  | `array`   | List of collaborator usernames on the post               |
| `post_url`       | `string`  | Direct URL to the Instagram post                         |
| `pub_date`       | `string`  | Publication date in ISO 8601 format                      |
| `caption`        | `string`  | Full caption text of the post                            |
| `mentions`       | `array`   | Usernames @mentioned in the caption                      |
| `hashtags`       | `array`   | Hashtags used in the caption                             |
| `media_urls`     | `array`   | Direct URLs to media files (images and videos)           |
| `thumbnail_url`  | `string`  | URL of the post thumbnail image                          |
| `media_type`     | `string`  | Type of media: Photo, Video, Reel, IGTV, or Carousel    |
| `media_count`    | `integer` | Number of media items in the post                        |
| `likes_hidden`   | `boolean` | Whether like counts are hidden on this post              |
| `like_count`     | `integer` | Number of likes (null if hidden by the author)           |
| `comment_count`  | `integer` | Number of comments on the post                           |
| `location`       | `object`  | Location tagged in the post (name, latitude, longitude)  |
| `music`          | `object`  | Music/audio used in the post (artist and title)          |
| `search_keyword` | `string`  | The keyword that was used to find this post              |
| `scraped_at`     | `string`  | Timestamp when the data was collected                    |
| `status`         | `string`  | `"success"` when a post was extracted, `"No posts found"` when a keyword has no results |

### How to use Instagram Keyword Scraper

1. **Add your search keywords** - Enter one or more keywords or phrases (e.g., "living in dubai", "travel photography")
2. **Provide Instagram cookies** - Paste your Instagram session cookies (required for search access)
3. **Set the result limit** - Choose how many posts to extract per keyword (1 to 500, default 20)
4. **Run the scraper** - Click Start and the scraper collects all post data automatically
5. **Export your data** - Download results as JSON, CSV, Excel, or connect via API

### Input

| Field         | Type       | Description                                                  | Default             |
| ------------- | ---------- | ------------------------------------------------------------ | ------------------- |
| `keywords`    | `string[]` | List of keywords or phrases to search for on Instagram       | _required_          |
| `maxPosts`    | `integer`  | Maximum number of posts to extract per keyword (1-500)       | `20`                |
| `cookies`     | `string`   | Instagram authentication cookies in JSON format (required)   | -                   |
| `sessionName` | `string`   | Name for saving/loading cookies between runs                 | `"default_session"` |

#### Example Input

```json
{
  "keywords": ["living in dubai", "travel photography"],
  "maxPosts": 50,
  "cookies": "[{\"name\":\"sessionid\",\"value\":\"YOUR_SESSION_ID\",\"domain\":\".instagram.com\",\"path\":\"/\",\"secure\":true,\"httpOnly\":true}]",
  "sessionName": "my_session"
}
````

### Output

#### Example Output

```json
[
  {
    "username": "travel_creator",
    "full_name": "Travel Creator",
    "profile_url": "https://www.instagram.com/travel_creator/",
    "collaborators": ["co_creator"],
    "post_url": "https://www.instagram.com/p/ABC123/",
    "pub_date": "2025-11-20T15:25:01.000Z",
    "caption": "Amazing sunset in Dubai! #dubai #travel @friend",
    "mentions": ["friend"],
    "hashtags": ["dubai", "travel"],
    "media_urls": ["https://instagram.com/video.mp4"],
    "thumbnail_url": "https://instagram.com/thumbnail.jpg",
    "media_type": "Reel",
    "media_count": 1,
    "likes_hidden": false,
    "like_count": 175908,
    "comment_count": 42,
    "location": {
      "name": "Dubai, United Arab Emirates",
      "lat": 25.1994,
      "lng": 55.2741
    },
    "music": {
      "artist": "Artist Name",
      "title": "Song Title"
    },
    "search_keyword": "living in dubai",
    "scraped_at": "2025-11-21T12:28:25.052408",
    "status": "success"
  }
]
```

When a keyword returns no results, a single record is pushed instead:

```json
[
  {
    "search_keyword": "very obscure query with no results",
    "status": "No posts found"
  }
]
```

### How to get Instagram cookies

Instagram requires authentication to access keyword search results. You need to provide cookies from an active Instagram session.

**Using a cookie export extension (recommended):**

1. Install a cookie export extension like [Cookie-Editor](https://cookie-editor.cgagnier.ca/) or EditThisCookie for your browser
2. Log in to Instagram
3. Click the extension icon and export cookies as JSON
4. Paste the entire JSON into the `cookies` input field

The scraper automatically converts browser cookie formats - no manual cleanup needed.

**Important:** Use a dedicated Instagram account for scraping. Never share your cookies. Cookies expire periodically and need to be refreshed.

### Use cases

- **Market research** - Analyze trending topics and popular content for any niche or industry
- **Brand monitoring** - Track how your brand, products, or campaigns are discussed on Instagram
- **Competitor analysis** - Monitor competitor content, engagement rates, and posting patterns
- **Influencer discovery** - Find creators in specific niches by searching relevant keywords
- **Trend tracking** - Identify emerging trends, popular hashtags, and viral content
- **Content inspiration** - Discover high-performing posts for content strategy planning
- **Location intelligence** - Analyze posts tagged at specific locations or mentioning places

### Integrations

Connect Instagram Keyword Scraper with your existing tools and workflows:

- **Webhooks** - Get notified when a scrape finishes
- **API access** - Integrate results directly into your application
- **Scheduled runs** - Set up recurring scrapes to monitor keywords over time
- Export to **Google Sheets**, **Slack**, **Zapier**, **Make**, and more

### FAQ

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

You can extract up to 500 posts per search keyword. The default is 20. Instagram's search results are limited by their algorithm, so available results may vary by keyword.

#### What types of posts are supported?

The scraper extracts all post types: Photos, Videos, Reels, IGTV, and Carousels. For carousel posts, all individual media URLs are included.

#### Does the scraper extract engagement metrics?

Yes. Like counts, comment counts, and view data are extracted for each post. If the post author has hidden like counts, the `likes_hidden` field will be `true` and `like_count` will be null.

#### Can I search for multiple keywords at once?

Yes. Pass an array of keywords and the scraper will process each one, returning all results in a single dataset. Each result includes a `search_keyword` field so you can filter by keyword.

#### Why do I need cookies?

Instagram requires authentication to access keyword search results. Without valid cookies, the search page won't load any posts. Use a cookie export extension to get your session cookies easily.

#### How often do cookies expire?

Instagram session cookies typically last a few weeks to a few months. If the scraper stops returning results, try refreshing your cookies. Use the `sessionName` field to manage cookies between runs.

#### What format can I export the data in?

Results can be exported as JSON, CSV, Excel, XML, or accessed via the Apify API. You can also connect to Google Sheets, Slack, Zapier, and other integrations.

#### Does it extract location and music data?

Yes. If a post is tagged with a location, the scraper returns the location name, latitude, and longitude. For Reels and videos with music, the artist name and song title are included.

#### Can I scrape posts from private accounts?

No. Only publicly visible posts that appear in Instagram's keyword search results can be scraped. Posts from private accounts are not accessible.

#### What does the `status` field mean?

Every record in the output includes a `status` field. For successfully extracted posts it's `"success"`. When a keyword returns no results from Instagram's search, the scraper pushes a single record with `status: "No posts found"` so you can tell the difference between a failed run and a keyword that legitimately has no matches.

# Actor input Schema

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

List of keywords or phrases to search for on Instagram. Each keyword will be searched separately.

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

Maximum number of posts to extract for each keyword.

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

Instagram authentication cookies in JSON format. If not provided, uses our own cookies file as fallback. Format: \[{"name":"sessionid","value":"...","domain":".instagram.com"}, ...]. See README for extraction instructions.

## `sessionName` (type: `string`):

Name for saving/loading cookies between runs. Use different names for different Instagram accounts.

## Actor input object example

```json
{
  "keywords": [
    "living in dubai",
    "travel photography",
    "food recipes"
  ],
  "maxPosts": 50,
  "cookies": "[{\"name\":\"sessionid\",\"value\":\"your_session_id\",\"domain\":\".instagram.com\"}]",
  "sessionName": "my_instagram_session"
}
```

# Actor output Schema

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

No description

# 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": [
        "fitness"
    ],
    "maxPosts": 3
};

// Run the Actor and wait for it to finish
const run = await client.actor("crawlerbros/instagram-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 = {
    "keywords": ["fitness"],
    "maxPosts": 3,
}

# Run the Actor and wait for it to finish
run = client.actor("crawlerbros/instagram-keyword-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).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": [
    "fitness"
  ],
  "maxPosts": 3
}' |
apify call crawlerbros/instagram-keyword-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=crawlerbros/instagram-keyword-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Instagram Keyword Scraper",
        "description": "Search Instagram by keywords and extract detailed post data at scale. Get usernames, captions, engagement metrics, media URLs, hashtags, mentions, location data, music info, and more for every matching post.\n\nPerfect for market research, brand monitoring, competitor analysis and etc.",
        "version": "1.0",
        "x-build-id": "aYhjaXsnX8AWLloxW"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/crawlerbros~instagram-keyword-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-crawlerbros-instagram-keyword-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/crawlerbros~instagram-keyword-scraper/runs": {
            "post": {
                "operationId": "runs-sync-crawlerbros-instagram-keyword-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/crawlerbros~instagram-keyword-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-crawlerbros-instagram-keyword-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "keywords"
                ],
                "properties": {
                    "keywords": {
                        "title": "Search Keywords",
                        "minItems": 1,
                        "maxItems": 50,
                        "type": "array",
                        "description": "List of keywords or phrases to search for on Instagram. Each keyword will be searched separately.",
                        "items": {
                            "type": "string",
                            "minLength": 1
                        }
                    },
                    "maxPosts": {
                        "title": "Maximum Posts Per Keyword",
                        "minimum": 1,
                        "maximum": 500,
                        "type": "integer",
                        "description": "Maximum number of posts to extract for each keyword.",
                        "default": 20
                    },
                    "cookies": {
                        "title": "Instagram Cookies (Optional)",
                        "type": "string",
                        "description": "Instagram authentication cookies in JSON format. If not provided, uses our own cookies file as fallback. Format: [{\"name\":\"sessionid\",\"value\":\"...\",\"domain\":\".instagram.com\"}, ...]. See README for extraction instructions."
                    },
                    "sessionName": {
                        "title": "Session Name (Optional)",
                        "type": "string",
                        "description": "Name for saving/loading cookies between runs. Use different names for different Instagram accounts.",
                        "default": "default_session"
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
