Douyin (TikTok China) Video Search API (V4)
Searches Douyin (TikTok China) videos by keyword with sort, publish-time, duration, and page filters; later pages require the previous search ID. Use it to support content discovery and trend research.
Parameters
| Name | In | Type | Required | Default | Description |
|---|---|---|---|---|---|
token | query | string | Yes | - | Access token for this API service. |
keyword | query | string | Yes | - | The search keyword. |
sortType | query | string | No | _0 | Sorting criteria for search results. Available Values: - _0: General- _1: More likes- _2: Newest |
publishTime | query | string | No | _0 | Filter by video publish time range. Available Values: - _0: No Limit- _1: Last 24 Hours- _7: Last 7 Days- _180: Last 6 Months |
duration | query | string | No | _0 | Filter by video duration. Available Values: - _0: No Limit- _1: Under 1 Minute- _2: 1-5 Minutes- _3: Over 5 Minutes |
page | query | integer | No | 1 | Page number (starting from 1). |
searchId | query | string | No | - | Search ID; required for pages > 1. Use data.business_config.next_page.search_id from the previous response, and stop paging when data.business_config.has_more is 0. |
Code Samples
curl --max-time 120 -X GET 'https://api.justoneapi.com/api/douyin/search-video/v4?token=YOUR_API_KEY&keyword=VALUE'I want to use the "Video Search (V4)" API from JustOneAPI.
Base URL: https://api.justoneapi.com.
API Path: /api/douyin/search-video/v4?token=YOUR_API_KEY&keyword=VALUE
API Endpoint: BASE_URL + /api/douyin/search-video/v4?token=YOUR_API_KEY&keyword=VALUE
HTTP Method: GET
Authentication: Append the "token" query parameter to the URL.
OpenAPI Definition: https://docs.justoneapi.com/openapi/douyin-tiktok-china/video-search-v4-en.json
Parameters:
- token (query): Access token for this API service. (Required)
- keyword (query): The search keyword. (Required)
- sortType (query): Sorting criteria for search results.
Available Values:
- `_0`: General
- `_1`: More likes
- `_2`: Newest
- publishTime (query): Filter by video publish time range.
Available Values:
- `_0`: No Limit
- `_1`: Last 24 Hours
- `_7`: Last 7 Days
- `_180`: Last 6 Months
- duration (query): Filter by video duration.
Available Values:
- `_0`: No Limit
- `_1`: Under 1 Minute
- `_2`: 1-5 Minutes
- `_3`: Over 5 Minutes
- page (query): Page number (starting from 1).
- searchId (query): Search ID; required for pages > 1. Use data.business_config.next_page.search_id from the previous response, and stop paging when data.business_config.has_more is 0.
Return format: safely handle JSON or text according to the actual Content-Type.
Response Handling & Error Codes:
1. Business results should be determined by the "code" field in the response body (code 0 means success).
2. Timeout Recommendation: Set the request timeout to 120 seconds. If 120 seconds is too long for your use case, use at least 60 seconds, but a small number of requests may time out before receiving a result.
3. Business Code Reference:
- 0: Success
- 100: Invalid or Inactive Token
- 301: Collection Failed. Please Retry.
- 302: Rate Limit Exceeded
- 303: Daily Quota Exceeded
- 400: Invalid Parameters
- 500: Internal Server Error
- 600: Permission Denied
- 601: Insufficient Balance
- 602: Token Budget Exceeded
4. Code 601 means the shared account balance is insufficient. Code 602 means the current API token's own cumulative budget limit has been reached. Token budget limits do not transfer funds out of the shared account balance.
Please help me write a script in my preferred programming language to call this API and handle the response.import requests
BASE_URL = "https://api.justoneapi.com" # Provided by OpenAPI servers
url = BASE_URL + "/api/douyin/search-video/v4?token=YOUR_API_KEY&keyword=VALUE"
response = requests.get(url, timeout=120)
print(response.status_code)
if response.content:
content_type = response.headers.get("content-type", "").lower()
if "json" in content_type:
try:
print(response.json())
except ValueError:
print(response.text)
elif content_type.startswith("text/") or "xml" in content_type or content_type.split(";", 1)[0].strip() in {"application/javascript", "application/x-www-form-urlencoded", "application/graphql"}:
print(response.text)
else:
with open("response.bin", "wb") as output:
output.write(response.content)
print(f"Saved {len(response.content)} bytes to response.bin")const BASE_URL = "https://api.justoneapi.com"; // Provided by OpenAPI servers
const url = BASE_URL + "/api/douyin/search-video/v4?token=YOUR_API_KEY&keyword=VALUE";
const response = await fetch(url, {
method: "GET",
signal: AbortSignal.timeout(120000)
});
console.log(response.status);
const responseBytes = await response.arrayBuffer();
if (responseBytes.byteLength) {
const contentType = (response.headers.get("content-type") || "").toLowerCase();
const mediaType = contentType.split(";", 1)[0].trim();
const textual = contentType.startsWith("text/") || contentType.includes("json") || contentType.includes("xml") || ["application/javascript", "application/x-www-form-urlencoded", "application/graphql"].includes(mediaType);
if (textual) {
const responseText = new TextDecoder().decode(responseBytes);
let data = responseText;
if (contentType.includes("json")) {
try { data = JSON.parse(responseText); } catch { /* Keep the raw body. */ }
}
console.log(data);
} else {
console.log(`Received ${responseBytes.byteLength} binary bytes`);
}
}import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
public class Main {
public static void main(String[] args) throws Exception {
final String BASE_URL = "https://api.justoneapi.com"; // Provided by OpenAPI servers
final String url = BASE_URL + "/api/douyin/search-video/v4?token=YOUR_API_KEY&keyword=VALUE";
HttpClient client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(120)).build();
HttpRequest.Builder builder = HttpRequest.newBuilder()
.uri(URI.create(url))
.timeout(Duration.ofSeconds(120))
.method("GET", HttpRequest.BodyPublishers.noBody());
HttpRequest request = builder.build();
HttpResponse<byte[]> response = client.send(request, HttpResponse.BodyHandlers.ofByteArray());
System.out.println(response.statusCode());
String contentType = response.headers().firstValue("content-type").orElse("").toLowerCase();
String mediaType = contentType.split(";", 2)[0].trim();
if (contentType.startsWith("text/") || contentType.contains("json") || contentType.contains("xml") || mediaType.equals("application/javascript") || mediaType.equals("application/x-www-form-urlencoded") || mediaType.equals("application/graphql")) {
System.out.println(new String(response.body(), StandardCharsets.UTF_8));
} else {
Files.write(Path.of("response.bin"), response.body());
System.out.println("Saved " + response.body().length + " bytes to response.bin");
}
}
}package main
import (
"fmt"
"io"
"os"
"strings"
"net/http"
"time"
)
const BASE_URL = "https://api.justoneapi.com" // Provided by OpenAPI servers
func main() {
client := &http.Client{Timeout: 120 * time.Second}
url := BASE_URL + "/api/douyin/search-video/v4?token=YOUR_API_KEY&keyword=VALUE"
req, _ := http.NewRequest("GET", url, nil)
resp, _ := client.Do(req)
defer resp.Body.Close()
fmt.Println(resp.StatusCode)
bodyBytes, _ := io.ReadAll(resp.Body)
contentType := strings.ToLower(resp.Header.Get("Content-Type"))
mediaType := strings.TrimSpace(strings.SplitN(contentType, ";", 2)[0])
if strings.HasPrefix(contentType, "text/") || strings.Contains(contentType, "json") || strings.Contains(contentType, "xml") || mediaType == "application/javascript" || mediaType == "application/x-www-form-urlencoded" || mediaType == "application/graphql" {
fmt.Println(string(bodyBytes))
} else {
os.WriteFile("response.bin", bodyBytes, 0600)
fmt.Printf("Saved %d bytes to response.bin\n", len(bodyBytes))
}
}<?php
$BASE_URL = 'https://api.justoneapi.com'; // Provided by OpenAPI servers
$url = $BASE_URL . '/api/douyin/search-video/v4?token=YOUR_API_KEY&keyword=VALUE';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
$contentType = strtolower((string) curl_getinfo($ch, CURLINFO_CONTENT_TYPE));
curl_close($ch);
echo $status . PHP_EOL;
$mediaType = trim(explode(';', $contentType, 2)[0]);
if (str_starts_with($contentType, 'text/') || str_contains($contentType, 'json') || str_contains($contentType, 'xml') || in_array($mediaType, ['application/javascript', 'application/x-www-form-urlencoded', 'application/graphql'], true)) {
echo $response;
} else {
file_put_contents('response.bin', $response);
echo 'Saved ' . strlen($response) . ' bytes to response.bin' . PHP_EOL;
}Response Fields
Key fields in a successful response (code = 0).
Search results and pagination8 fields
data
Search results and pagination details supplied for the Douyin keyword query.
| Field | Type | Description |
|---|---|---|
business_data | array | Search result cards. The same video may appear on multiple pages. Use aweme_id to deduplicate video results. |
business_config | object | Pagination and query information. |
business_config.keyword | string | Keyword reported for this search. |
business_config.card_count | integer | Number of cards reported for this result page. |
business_config.has_more | integer | string | Stop when this flag is 0, including when a search ID is still present. An end-of-results response may contain only the pagination flag. |
business_config.next_page | object | Continuation information when supplied. |
business_config.next_page.search_id | string | Search ID for the next page. Pass it as searchId, increment page by one and keep the keyword and filters unchanged. Successive pages may return the same search ID. |
status_code | number | string | Douyin search status code when supplied. |
Result cards2 fields
data.business_data[]
| Field | Type | Description |
|---|---|---|
data_id | string | Identifier of the card within the current response. |
type | integer | Result kind code. Observed kinds include 1 for video results and 66667 for related searches. |
Video information12 fields
data.business_data[].data.aweme_info
A Douyin video result when the card includes one.
| Field | Type | Description |
|---|---|---|
aweme_id | string | Stable Douyin video ID encoded as a string. Use this value to identify the video across search pages. |
group_id | string | Group identifier reported for the post. |
author_user_id | integer | Numeric ID of the posting account. |
desc | string | Post description supplied by Douyin. |
caption | string | Post caption supplied by Douyin. |
item_title | string | Post title, when supplied. |
preview_title | string | Title supplied for the post preview. |
create_time | integer | Video publication time as a Unix timestamp in seconds. |
duration | integer | Video duration in milliseconds. |
aweme_type | integer | Post type code reported by Douyin. |
media_type | integer | Media type code reported by Douyin. |
ip_attribution | string | IP region label reported by Douyin, when available. |
Author26 fields
data.business_data[].data.aweme_info.author
Author profile information returned with the video.
| Field | Type | Description |
|---|---|---|
uid | string | Douyin account ID encoded as a string. |
sec_uid | string | Secondary Douyin account identifier used by user profile endpoints. |
nickname | string | Author’s display name. |
unique_id | string | Public Douyin account handle, when available. |
short_id | string | Short account identifier reported by Douyin. |
follower_count | integer | Follower count reported for the author. |
is_verified | boolean | Whether Douyin reports the author as verified. |
verification_type | integer | Verification category code reported for the author. |
avatar_thumb | object | Thumbnail avatar for the author. |
avatar_thumb.uri | string | Resource identifier reported by Douyin. |
avatar_thumb.url_list | array | URLs supplied for the resource. |
avatar_thumb.url_list[] | string | URL supplied for the resource. |
avatar_thumb.width | integer | Resource width in pixels reported in the metadata. |
avatar_thumb.height | integer | Resource height in pixels reported in the metadata. |
avatar_medium | object | Medium avatar for the author. |
avatar_medium.uri | string | Resource identifier reported by Douyin. |
avatar_medium.url_list | array | URLs supplied for the resource. |
avatar_medium.url_list[] | string | URL supplied for the resource. |
avatar_medium.width | integer | Resource width in pixels reported in the metadata. |
avatar_medium.height | integer | Resource height in pixels reported in the metadata. |
avatar_larger | object | Larger avatar for the author. |
avatar_larger.uri | string | Resource identifier reported by Douyin. |
avatar_larger.url_list | array | URLs supplied for the resource. |
avatar_larger.url_list[] | string | URL supplied for the resource. |
avatar_larger.width | integer | Resource width in pixels reported in the metadata. |
avatar_larger.height | integer | Resource height in pixels reported in the metadata. |
Engagement7 fields
data.business_data[].data.aweme_info.statistics
Engagement counts reported for the video.
| Field | Type | Description |
|---|---|---|
aweme_id | string | Douyin video ID associated with these statistics. |
digg_count | integer | Number of likes reported for the video. |
comment_count | integer | Number of comments reported for the video. |
collect_count | integer | Number of saves reported for the video. |
share_count | integer | Number of shares reported for the video. |
forward_count | integer | Forward count supplied in the response. |
download_count | integer | Number of downloads reported for the video. |
Video covers22 fields
data.business_data[].data.aweme_info.video
| Field | Type | Description |
|---|---|---|
cover | object | Video cover image. |
cover.uri | string | Resource identifier reported by Douyin. |
cover.url_list | array | URLs supplied for the resource. |
cover.url_list[] | string | URL supplied for the resource. |
cover.width | integer | Resource width in pixels reported in the metadata. |
cover.height | integer | Resource height in pixels reported in the metadata. |
origin_cover | object | Cover image in the original cover field. |
origin_cover.uri | string | Resource identifier reported by Douyin. |
origin_cover.url_list | array | URLs supplied for the resource. |
origin_cover.url_list[] | string | URL supplied for the resource. |
origin_cover.width | integer | Resource width in pixels reported in the metadata. |
origin_cover.height | integer | Resource height in pixels reported in the metadata. |
dynamic_cover | object | Moving cover resource when available. |
dynamic_cover.uri | string | Resource identifier reported by Douyin. |
dynamic_cover.url_list | array | URLs supplied for the resource. |
dynamic_cover.url_list[] | string | URL supplied for the resource. |
dynamic_cover.width | integer | Resource width in pixels reported in the metadata. |
dynamic_cover.height | integer | Resource height in pixels reported in the metadata. |
animated_cover | object | Animated cover resource when available. |
animated_cover.uri | string | Resource identifier reported by Douyin. |
animated_cover.url_list | array | URLs supplied for the resource. |
animated_cover.url_list[] | string | URL supplied for the resource. |
Playback and quality51 fields
data.business_data[].data.aweme_info.video
Video metadata and available playback resources.
| Field | Type | Description |
|---|---|---|
duration | integer | Video duration in milliseconds. |
width | integer | Video width reported by Douyin in pixels. |
height | integer | Video height reported by Douyin in pixels. |
format | string | Video format reported by Douyin. |
ratio | string | Resolution label reported by Douyin. |
has_watermark | boolean | Watermark flag from the video metadata. |
play_addr | object | Primary playback address supplied for the video. |
play_addr.uri | string | Resource identifier reported by Douyin. |
play_addr.url_list | array | URLs supplied for the resource. |
play_addr.url_list[] | string | URL supplied for the resource. |
play_addr.width | integer | Resource width in pixels reported in the metadata. |
play_addr.height | integer | Resource height in pixels reported in the metadata. |
play_addr.data_size | integer | Resource file size in bytes reported in the metadata. |
play_addr_h264 | object | Address supplied for the H.264 variant. |
play_addr_h264.uri | string | Resource identifier reported by Douyin. |
play_addr_h264.url_list | array | URLs supplied for the resource. |
play_addr_h264.url_list[] | string | URL supplied for the resource. |
play_addr_h264.width | integer | Resource width in pixels reported in the metadata. |
play_addr_h264.height | integer | Resource height in pixels reported in the metadata. |
play_addr_h264.data_size | integer | Resource file size in bytes reported in the metadata. |
play_addr_265 | object | Address supplied in the H.265 playback field. |
play_addr_265.uri | string | Resource identifier reported by Douyin. |
play_addr_265.url_list | array | URLs supplied for the resource. |
play_addr_265.url_list[] | string | URL supplied for the resource. |
play_addr_265.width | integer | Resource width in pixels reported in the metadata. |
play_addr_265.height | integer | Resource height in pixels reported in the metadata. |
play_addr_265.data_size | integer | Resource file size in bytes reported in the metadata. |
download_addr | object | Download address supplied for the video. |
download_addr.uri | string | Resource identifier reported by Douyin. |
download_addr.url_list | array | URLs supplied for the resource. |
download_addr.url_list[] | string | URL supplied for the resource. |
download_addr.width | integer | Resource width in pixels reported in the metadata. |
download_addr.height | integer | Resource height in pixels reported in the metadata. |
download_addr.data_size | integer | Resource file size in bytes reported in the metadata. |
bit_rate | array | Playback encodings and bitrate metadata supplied for the video. |
bit_rate[] | object | One playback encoding supplied for the video. |
bit_rate[].bit_rate | integer | Encoding bitrate in bits per second. |
bit_rate[].FPS | integer | Frame rate in frames per second. |
bit_rate[].format | string | Media format reported for this encoding. |
bit_rate[].gear_name | string | Encoder preset label reported for this variant. |
bit_rate[].quality_type | integer | Quality category code reported for this encoding. |
bit_rate[].is_h265 | integer | H.265 encoding flag reported for this variant. |
bit_rate[].HDR_type | string | HDR category label returned for the encoding. |
bit_rate[].HDR_bit | string | HDR bit-depth label returned for the encoding. |
bit_rate[].play_addr | object | Playback address for this encoding. |
bit_rate[].play_addr.uri | string | Resource identifier reported by Douyin. |
bit_rate[].play_addr.url_list | array | URLs supplied for the resource. |
bit_rate[].play_addr.url_list[] | string | URL supplied for the resource. |
bit_rate[].play_addr.width | integer | Resource width in pixels reported in the metadata. |
bit_rate[].play_addr.height | integer | Resource height in pixels reported in the metadata. |
bit_rate[].play_addr.data_size | integer | Resource file size in bytes reported in the metadata. |
Music and audio17 fields
data.business_data[].data.aweme_info.music
Music or sound metadata associated with the video.
| Field | Type | Description |
|---|---|---|
id | integer | Numeric music ID. Use a lossless JSON parser to retain the full value in JavaScript. |
id_str | string | Music ID encoded as a string. |
mid | string | Music ID returned in the mid field. |
title | string | Title of the sound or music track. |
author | string | Artist or sound creator name returned with the track. |
album | string | Album title when supplied. |
is_original_sound | boolean | Whether Douyin marks the track as original sound. |
cover_thumb | object | Thumbnail cover for the sound or music track. |
cover_thumb.uri | string | Resource identifier reported by Douyin. |
cover_thumb.url_list | array | URLs supplied for the resource. |
cover_thumb.url_list[] | string | URL supplied for the resource. |
cover_thumb.width | integer | Resource width in pixels reported in the metadata. |
cover_thumb.height | integer | Resource height in pixels reported in the metadata. |
play_url | object | Playback resource for the sound or music track. |
play_url.uri | string | Resource identifier reported by Douyin. |
play_url.url_list | array | URLs supplied for the resource. |
play_url.url_list[] | string | URL supplied for the resource. |
Sharing, topics, and mentions19 fields
data.business_data[].data.aweme_info
| Field | Type | Description |
|---|---|---|
share_url | string | Douyin share URL for the video. |
share_info | object | Metadata supplied for sharing the video. |
share_info.share_url | string | URL supplied for sharing the video. |
share_info.share_title | string | Title supplied for sharing the video. |
share_info.share_desc | string | Description supplied for sharing the video. |
text_extra | array | null | Hashtags and user mentions associated with the post text. This list may be null. |
text_extra[] | object | One text annotation. |
text_extra[].type | integer | Annotation type code reported by Douyin. |
text_extra[].hashtag_id | string | ID of the annotated hashtag when the annotation represents a hashtag. |
text_extra[].hashtag_name | string | Name of the annotated hashtag. |
text_extra[].user_id | string | Douyin account ID when the annotation mentions a user. |
text_extra[].sec_uid | string | Secondary Douyin account ID for the mentioned user. |
text_extra[].is_commerce | boolean | Whether Douyin flags the annotated hashtag as commercial. |
cha_list | array | null | Topic or challenge details associated with the post. This list may be null. |
cha_list[] | object | One topic or challenge. |
cha_list[].cid | string | Douyin topic or challenge ID. |
cha_list[].cha_name | string | Topic or challenge name. |
cha_list[].desc | string | Description of the topic or challenge. |
cha_list[].is_commerce | boolean | Whether Douyin flags the topic or challenge as commercial. |
Related searches3 fields
data.business_data[].data
| Field | Type | Description |
|---|---|---|
related_word_list | array | Suggested related search terms when the card includes them. |
related_word_list[] | object | One related search suggestion. |
related_word_list[].related_word | string | Suggested related search term. |
Other fields2 fields
| Field path | Type | Description |
|---|---|---|
data.business_data[] | object | One card returned in the search result list. |
data.business_data[].data | object | Content supplied for the result card. Fields depend on the card kind. |