Tutorial

How to Get TikTok Hashtag Videos via API

Fetch videos from any TikTok hashtag with engagement data. Python and JavaScript examples using Scavio hashtag endpoints.

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.

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']

Step 2: Fetch videos for the hashtag

Use the challenge_id to get videos posted under this hashtag.

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 Example

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 Example

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');

Expected Output

JSON
Hashtag metadata (total views, video count) plus sample videos with engagement metrics for content research.

Related Tutorials

Frequently Asked Questions

Most developers complete this tutorial in 15 to 30 minutes. You will need a Scavio API key (free tier works) and a working Python or JavaScript environment.

Scavio API key. Target hashtag name. Python 3.8+ or Node.js 18+. A Scavio API key gives you 250 free credits per month.

Yes. The free tier includes 250 credits per month, which is more than enough to complete this tutorial and prototype a working solution.

Scavio has a native LangChain package (langchain-scavio), an MCP server, and a plain REST API that works with any HTTP client. This tutorial uses the raw REST API, but you can adapt to your framework of choice.

Start Building

Fetch videos from any TikTok hashtag with engagement data. Python and JavaScript examples using Scavio hashtag endpoints.