Skip to main content
skill CX Codex

scraping-instagram-posts-by-hashtag — Claude Code skill

Collects Instagram posts by hashtag through Apify, including author and engagement data. Use it for trend research, UGC collection, or tag-based exports.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add apidojo-io/apidojo-skills --skill scraping-instagram-posts-by-hashtag -a claude-code
Open on GitHub

What scraping-instagram-posts-by-hashtag does

The skill cleans up the hashtag input, starts apidojo~instagram-hashtag-scraper, waits for SUCCEEDED, and returns a post dataset. Records can include the post URL, caption, author handle, likes, comments, timestamp, media type, hashtags, and mentions. scripts/run_actor.js can print a table or save CSV and JSON output.

Set APIFY_TOKEN in the environment or in .env before running the actor. Apify MCP is optional and can call apify:run-actor directly. Inputs support Reels, regular posts, a YYYY-MM-DD cutoff, maxItems, and a JavaScript mapping function. Without APIFY_TOKEN, the script and REST API cannot start the run. Restricted hashtags may return zero posts, while popular feeds can expose only top posts.

What it helps with

  • collect Instagram posts for a hashtag
  • export post metadata to CSV
  • compare likes and comments across a tag
  • limit results by date
  • retrieve author and media fields

Example prompts for the agent

  • Collect Instagram posts for the hashtag fitness and show the results as a table.
  • Run the scraper for a hashtag and save the dataset as YYYY-MM-DD_results.csv with scripts/run_actor.js.
  • Fetch posts with Reels included and write the response to YYYY-MM-DD_results.json.

How to install scraping-instagram-posts-by-hashtag

1Skills CLI (Vercel)

npx skills add apidojo-io/apidojo-skills --skill scraping-instagram-posts-by-hashtag -a claude-code

2Manually: put the files in place

~/.claude/skills/scraping-instagram-posts-by-hashtag/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/scraping-instagram-posts-by-hashtag/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about scraping-instagram-posts-by-hashtag

How do I install scraping-instagram-posts-by-hashtag in Claude Code?

Run npx skills add apidojo-io/apidojo-skills --skill scraping-instagram-posts-by-hashtag -a claude-code. The skill file will be placed at ~/.claude/skills/scraping-instagram-posts-by-hashtag/SKILL.md.

What does scraping-instagram-posts-by-hashtag do?

It runs Apify’s Instagram hashtag scraper and returns post-level data such as the author, caption, engagement counts, timestamp, URL, and media details.

What does the skill require?

Set APIFY_TOKEN in the environment or in .env. With Apify MCP installed, the actor can be started through apify:run-actor instead.

Source text

SKILL.md · Apache-2.0
---
name: scraping-instagram-posts-by-hashtag
description: >
  Scrapes Instagram posts for any hashtag using apidojo's Instagram scraper on Apify.
  Triggers when the user asks to: get Instagram posts for a hashtag, scrape Instagram
  content by tag, export Instagram post data for a keyword or topic, fetch posts under
  an Instagram challenge or trend, collect Instagram media for a specific tag, or
  download Instagram post metadata by hashtag. Returns post URL, caption, like count,
  comment count, author handle, and timestamp per post.
  Ideal for trend analysts, UGC collectors, and social media researchers.
license: Apache-2.0
metadata:
  author: apidojo
  version: "1.0"
  apify-actor: apidojo/instagram-hashtag-scraper
---

# Scraping Instagram Posts by Hashtag

Raw Instagram post dataset for any hashtag. Returns post-level metadata including engagement and author info.

## Prerequisites

- `APIFY_TOKEN` environment variable set
- Optional: Apify MCP server installed

## Inputs

| Parameter | Type | Required | Default | Notes |
|-----------|------|----------|---------|-------|
| `startUrls` | array | Optional | `[]` | Instagram hashtag search URLs |
| `keyword` | string | Optional | — | Hashtag keyword to search (e.g. `fitness`) |
| `getReels` | boolean | Optional | `false` | Include Reels in results |
| `getPosts` | boolean | Optional | `true` | Include regular posts in results |
| `until` | string | Optional | — | Date filter (YYYY-MM-DD) |
| `maxItems` | number | Optional | Unlimited | Maximum posts to return |
| `customMapFunction` | string | Optional | — | JavaScript function to transform each output object |

## Workflow

