Searching TikTok
Collect TikTok videos from a profile or by keyword, or find TikTok LIVE rooms broadcasting now, using the asynchronous TikTok endpoints, then poll for paginated results.
Overview
VidNavigator offers three ways to collect TikTok content:
Profile Scrape
Walk a single creator's account and return their videos, filtered by date and likes.
Keyword Search
Search across TikTok by keyword and return matching videos from many creators.
LIVE Search
Find LIVE rooms broadcasting now for a keyword, with their stream URLs.
The three searches are asynchronous: you submit a task, get a task_id back immediately, then poll a GET endpoint until the task is completed. Results are retained for about 1 hour, and large result sets can be downloaded as a single JSON file via a temporary download_url.
The Python and JavaScript SDKs (v2.3.1) wrap the submit-and-poll flow in a single call. Each section below starts with the SDK version, followed by the raw HTTP workflow (cURL, Python requests, and fetch) if you'd rather call the API directly.
Prerequisites
- A valid VidNavigator API key.
- Optional: the SDK, version 2.3.1 (
pip install vidnavigator==2.3.1ornpm install vidnavigator@2.3.1). LIVE search and keywordcountryneed 2.2.0, the LIVE room 2.3.0.
Billing
The three searches bill in the background worker, so usage is disclosed on the polling GET (pass include_usage=true there), not at submit time. The LIVE room is synchronous and discloses usage in its own response.
| Endpoint | What you're billed |
|---|---|
Profile scrape (/tiktok/profile) | standard_request per TikTok page fetched (residential_request when a residential proxy is used). |
Keyword search (/tiktok/search) | 1 residential_request per 30 results returned (stats.results_count), minimum 1 per search and 1 per 5 TikTok pages read (stats.pages_fetched). Videos your filters drop are not billed. No search_request. |
LIVE search (/tiktok/live/search) | 1 residential_request per 30 rooms returned (stats.results_count), same minimums. Usually 1 or 2 per search. No search_request. |
LIVE room (/tiktok/live/room, synchronous) | 1 residential_request, 2 with include_comments (1 when the room has ended). Pass include_usage: true on the request itself. Not billed when the room does not exist. |
See Usage & Costs for credit conversions.
Searching a TikTok Profile
Send a public profile_url and optional filters. max_posts and after_datetime let the scraper stop paginating early.
With the SDK
One call submits the scrape, waits for it to finish, and returns every matching video: both SDKs walk all the result pages for you (Python since 2.2.0).
from vidnavigator import VidNavigatorClient
client = VidNavigatorClient() # reads VIDNAVIGATOR_API_KEY
result = client.scrape_tiktok_profile(
profile_url="https://www.tiktok.com/@tiktok",
max_posts=50,
after_datetime="2024-01-01",
min_likes=10000,
)
for video in result.data.videos or []:
print(video.published_at, video.likes, video.url) # published_at is a datetimeTo start the scrape without waiting, use client.tiktok_profile.submit(...) (Python) or vn.tiktokProfile.submit(...) (JavaScript) and collect it later with job.result(). Both accept a webhook_url to be notified when the scrape finishes.
With raw HTTP
1. Submit the scrape
curl -X POST "https://api.vidnavigator.com/v1/tiktok/profile" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"profile_url": "https://www.tiktok.com/@tiktok",
"max_posts": 50,
"after_datetime": "2024-01-01T00:00:00Z",
"min_likes": 10000
}'2. Poll until completed and page through results
Poll GET /tiktok/profile/{task_id} while task_status is processing. Once completed, walk the pages using the next_cursor from data.pagination.
import time
def get_profile_page(task_id, cursor=None, limit=50):
params = {"limit": limit}
if cursor:
params["cursor"] = cursor
r = requests.get(f"{BASE}/tiktok/profile/{task_id}", headers=HEADERS, params=params)
return r.json()["data"]
# Wait for completion
while True:
data = get_profile_page(task_id, limit=1)
if data["task_status"] != "processing":
break
time.sleep(3)
if data["task_status"] == "failed":
raise RuntimeError((data.get("error") or {}).get("message", "scrape failed"))
# Page through all videos
videos, cursor = [], None
while True:
page = get_profile_page(task_id, cursor=cursor, limit=100)
videos.extend(page["videos"])
pagination = page["pagination"]
if not pagination["has_next"]:
break
cursor = pagination["next_cursor"]
print(f"Collected {len(videos)} videos")
for v in videos[:5]:
print(v["published_at"], v["likes"], v["url"])For very large profiles, skip pagination and download the whole result at once: once the task is completed, data.download_url holds a short-lived signed URL to the full JSON. Call the GET endpoint again to mint a fresh URL if it expires.
Searching TikTok by Keyword
Keyword search returns videos across many creators, sorted by published_at (newest first) unless you set sort_by (relevance, most_liked, newest). Use published_within (past_24_hours, this_week, this_month, last_3_months, last_6_months) or after_datetime / before_datetime for time windows, and parallel_search_slices (1–4) to lift the result ceiling (~115–140 items per slice) — most useful on searches without a date window.
Results are localized to country (default gb). Pass country: "fr", "de", "jp", ... to get another country's TikTok results; us is not supported, because TikTok asks US visitors to log in before searching.
With the SDK
result = client.search_tiktok(
query="ai tools",
sort_by="most_liked",
published_within="this_month",
min_likes=1000,
include_usage=True,
)
stats = result.data.stats
print(f"{stats.results_count} results, sorted by {stats.sort_by} within {stats.published_within}")
for item in result.data.results or []:
print(item.published_at, item.stats.likes if item.stats else None, item.url)
if result.usage:
print("Credits charged:", result.usage.total_credits)Both calls return every result. Pass limit in Python if you want one page at a time, then page with client.get_tiktok_search(task_id, cursor=...).
With raw HTTP
1. Submit the search
curl -X POST "https://api.vidnavigator.com/v1/tiktok/search" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "ai tools",
"parallel_search_slices": 2,
"after_datetime": "2024-01-01T00:00:00Z",
"min_likes": 1000
}'2. Poll, paginate, and read usage
The polling flow is identical to the profile scrape — just swap the path to /tiktok/search/{task_id} and read data.results instead of data.videos. Pass include_usage=true once the task is completed to see what was billed.
import time
def get_search_page(task_id, cursor=None, limit=50, include_usage=False):
params = {"limit": limit}
if cursor:
params["cursor"] = cursor
if include_usage:
params["include_usage"] = "true"
r = requests.get(f"{BASE}/tiktok/search/{task_id}", headers=HEADERS, params=params)
return r.json()
# Wait for completion
while True:
body = get_search_page(task_id, limit=1)
if body["data"]["task_status"] != "processing":
break
time.sleep(3)
# First completed page, with usage disclosure
body = get_search_page(task_id, limit=50, include_usage=True)
data = body["data"]
print(f"{data['stats']['results_count']} results from {data['stats']['videos_fetched']} videos fetched")
for item in data["results"][:5]:
print(item["published_at"], item["stats"]["likes"], item["url"])
# Usage is at the top level of the response
if "usage" in body:
print("Credits charged:", body["usage"]["total_credits"])Don't pass include_usage on the submit (POST) call — it's ignored because billing happens after the 202 response. Pass it on the polling GET, and only expect a usage block once task_status=completed (failed tasks have all charges refunded).
Searching TikTok LIVE Rooms
LIVE search returns the TikTok LIVE rooms broadcasting right now for a keyword, in TikTok's ranking, with their author, live counters, hashtags, category and stream URLs (FLV and HLS by quality, plus an audio-only stream). Results are localized to country (default us). A search usually takes 20 to 50 seconds.
With the SDK
result = client.tiktok_live_search(query="gaming", country="us", include_usage=True)
for room in result.data.results or []:
print(room.title, room.author.unique_id, room.stats.viewers, room.category, room.hashtags)
if room.stream_urls:
quality = room.stream_urls.default_quality
print(" FLV:", room.stream_urls.flv.get(quality))
print(" HLS:", room.stream_urls.hls.get(quality)) # not every LIVE offers HLS
print(" audio only:", room.stream_urls.audio_only)With raw HTTP
Submit the search, then poll GET /tiktok/live/search/{task_id} exactly like a keyword search, reading data.results:
curl -X POST "https://api.vidnavigator.com/v1/tiktok/live/search" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "gaming", "country": "us"}'
curl "https://api.vidnavigator.com/v1/tiktok/live/search/TASK_ID?limit=50&include_usage=true" \
-H "X-API-Key: YOUR_API_KEY"What to know:
- Each room has
id,url,authorandstatslike a keyword result, plusstarted_at,stats.viewers(watching now),stats.total_viewers,hashtags(the title's#tags),category(e.g.Gaming) andgame_tags. stream_urlsholdsflvandhlsURLs keyed by quality (origin,uhd,hd,sd,ld),default_quality,audio_onlyandexpires_at. They play while the LIVE is on, in VLC,ffmpeg/ffplay, orhls.jsin a browser. They are returned by default; passinclude_stream_urls: falseto leave them out.- A keyword with no LIVE room in that country at that moment completes with zero results. Try another country or keyword.
See the TikTok LIVE Search reference for every field.
Following One LIVE Room
To check a single room or streamer, call POST /tiktok/live/room. It is synchronous: no task, the room comes back in the response, usually within a few seconds. Pass exactly one of room_id (e.g. a LIVE search room's id), username or url.
resp = client.get_tiktok_live_room(username="creator", include_comments=True)
room = resp.data.room
print(room.status, room.stats.viewers, room.stats.new_followers)
for comment in resp.data.comments or []:
print(comment.author.unique_id, comment.text)- The room says whether it is
liveorended(andended_at), with its viewers, the followers gained during the LIVE, the streamer's bio, and the LIVE search room fields. Ausernamegives the current LIVE, or the last one when the streamer is offline. include_comments: trueadds the latest comments (up to 50, newest first), the pinned comment, the intro and the top viewers. TikTok keeps only about the last 50 comments of a LIVE.- Likes, comment counts and share counts are not available for a single room: LIVE search returns them.
- Billing: 1
residential_request, 2 withinclude_comments(1 when the room has ended). A room or account that does not exist (404 live_not_found) is not billed.
Choosing Between Profile and Keyword Search
| Use case | Endpoint |
|---|---|
| Collect one creator's catalog | Profile scrape |
| Track a hashtag, topic, or trend across creators | Keyword search |
| Filter by date range and likes | Both (add after_datetime / before_datetime, min_likes / max_likes) |
| Filter by views | Keyword search (min_views / max_views) |
| Maximize coverage of a keyword | Keyword search with parallel_search_slices up to 4 (no date window) |
| Most popular recent videos for a keyword | Keyword search with sort_by: "most_liked" and published_within |
| Videos from another country's TikTok | Keyword search with country (e.g. fr) |
| Creators streaming now, with stream URLs | LIVE search |
| Is a creator live now? Latest comments of a LIVE | LIVE room |