Skip to main content
skill CX Codex

scraping-tiktok-videos-by-hashtag — Claude Code skill: TikTok videos

Pulls TikTok videos for any hashtag or keyword through apidojo's scraper on Apify. Returns URL, views, likes, comments, shares and author per video.

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

What scraping-tiktok-videos-by-hashtag does

The skill runs the apidojo/tiktok-scraper actor on Apify and hands back a dataset with videoId, authorUsername, desc, playCount, diggCount, commentCount, shareCount, createTime, videoUrl, musicTitle, hashtags and isAd. The workflow has four steps: normalize the hashtag list, run the actor, poll until the run reaches SUCCEEDED, then deliver the dataset as a chat table or a saved file.

Execution goes through node scripts/run_actor.js with --actor "apidojo~tiktok-scraper" and a JSON string in --input; add --output and --format to drop the result straight into CSV or JSON. With Apify MCP installed, the same actor is called as the apify:run-actor tool. A REST fallback exists too: POST to api.apify.com, poll actor-runs/$RUN_ID for SUCCEEDED, then read dataset/items.

You need APIFY_TOKEN in your environment or a .env file before the first run — neither the script nor the curl path works without it. Input accepts startUrls for profiles, hashtags, music pages, search and locations, plus keywords, sortType (RELEVANCE, MOST_LIKED, DATE_POSTED), a two-letter location code, maxItems and a JavaScript customMapFunction. TikTok rate-limits hard, so the skill advises capping a run at maxItems: 200. A banned hashtag comes back with zero rows; try the parent category tag instead. Duplicate videos across hashtags get deduplicated on videoId.

What it helps with

  • collect every TikTok video under a hashtag or keyword
  • export engagement metrics to CSV for a report
  • find posts under a specific challenge or trend
  • filter results by country with an ISO 3166-1 code
  • deduplicate videos that appear under several hashtags

Example prompts for the agent

  • Scrape all TikTok videos for #skincare from the last week and save them as CSV
  • Export video metrics for the keyword "coffee" sorted by MOST_LIKED, max 200 items
  • Fetch posts under the #fitness trend filtered to US and show a table with views and likes

How to install scraping-tiktok-videos-by-hashtag

1Skills CLI (Vercel)

npx skills add apidojo-io/apidojo-skills --skill scraping-tiktok-videos-by-hashtag -a claude-code

2Manually: put the files in place

~/.claude/skills/scraping-tiktok-videos-by-hashtag/SKILL.md

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

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

Questions about scraping-tiktok-videos-by-hashtag

How do I install scraping-tiktok-videos-by-hashtag in Claude?

Run npx skills add apidojo-io/apidojo-skills --skill scraping-tiktok-videos-by-hashtag -a claude-code. The skill lands in ~/.claude/skills/scraping-tiktok-videos-by-hashtag/SKILL.md.

What does scraping-tiktok-videos-by-hashtag do?

It runs the apidojo/tiktok-scraper actor on Apify for a hashtag or keyword and returns each video's URL, view count, likes, comments, shares, author handle, caption and timestamp.

What do I need before running it?

An APIFY_TOKEN environment variable, set in the shell or a .env file. The Apify MCP server is optional — without it the run goes through node scripts/run_actor.js or the REST API.

Source text

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

# Scraping TikTok Videos by Hashtag

Raw video dataset for any TikTok hashtag or keyword. Returns full video metadata including engagement metrics and author info.

## Prerequisites

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

## Inputs

| Parameter | Type | Required | Default | Notes |
|-----------|------|----------|---------|-------|
| `startUrls` | array | Optional | `[]` | TikTok URLs — user profiles, hashtags, music pages, search, locations |
| `keywords` | array | Optional | `[]` | Search keywords/terms to find posts |
| `sortType` | string | Optional | `RELEVANCE` | Sort order for keyword results: `RELEVANCE`, `MOST_LIKED`, `DATE_POSTED` |
| `location` | string | Optional | — | ISO 3166-1 alpha-2 country code for regional filtering (e.g. `US`, `GB`) |
| `maxItems` | number | Optional | Unlimited | Maximum posts to return across the run |
| `includeSearchKeywords` | boolean | Optional | `false` | Add the matched search keyword field to each post |
| `customMapFunction` | string | Optional | — | JavaScript function to transform each output object |

## Workflow

```
Progress:
- [ ] Step 1: Normalize hashtag list
- [ ] Step 2: Run tiktok-scraper
- [ ] Step 3: Poll for SUCCEEDED
- [ ] Step 4: Deliver video 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~tiktok-scraper" \
  --input '{"param": "value"}'

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

# Save as JSON
node scripts/run_actor.js \
  --actor "apidojo~tiktok-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~tiktok-scraper"
Input:
{
  "keywords": ["tag1", "tag2"],
  "maxItems": 100
}
```

**REST API fallback:**
```bash
curl -X POST \
  "https://api.apify.com/v2/acts/apidojo~tiktok-scraper/runs?token=$APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"keywords": ["tag1", "tag2"], "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

- **0 results for hashtag**: Hashtag may be banned on TikTok or spelled incorrectly. Try alternate spelling.
- **< 20 results**: Hashtag may be very niche — inform user, return what is available.
- **Duplicate video IDs across hashtags**: Deduplicate by `videoId` field.

## Output Format

```
# TikTok Video Dataset: #<hashtag>
Videos collected: N | Hashtags queried: N

| Video ID | Author | Caption (truncated) | Views | Likes | Comments | Shares | Posted |
|----------|--------|---------------------|-------|-------|----------|--------|--------|
| ...      | ...    | ...                 | ...   | ...   | ...      | ...    | ...    |

Available fields: videoId, authorUsername, desc, playCount, diggCount, commentCount,
shareCount, createTime, videoUrl, musicTitle, hashtags, isAd
```

## Troubleshooting

**Banned hashtag returns 0:** Some hashtags are restricted by TikTok — try parent category tag.
**Slow run:** TikTok rate-limits heavily; `maxItems: 200` is a safe cap per run.

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

Similar skills

All skills for Browser and scraping →

From the same set22

tracking-brand-sentiment-across-platforms Pulls brand mentions from Twitter, Reddit and TikTok, scores sentiment per platform, and returns one brand health number from 0 to 100. CX Codex +1 767installs finding-tiktok-creators-by-location Finds TikTok creators and their videos by geographic location through apidojo's scraper on Apify. Useful for local campaigns and regional research. CX Codex +1 766installs tracking-google-serp-rankings A skill that pulls Google results for a keyword list: positions, URLs, titles, snippets and SERP features. Useful for SEO audits and competitor checks. CX Codex +1 763installs scraping-google-search-results Pulls Google search results for any query: URLs, titles, snippets, positions and SERP feature types. Handy when you need raw SERP data for SEO or competitor work. CX Codex +1 759installs benchmarking-instagram-influencer-engagement Pulls recent Instagram posts and turns them into engagement benchmarks: followers, average likes and comments, ER, posting frequency. CX Codex +1 757installs monitoring-instagram-hashtag-trends Pulls Instagram posts per hashtag and works out which tags actually earn engagement. Useful when you need a hashtag set for a post or a brand comparison. CX Codex +1 740installs building-twitter-industry-watchlist Builds a curated list of key voices in an industry on X, with handle, follower count, engagement and an influence score. CX Codex +1 739installs finding-youtube-channels-by-growth-rate Finds YouTube channels with high growth rates in a niche using Apify's YouTube scraper. Useful for spotting rising creators before they get big. CX Codex +1 730installs

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