```
Progress:
- [ ] Step 1: Normalize hashtag input
- [ ] Step 2: Run instagram-scraper
- [ ] Step 3: Poll for SUCCEEDED
- [ ] Step 4: Deliver post dataset
```

### Step 2: Run the Actor


**Recommended — run_actor.js (handles waiting, output, and file saving automatically):**
```bash
# Quick answer (prints table to chat)
node scripts/run_actor.js \
  --actor "apidojo~instagram-hashtag-scraper" \
  --input '{"param": "value"}'

# Save as CSV
node scripts/run_actor.js \
  --actor "apidojo~instagram-hashtag-scraper" \
  --input '{"param": "value"}' \
  --output YYYY-MM-DD_results.csv --format csv

# Save as JSON
node scripts/run_actor.js \
  --actor "apidojo~instagram-hashtag-scraper" \
  --input '{"param": "value"}' \
  --output YYYY-MM-DD_results.json --format json
```
> `APIFY_TOKEN` must be set in environment or `.env` file.

**If Apify MCP is available:**
```
Tool: apify:run-actor
Actor: "apidojo~instagram-hashtag-scraper"
Input:
{
  "keywords": ["tag1", "tag2"],
  "maxItems": 100,
  "mediaType": "all"
}
```

**REST API fallback:**
```bash
curl -X POST \
  "https://api.apify.com/v2/acts/apidojo~instagram-hashtag-scraper/runs?token=$APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"keywords": ["tag1"], "maxItems": 100}'
```

Save `id` as `RUN_ID`. Poll until `status = SUCCEEDED`:
```bash
curl "https://api.apify.com/v2/actor-runs/$RUN_ID?token=$APIFY_TOKEN" | grep '"status"'
```

Fetch results:
```bash
curl "https://api.apify.com/v2/actor-runs/$RUN_ID/dataset/items?token=$APIFY_TOKEN&format=json"
```

### Step 3: Handle Edge Cases

- **Banned hashtag**: Instagram hides some hashtags — returns 0. Try parent category.
- **Only top posts returned**: Instagram limits hashtag feeds; very popular tags may return only top posts.
- **Private account posts**: Post metadata visible but media URL may be restricted.

## Output Format

```
# Instagram Post Dataset: #<hashtag>
Posts collected: N | Media type: all/image/video

| Post ID | Author | Caption (truncated) | Likes | Comments | Type | Timestamp |
|---------|--------|---------------------|-------|----------|------|-----------|
| ...     | ...    | ...                 | ...   | ...      | ...  | ...       |

Available fields: id, ownerUsername, caption, likesCount, commentsCount, type,
timestamp, url, mediaUrl, hashtags, mentions
```

## Troubleshooting

**0 results:** Hashtag may be banned or restricted by Instagram.
**Rate limiting:** Keep `maxItems` ≤ 200 per run; space runs 5 minutes apart.

© apidojo · Apache-2.0 · apidojo-io/apidojo-skills

Similar skills

All skills for Browser and scraping →

From the same set57

finding-instagram-ugc-creators-for-brands Finds Instagram creators for UGC campaigns and ranks them by engagement, niche signals, and profile data. CX Codex +1 794installs finding-youtube-micro-influencers Finds YouTube channels under 100k subscribers in a given niche and ranks them by view-to-subscriber ratio. Built for sponsorship deals and affiliate programs. CX Codex +1 793installs scraping-tiktok-posts-by-music Pulls TikTok posts built on one sound or track and returns their stats, creators and song metadata. Useful when you need to see who is using a piece of music. CX Codex +1 793installs monitoring-vc-investor-activity-on-twitter This skill pulls investor tweets through apidojo's scraper, classifies the accounts and scores deal signals. Useful when you are raising. CX Codex +1 789installs tracking-twitter-thought-leaders Finds Twitter/X accounts whose posts on a topic actually get shared, then hands back a ranked list for PR and partnerships. CX Codex +1 786installs finding-data-scientists-on-twitter Searches Twitter for data scientists and ML engineers who may fit a hiring pipeline, then enriches profiles with skills and work-interest signals. CX Codex +1 786installs monitoring-twitter-for-competitor-job-posts Tracks competitor hiring tweets on X and turns them into growth signals: who is hiring, for what role, and when. CX Codex +1 786installs tracking-sports-team-fan-sentiment-twitter Collects tweets about a sports team and measures fan sentiment. Use it to study reactions to games, team news, player trades, and events. CX Codex +1 785installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor