POST /v1/social/tiktok/{action}. {action} picks what to read. A completed request costs 0.5 credits.
Request
200 with the result in response. A task still running answers 202; poll GET /v1/async/task/{id} or set webhook. See Async tasks.
Actions
For
video and comments, videoId and url take a video ID, a video or photo post URL, or a vm.tiktok.com or vt.tiktok.com short link. For creator, username and url take a username, an @username or a profile URL, such as https://www.tiktok.com/@nasa.
Parameters
A request with a parameter of another action, a value outside the ones listed below, or a missing required field is refused when you submit it, with400 VALIDATION_ERROR naming the field.
search:
query: Required, up to 500 characters, with at least one letter or digit.limit: Optional integer from 1 to 50, default 10. A search finds videos through Google results, so it returns up tolimitvideos, fewer when Google lists fewer. It returns one page.
comments:
limit: Optional integer from 1 to 500, default 50. It counts comments and replies together.includeReplies:true(default) reads each comment’s replies after it.falsereturns top-level comments only.
trending:
limit: Optional integer from 1 to 50, default 20.regionCode: A two-letter country code, defaultUS.
Response example
Result fields
- Every response echoes
platformandaction, andprovidernames the source the data was read from. Lists carryreturnedCount. - A video has
videoId,url,caption,hashtags(when the caption has any),author(id,handle,displayName,verified,avatarUrl,profileUrl,followerCount),music(id,title,author,original,durationSeconds),coverUrl,durationSeconds,language,region,publishedAt,viewCount,likeCount,commentCount,shareCountandcollectCount, the times it was saved. Counts above 1 million are the rounded values TikTok shows. searchreturnsvideos, each with itspositionandsource, andhasMoreisfalsewithnextCursornull. A result whose page could not be read carries onlyurl,videoIdand the author’shandleandprofileUrl.videoreturns the video’s fields at the top level.commentsreturnsvideoId,url(nullwhen you sent onlyvideoId),comments,includeReplies,returnedCount,topLevelCount,replyCountandavailableTopLevelCount, the comment count TikTok shows for the video.- A comment has
commentId,videoId,text,author,likeCount,replyCount,publishedAtandparentId, which isnullfor a top-level comment and thecommentIdit answers for a reply. - A video with no comments, or with comments turned off, ends the task with
ENGINE_NO_RESULT.
- A comment has
creatorreturnscreatorId,handle,displayName,bio,bioLink,avatarUrl,profileUrl,verified,privateAccount,createdAt,followerCount,followingCount,likeCountandvideoCount.trendingreturnsvideosand theregionCodeit read.- A video or creator that does not exist or is private ends the task with
PAGE_UNAVAILABLE. Only completed requests are charged.
HTML page
Setinclude.html to true and the result gains html, a link to the TikTok page the answer was read from, saved as a file you can put in a report. html has status, url and expiresAt, described in HTML pages.
include.htmlworks onvideoandcreator.- The file is the HTML document TikTok sent for the page, before any script ran. It starts with a note comment,
Saved by querying.ai: the page TikTok served for task <id> at <UTC time>, the page as TikTok sent it, before any script ran, the address of the visit and its session ids masked. - Values that belong to the visit are replaced with zeros of the same length: cookie values, session, request and device ids, CSRF and other tokens, nonces and the signatures in media addresses. Because those signatures are masked, the image and video links in the file do not load. Content that depends on where the visit came from, such as the regional CDN host names in media addresses, stays as TikTok sent it.
- The document’s scripts are kept as text. The file is served with a Content-Security-Policy that runs no script and loads no outside resource.
- TikTok sends its data inside an embedded JSON script, so the opened file shows almost nothing and the data is in the document source.
- On
video, a short link is kept as the page it redirects to. - Every other action (
search,commentsandtrending) returns422 EVIDENCE_UNSUPPORTEDwhen you submit the task, and the message names why. - The page costs nothing extra: the request is still 0.5 credits.
- When the page cannot be kept, the answer is still returned and
htmlis{ "status": "failed", "error": "EVIDENCE_FAILED" }. Resubmit the task to try again.
Related
- YouTube
- TikTok Ads, for the ads an advertiser runs on TikTok
- Engine overview
- Credits and limits