Docs
Query Videos
Create Query Task
Query
Query Parameters
Key | Type | Description | Example | Required |
category | string | The data category for which the analysis is planned | video | Yes |
condition_groups | object | Specifications for what data should be returned and processed |
| No |
fields | string | Data fields to be returned. Interface will only return the fields listed here. | username, region_code, video_description, music_id, like_count, comment_count, share_count, view_count, effect_ids, hashtag_names, playlist_id, voice_to_text, id, create_time, duration_type, favorites_count,and stem_verified | Yes |
limit | int | The maximum number of records that will be returned. Test Stage The default value is 100, and the maximum value is 5000 per day. Execution Stage The default value is 1000, and the maximum value is 100,000 in one query. | 200 | No |
Query Condition
Key | Type | Description | Required |
and | list<Condition> | The | No |
or | list<Condition> | The | No |
not | list<Condition> | The | No |
Query Condition Fields and Operators
Field | Description | Type | Allowed Operator |
id | Unique identifier for the TikTok video. Also called "item_id" or "video_id" | int64 |
|
create_time | UTC Unix epoch (in seconds) of when the TikTok video was posted. (Inherited field from TNS research API) | int64 |
|
username | The video creator's username | string |
|
region_code | A two digit code for the country the video was posted in | string |
|
video_description | The description of the video, also known as the title | string |
|
music_id | The music_id used in the video | int64 |
|
like_count | The number of likes the video has received. | int64 |
|
comment_count | The number of comments the video has received. | int64 |
|
share_count | The number of shares the video has received. | int64 |
|
view_count | The number of video views the video has received. | int64 |
|
effect_ids | The list of effect ids applied on the video | list<string> |
|
hashtag_names | The list of hashtag names that the video participates in | list<string> |
|
playlist_id | The ID of playlist that the video belongs to | int64 |
|
voice_to_text | Voice to text and subtitles (for videos that have voice to text features on, show the texts already generated) | string |
|
duration_type | int |
|
Create Query Task Sample Code
This interface will create a query task at TikTok, and it will return a task id. Users can use this id to check the status, get the result and cancel the result in the future.
Example
from pyrqs import rqs
category = 'video'
condition_groups = [
{
"operator": "and",
"conditions": [
{
"field": "region_code",
"operator": "eq",
"field_values": ["NL"]
}
]
}
]
fields = 'username,region_code,video_description,music_id,like_count'
limit = 1000
client = rqs.RQSClient()
task_id = client.create_query_task(
category=category, condition_groups=condition_groups, fields=fields, limit=limit)
Response
Key | Type | Description | Example |
task_id | int | Data query job task identifier | 12345 |
Check Query Task Status
Query Parameters
Key | Type | Description | Example | Required |
task_id | int | Data query job task identifier | 12345 | Yes |
Response
Key | Type | Description | Example | Required |
status | string | Data query job task status | Created AnalysisFailed Processing Completed Cancelled Validating | Yes |
Check Query Task Result Code Sample
Example
data = client.get_query_task_result(task_id)
Cancel Query Task
Query Parameters
Key | Type | Description | Example | Required |
task_id | int | Data query job task identifier | 12345 | Yes |
Response
Key | Type | Description | Example |
success | bool | Whether the request was successfullycancelled | True |
Cancel Query Task Sample Code
Example
result = client.cancel_query_task(task_id)
Get Query Task Result
Query Parameters
Key | Type | Description | Example | Required |
task_id | int | Data query job task identifier | 12345 | Yes |
Get_query_task_result_example
Example
data = client.get_query_task_result(task_id)
Response
Key | Type | Description | Example |
result | string | Data fields returned from the query. Interface will only return the fields listed here. | username, country_code, video_description, music_id, like_count, comment_count, share_count, view_count, effect_ids, hashtag_names, playlist_id, voice_to_text, id, create_date, duration_type, favorites_count, and stem_verified. |
Query Video Data from Tiktok via SDK
Example code
from pyrqs import rqs
import time
from datetime import datetime, timedelta
import json
category = 'video'
fields = 'username,like_count,hashtag_info_list,sticker_info_list,video_sticker_id,video_mention_list,video_label'
limit = 100
client = rqs.RQSClient()
condition_groups = [
{
"operator": "and",
"conditions": [
{
"field": "video_description",
"operator": "LIKE",
"field_values": ["%tiktok%"]
},
{
"field": "hashtag_names",
"operator": "CONTAINS",
"field_values": ["tiktok"]
}
]
}
]
data = client.query(category=category, condition_groups=condition_groups, fields=fields, limit=limit)
print(data)