通过 Scavio API 从任何 TikTok 主题标签获取视频,每次请求费用为 0.005 美元。两步过程:获取主题标签信息(包括challenge_id),然后获取具有完整参与度指标的该主题标签的视频。
前置条件
- Scavio API 密钥
- 目标标签名称
- Python 3.8+ 或 Node.js 18+
操作指南
步骤 1: 获取主题标签信息
查找主题标签元数据,包括challenge_id 和视图计数。
Python
import requests, os
HEADERS = {'Authorization': f'Bearer {os.environ["SCAVIO_API_KEY"]}',
'Content-Type': 'application/json'}
info = requests.post('https://api.scavio.dev/api/v1/tiktok/hashtag',
headers=HEADERS, json={'hashtag': 'smallbusiness'}).json()['data']
print(f"Views: {info['stats']['view_count']:,}")
print(f"Videos: {info['stats']['video_count']:,}")
challenge_id = info['challenge_id']步骤 2: 获取主题标签的视频
使用challenge_id获取在此主题标签下发布的视频。
Python
videos = requests.post('https://api.scavio.dev/api/v1/tiktok/hashtag/videos',
headers=HEADERS,
json={'challenge_id': challenge_id, 'count': 20, 'cursor': 0}).json()['data']
for v in videos.get('videos', []):
print(f"{v['desc'][:40]} | {v['stats']['playCount']:,} plays")Python 示例
Python
import requests, os
HEADERS = {'Authorization': f'Bearer {os.environ["SCAVIO_API_KEY"]}',
'Content-Type': 'application/json'}
def hashtag_research(hashtag, video_pages=3):
info = requests.post('https://api.scavio.dev/api/v1/tiktok/hashtag',
headers=HEADERS, json={'hashtag': hashtag}).json()['data']
challenge_id = info['challenge_id']
videos = []
cursor = 0
for _ in range(video_pages):
resp = requests.post('https://api.scavio.dev/api/v1/tiktok/hashtag/videos',
headers=HEADERS,
json={'challenge_id': challenge_id, 'count': 20, 'cursor': cursor}).json()['data']
videos.extend(resp.get('videos', []))
if not resp.get('has_more'):
break
cursor = resp['cursor']
return {'views': info['stats']['view_count'],
'video_count': info['stats']['video_count'],
'sample_videos': len(videos), 'videos': videos}
result = hashtag_research('smallbusiness')
print(f"{result['views']:,} views, {result['sample_videos']} videos sampled")JavaScript 示例
JavaScript
const H = {'Authorization': `Bearer ${process.env.SCAVIO_API_KEY}`, 'Content-Type': 'application/json'};
async function hashtagResearch(hashtag) {
const info = await fetch('https://api.scavio.dev/api/v1/tiktok/hashtag', {
method: 'POST', headers: H, body: JSON.stringify({hashtag})
}).then(r => r.json());
const cid = info.data.challenge_id;
const vids = await fetch('https://api.scavio.dev/api/v1/tiktok/hashtag/videos', {
method: 'POST', headers: H,
body: JSON.stringify({challenge_id: cid, count: 20, cursor: 0})
}).then(r => r.json());
console.log(`${info.data.stats.view_count} views, ${(vids.data.videos||[]).length} sample videos`);
}
hashtagResearch('smallbusiness');预期输出
JSON
Hashtag metadata (total views, video count) plus sample videos with engagement metrics for content research.