ScavioScavio
ProductPricingDocs
Sign InGet Started
  1. Home
  2. Tutorials
  3. How to Search TikTok Videos and Users via API
Tutorial

How to Search TikTok Videos and Users via API

Use the Scavio TikTok search API to find videos and users by keyword. Covers pagination with cursor, result parsing, and full Python/JS examples.

Get Free API KeyAPI Docs

The Scavio TikTok API provides two search endpoints: search/videos returns video results for a query with cursor-based pagination, and search/users returns creator profiles. Both use POST requests with Authorization: Bearer.

Prerequisites

  • Python 3.9+ or Node.js 18+
  • Scavio API key with TikTok access

Walkthrough

Step 1: Search TikTok videos by keyword

POST to /tiktok/search/videos with your query. Paginate with the cursor field.

Python
import requests

API_KEY = "your-scavio-api-key"

def search_tiktok_videos(query: str, cursor: int = 0, count: int = 20) -> dict:
    r = requests.post(
        "https://api.scavio.dev/api/v1/tiktok/search/videos",
        json={"query": query, "cursor": cursor, "count": count},
        headers={"Authorization": f"Bearer {API_KEY}"},
        timeout=20
    )
    r.raise_for_status()
    return r.json()

result = search_tiktok_videos("ai coding tutorial")
videos = result.get("videos", [])
for v in videos:
    print(v.get("desc"), v.get("stats", {}).get("playCount"))

Step 2: Paginate through video results

Use the cursor from the response to fetch the next page. Continue until has_more is False.

Python
def get_all_videos(query: str, max_pages: int = 5) -> list:
    all_videos = []
    cursor = 0
    for page in range(max_pages):
        result = search_tiktok_videos(query, cursor=cursor)
        videos = result.get("videos", [])
        all_videos.extend(videos)
        print(f"Page {page + 1}: {len(videos)} videos (total: {len(all_videos)})")
        if not result.get("has_more") or not videos:
            break
        cursor = result.get("cursor", cursor + len(videos))
    return all_videos

videos = get_all_videos("ai coding tutorial", max_pages=3)
print(f"Total videos fetched: {len(videos)}")

Step 3: Search TikTok users by keyword

POST to /tiktok/search/users to find creator profiles. Same cursor-based pagination.

Python
def search_tiktok_users(query: str, cursor: int = 0) -> dict:
    r = requests.post(
        "https://api.scavio.dev/api/v1/tiktok/search/users",
        json={"query": query, "cursor": cursor},
        headers={"Authorization": f"Bearer {API_KEY}"},
        timeout=20
    )
    r.raise_for_status()
    return r.json()

result = search_tiktok_users("ai developer")
users = result.get("users", [])
for u in users:
    print(u.get("nickname"), u.get("follower_count"), u.get("sec_uid"))

Step 4: Parse and filter results

Extract key metrics and filter by minimum play count or follower count.

Python
def filter_videos(videos: list, min_plays: int = 10000) -> list:
    filtered = []
    for v in videos:
        plays = v.get("stats", {}).get("playCount", 0)
        if plays >= min_plays:
            filtered.append({
                "id": v.get("id"),
                "desc": v.get("desc", "")[:100],
                "plays": plays,
                "likes": v.get("stats", {}).get("diggCount", 0),
                "comments": v.get("stats", {}).get("commentCount", 0),
                "author": v.get("author", {}).get("uniqueId")
            })
    return sorted(filtered, key=lambda x: x["plays"], reverse=True)

top_videos = filter_videos(videos, min_plays=50000)
for v in top_videos[:5]:
    print(f"{v['plays']:>10,} plays | @{v['author']} | {v['desc'][:60]}")

Python Example

Python
import requests

API_KEY = "your-scavio-api-key"

def search_videos(query: str, cursor: int = 0, count: int = 20) -> dict:
    r = requests.post(
        "https://api.scavio.dev/api/v1/tiktok/search/videos",
        json={"query": query, "cursor": cursor, "count": count},
        headers={"Authorization": f"Bearer {API_KEY}"},
        timeout=20
    )
    r.raise_for_status()
    return r.json()

def search_users(query: str, cursor: int = 0) -> dict:
    r = requests.post(
        "https://api.scavio.dev/api/v1/tiktok/search/users",
        json={"query": query, "cursor": cursor},
        headers={"Authorization": f"Bearer {API_KEY}"},
        timeout=20
    )
    r.raise_for_status()
    return r.json()

