Fetch videos from any TikTok hashtag via Scavio API at $0.005/request. Two-step process: get hashtag info (including challenge_id), then fetch videos for that hashtag with full engagement metrics.
Prerequisites
- Scavio API key
- Target hashtag name
- Python 3.8+ or Node.js 18+
Walkthrough
Step 1: Get hashtag info
Look up hashtag metadata including challenge_id and view count.
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']Step 2: Fetch videos for the hashtag
Use the challenge_id to get videos posted under this hashtag.
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 Example
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 Example
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');Expected Output
Hashtag metadata (total views, video count) plus sample videos with engagement metrics for content research.