# Instagram Topic Scraper (`apify/instagram-topic-scraper`) Actor

Scrape and download Instagram posts based on the topic. Just add one or more Instagram topic URLs. Export scraped datasets, run the scraper via API, schedule and monitor runs or integrate with other tools.

- **URL**: https://apify.com/apify/instagram-topic-scraper.md
- **Developed by:** [Apify](https://apify.com/apify) (Apify)
- **Categories:** Social media
- **Stats:** 227 total users, 2 monthly users, 100.0% runs succeeded, 6 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $2.00 / 1,000 posts

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

### What is Instagram Topic Scraper?

Instagram Topic Scraper allows you to scrape posts based on the topic. You can scrape the [main page for topics](https://www.instagram.com/explore/) or any part of it.

### What topics can you scrape?

Except for the main explore page, there are many more. The most popular ones are: <br>
⛹ [Sport](https://www.instagram.com/explore/topics/10155868806390727/sports/)<br>
🎶 [Music & video](https://www.instagram.com/explore/topics/10155994924430727/music-audio/)<br>
💅🏻 [Fashion & beauty](https://www.instagram.com/explore/topics/10156104410190727/fashion-beauty/)<br>
📺 [TV & movies](https://www.instagram.com/explore/topics/10155994923880727/tv-movies/)<br>
🎮 [Games](https://www.instagram.com/explore/topics/10156104417160727/games/)<br>
👩🏻‍🎤 [Pop culture](https://www.instagram.com/explore/topics/514454113372737/pop-culture/)

> Please note that the URLs work in **Incognito mode only**.

### How to scrape Instagram with Instagram Topic Scraper

Instagram Topic Scraper is designed to be fast and easy to use so there aren't too many parameters or settings. Just follow the steps below:

1. Create a free Apify account.
2. Open Instagram Topic Scraper.
3. Add one or more Instagram URLs to scrape.
4. Set the maximum for results and the depth level (how many possible subtopics you would like to scrape).
5. Click "Save & Start" and wait for the datasets to be extracted.
6. Download your data in JSON, XML, CSV, Excel, or HTML.

### Want to scrape Instagram hashtags, posts, or comments?

You can use the other dedicated scrapers below if you want to scrape specific Instagram data. You'll have fewer settings to change and faster results. Just enter one or more Instagram usernames or URLs and click to scrape.

<table>
<tr>
<td>👤 <a href="https://apify.com/apify/instagram-profile-scraper">Instagram Profile Scraper</a></td>
<td>✅ <a href="https://apify.com/apify/quick-instagram-posts-checker">Quick Instagram Posts Checker</a></td>
</tr>
<tr>
<td>#️⃣ <a href="https://apify.com/apify/instagram-hashtag-scraper">Instagram Hashtag Scraper</a></td>
<td>📷 <a href="https://apify.com/apify/instagram-post-scraper">Instagram Post Scraper</a></td>
</tr>
<tr>
<td>🏷️ <a href="https://apify.com/apify/instagram-tagged-scraper">Instagram Mentions Scraper</a></td>
<td>🎞️ <a href="https://apify.com/apify/instagram-reel-scraper">Instagram Reel Scraper</a></td>
</tr>
<tr>
<td>👥 <a href="https://apify.com/apify/instagram-followers-count-scraper">Instagram Followers Count Scraper</a></td>
<td>💬 <a href="https://apify.com/apify/instagram-comment-scraper">Instagram Comments Scraper</a></td>
</tr>
<tr>
<td>📊 <a href="https://apify.com/apify/instagram-hashtag-stats">Instagram Hashtag Stats</a></td>
<td></td>
</tr>
</table>

### Not your cup of tea? Build your own scraper

Instagram Topic Scraper doesn’t exactly do what you need? You can always build your own! We have various [scraper templates](https://apify.com/templates) in Python, JavaScript, and TypeScript to get you started. Alternatively, you can write it from scratch using our [open-source library Crawlee](https://crawlee.dev/). You can keep the scraper to yourself or make it public by adding it to Apify Store (and [find users](https://blog.apify.com/make-regular-passive-income-developing-web-automation-actors-b0392278d085/) for it).

Or let us know if you need a [custom scraping solution](https://apify.com/custom-solutions).

### Your feedback

We’re always working on improving the performance of our Actors. So if you’ve got any technical feedback for Instagram Topic Scraper or simply found a bug, please create an issue on the Actor’s [Issues tab](https://console.apify.com/actors/RB9HEZitC8hIUXAha/issues) in Apify Console.

# Changelog

This Actor's version history is a separate document: https://apify.com/apify/instagram-topic-scraper/changelog.md

# Actor input Schema

## `directUrls` (type: `array`):

Add one or multiple Instagram topic URLs you want to scrape.

## `resultsLimit` (type: `integer`):

Set the maximum number of results you want to scrape. If set to 5, you will get at most 5 results.

## `depthOfSubtopics` (type: `integer`):

The start URLs have depth 0, the pages linked directly from the start URLs have depth 1, and so on. This setting is useful to prevent accidental runaway. By setting it to 0, the Actor will only scrape the Start URLs.

## Actor input object example

```json
{
  "directUrls": [
    "https://www.instagram.com/explore/topics/10155868806390727/sports/"
  ],
  "resultsLimit": 100,
  "depthOfSubtopics": 1
}
```

# Actor output Schema

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

Dataset containing all scraped posts from the topic

# 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 = {
    "directUrls": [
        "https://www.instagram.com/explore/topics/10155868806390727/sports/"
    ],
    "resultsLimit": 100,
    "depthOfSubtopics": 1
};

// Run the Actor and wait for it to finish
const run = await client.actor("apify/instagram-topic-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 = {
    "directUrls": ["https://www.instagram.com/explore/topics/10155868806390727/sports/"],
    "resultsLimit": 100,
    "depthOfSubtopics": 1,
}

# Run the Actor and wait for it to finish
run = client.actor("apify/instagram-topic-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 '{
  "directUrls": [
    "https://www.instagram.com/explore/topics/10155868806390727/sports/"
  ],
  "resultsLimit": 100,
  "depthOfSubtopics": 1
}' |
apify call apify/instagram-topic-scraper --silent --output-dataset

```

## MCP server setup

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