def collect_top_videos(query: str, min_plays: int = 10000, max_pages: int = 3) -> list:
    all_videos = []
    cursor = 0
    for _ in range(max_pages):
        result = search_videos(query, cursor=cursor)
        batch = result.get("videos", [])
        if not batch:
            break
        all_videos.extend(batch)
        if not result.get("has_more"):
            break
        cursor = result.get("cursor", 0)

    return sorted(
        [{"id": v.get("id"), "desc": v.get("desc","")[:80],
          "plays": v.get("stats",{}).get("playCount",0),
          "likes": v.get("stats",{}).get("diggCount",0),
          "author": v.get("author",{}).get("uniqueId")}
         for v in all_videos if v.get("stats",{}).get("playCount",0) >= min_plays],
        key=lambda x: x["plays"], reverse=True
    )

if __name__ == "__main__":
    print("=== Top Videos for 'ai coding tutorial' ===")
    videos = collect_top_videos("ai coding tutorial", min_plays=50000)
    for i, v in enumerate(videos[:10], 1):
        print(f"{i:2}. {v['plays']:>10,} plays | @{v['author']:<20} | {v['desc'][:50]}")

    print("\n=== Users matching 'ai developer' ===")
    user_result = search_users("ai developer")
    for u in user_result.get("users", [])[:5]:
        print(f"@{u.get('uniqueId'):<25} {u.get('follower_count',0):>8,} followers")

JavaScript Example

JavaScript
const API_KEY = 'your-scavio-api-key';

async function searchVideos(query, cursor = 0, count = 20) {
  const res = await fetch('https://api.scavio.dev/api/v1/tiktok/search/videos', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${API_KEY}` },
    body: JSON.stringify({ query, cursor, count })
  });
  if (!res.ok) throw new Error(`Failed: ${res.status}`);
  return res.json();
}

async function searchUsers(query, cursor = 0) {
  const res = await fetch('https://api.scavio.dev/api/v1/tiktok/search/users', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${API_KEY}` },
    body: JSON.stringify({ query, cursor })
  });
  return res.json();
}

const videoResult = await searchVideos('ai coding tutorial');
const top = (videoResult.videos ?? [])
  .filter(v => (v.stats?.playCount ?? 0) >= 50000)
  .sort((a, b) => (b.stats?.playCount ?? 0) - (a.stats?.playCount ?? 0));

for (const v of top.slice(0, 5)) {
  console.log(`${v.stats?.playCount?.toLocaleString()} plays | @${v.author?.uniqueId} | ${v.desc?.slice(0, 60)}`);
}

Expected Output

JSON
=== Top Videos for 'ai coding tutorial' ===
 1.  2,847,392 plays | @aicodingpro        | How I built a full app in 10 minutes with AI
 2.  1,203,441 plays | @techwithtim         | Claude vs ChatGPT for coding - honest review
 3.    891,022 plays | @cursordev           | Cursor AI just changed everything

=== Users matching 'ai developer' ===
@aidevtools               1,240,000 followers
@buildwithclaude            890,441 followers

Related Tutorials

  • How to Build a TikTok Hashtag Tracker
  • How to Build a TikTok Influencer Vetting Workflow
  • How to Build a TikTok UGC Campaign Tracker

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.

Python 3.9+ or Node.js 18+. Scavio API key with TikTok access. A Scavio API key gives you 50 free credits on signup.

Yes. The free tier includes 50 credits on signup, 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.

Related Resources

Best Of

Best TikTok Video Search APIs in 2026

Read more
Best Of

Best Budget Search APIs for AI Agents Under $10/mo (2026)

Read more
Use Case

TikTok Brand Safety Creator Vetting

Read more
Use Case

n8n Search Enrichment Workflow

Read more
Solution

Migrate from Brave Search API to Scavio for Better Coverage

Read more
Workflow

Search API Vendor Evaluation Pipeline

Read more

Start Building

Use the Scavio TikTok search API to find videos and users by keyword. Covers pagination with cursor, result parsing, and full Python/JS examples.

Get Free API KeyRead the Docs
ScavioScavio

Real-time search API for AI agents. Search every platform, not just Google.

Product

  • Features
  • Pricing
  • Dashboard
  • Affiliates

Developers

  • Documentation
  • API Reference
  • Quickstart
  • MCP Integration
  • Python SDK

Alternatives

  • Tavily Alternative
  • SerpAPI Alternative
  • Firecrawl Alternative
  • Exa Alternative

Tools

  • JSON Formatter
  • cURL to Code
  • Token Counter
  • All Tools

© 2026 Scavio. All rights reserved.

Featured on TAAFT
Terms of ServicePrivacy Policy