API Overview
The TikTok API provides powerful search capabilities for discovering TikTok content, including keyword-based searches and trending content discovery across multiple countries.Overview
The TikTok service offers two primary capabilities:- Query Search: Search TikTok content based on keywords or hashtags
- Trending Search: Discover trending TikTok content sorted by various engagement metrics
Job Types
searchbyquery
Searches TikTok content based on keywords, hashtags, or phrases. This job type allows you to find specific content across the TikTok platform.
Use Cases:
- Finding content about specific topics
- Discovering videos with certain hashtags
- Researching content trends for particular keywords
searchbytrending
Retrieves trending TikTok content sorted by various engagement metrics. This job type helps you discover what’s currently popular on TikTok.
Use Cases:
- Monitoring viral content
- Tracking engagement trends
- Analyzing popular content by country
- Understanding what content formats are gaining traction
Parameters
Common Parameters
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
type | string | Yes | - | The job type: searchbyquery or searchbytrending |
max_items | integer | No | 10 | Maximum number of items to return |
searchbyquery
Parameters
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
search | array[string] | Yes | - | Array of search queries (keywords or hashtags) |
searchbytrending
Parameters
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
sort_by | string | No | vv | Sort trending content by metric. See Sort Options |
period | string | No | 7 | Time period for trending content: "7" (week) or "30" (month) |
country_code | string | No | "US" | Country code for regional trending content. See Supported Countries |
Sort Options
Thesort_by
parameter for trending searches supports the following values:
Value | Description | Best For |
---|---|---|
vv | Sort by views/trending score | Finding viral content |
like | Sort by number of likes | High engagement content |
comment | Sort by number of comments | Discussion-generating content |
repost | Sort by number of reposts/shares | Highly shareable content |
API Examples
Search by Query
Basic Keyword Search
Hashtag Search
Multi-Topic Search
Search by Trending
Most Shared Content (Last Week)
Most Commented Videos (Last Month)
Regional Trending Content
Most Liked Content by Country
Use Case Examples
Content Research
Discover what topics are gaining traction:Competitive Analysis
Monitor trending content in specific markets:Engagement Analysis
Find highly engaging content formats:Supported Countries
The TikTok API supports trending content from the following countries:Americas
US
- United StatesCA
- CanadaBR
- Brazil
Europe
GB
- United KingdomFR
- FranceDE
- GermanyIT
- ItalyES
- SpainRU
- RussiaTR
- Turkey
Asia-Pacific
AU
- AustraliaJP
- JapanKR
- South KoreaSG
- SingaporeMY
- MalaysiaID
- IndonesiaTH
- ThailandPH
- PhilippinesVN
- VietnamTW
- TaiwanIL
- Israel
Middle East & Africa
AE
- United Arab EmiratesSA
- Saudi ArabiaEG
- Egypt
Best Practices
1. Query Optimization
- Use specific keywords for targeted results
- Combine related search terms in a single request
- Include both general terms and specific hashtags
2. Trending Analysis
- Use
period: "7"
for current trends - Use
period: "30"
for more stable trend analysis - Compare different
sort_by
metrics to understand content performance
3. Regional Insights
- Always specify
country_code
when analyzing regional markets - Compare trending content across different countries
- Consider cultural context when interpreting results
4. Data Collection
- Set appropriate
max_items
based on your analysis needs - For comprehensive analysis, consider multiple queries with different parameters
- Cache results to avoid redundant API calls
Response Data
While the exact response structure may vary, typical TikTok data includes:- Video Details: Title, description, hashtags, duration
- Engagement Metrics: Views, likes, comments, shares/reposts
- Creator Information: Username, follower count
- Timestamps: Creation date, trending period
- Media URLs: Video URLs, thumbnail images
- Audio Information: Music/sound used in the video
Limitations
- Search results are subject to TikTok’s algorithm and availability
- Historical trending data is limited to 7 or 30-day periods
- Country-specific trending may not reflect global trends
- Content availability may vary by region
- Maximum item limits apply to prevent excessive API usage
Error Handling
Common Error Scenarios
Invalid Country Code
Ensure thecountry_code
parameter uses one of the supported country codes listed above.
Invalid Sort Option
Thesort_by
parameter must be one of: vv
, like
, comment
, or repost
.
Invalid Period
Theperiod
parameter only accepts "7"
or "30"
as string values.
Missing Required Parameters
searchbyquery
requires thesearch
arraysearchbytrending
has all optional parameters but benefits from explicit configuration
Notes
- The
vv
sort option represents TikTok’s trending/view score algorithm - Period values must be strings (
"7"
not7
) - Search queries can include hashtags with or without the
#
symbol - Multiple search terms in the
search
array will return combined results