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.
npx skills add apidojo-io/apidojo-skills --skill scraping-tiktok-videos-by-hashtag -a claude-codeWhat 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-code2Manually: put the files in place
~/.claude/skills/scraping-tiktok-videos-by-hashtag/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/scraping-tiktok-videos-by-hashtag/
1Skills CLI (Vercel)
npx skills add apidojo-io/apidojo-skills --skill scraping-tiktok-videos-by-hashtag -a codex2Manually: put the files in place
.agents/skills/scraping-tiktok-videos-by-hashtag/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add apidojo-io/apidojo-skills --skill scraping-tiktok-videos-by-hashtag -a cursor2Manually: put the files in place
.cursor/skills/scraping-tiktok-videos-by-hashtag/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install apidojo-io/apidojo-skills scraping-tiktok-videos-by-hashtag2Manually: put the files in place
.github/skills/scraping-tiktok-videos-by-hashtag/SKILL.md1Skills CLI (Vercel)
npx skills add apidojo-io/apidojo-skills --skill scraping-tiktok-videos-by-hashtag -a gemini-cli2Platform CLI
gemini skills install https://github.com/apidojo-io/apidojo-skills --path skills/primitives/scraping-tiktok-videos-by-hashtagManually: put the files in place
.devin/skills/scraping-tiktok-videos-by-hashtag/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add apidojo-io/apidojo-skills --skill scraping-tiktok-videos-by-hashtag -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
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