抖音视频搜索 API (V4)
GET
接口健康状态
24h 健康值
24h 平均耗时
最近检查时间
健康 可用 少量可用 基本不可用 暂无数据
健康
正在加载健康状态…
24 小时趋势
30 天趋势
按关键词搜索抖音视频,支持排序、发布时间、时长和分页筛选;后续页面需要上一页的搜索ID。用于支持内容发现和趋势研究。
请求参数
| 参数名 | 位置 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|---|
token | query | string | 是 | - | 此 API 服务的访问令牌。 |
keyword | query | string | 是 | - | 搜索关键词。 |
sortType | query | string | 否 | _0 | 搜索结果排序标准。 可用值: - _0:综合- _1:点赞最多- _2:最新 |
publishTime | query | string | 否 | _0 | 按视频发布时间范围筛选。 可用值: - _0: 不限- _1: 最近24小时- _7: 最近7天- _180: 最近6个月 |
duration | query | string | 否 | _0 | 按视频时长筛选。 可用值: - _0: 不限时长- _1: 1分钟以内- _2: 1-5分钟- _3: 超过5分钟 |
page | query | integer | 否 | 1 | 页码(从1开始)。 |
searchId | query | string | 否 | - | 搜索ID;页面大于1时需要。使用前一次响应中的 data.business_config.next_page.search_id,当 data.business_config.has_more 为 0 时停止分页。 |
代码示例
bash
curl --max-time 120 -X GET 'https://api.justoneapi.com/api/douyin/search-video/v4?token=YOUR_API_KEY&keyword=VALUE'text
我想使用 JustOneAPI 提供的“视频搜索 (V4)”接口。
接入地址: https://api.justoneapi.com。
接口路径: /api/douyin/search-video/v4?token=YOUR_API_KEY&keyword=VALUE
接口地址: BASE_URL + /api/douyin/search-video/v4?token=YOUR_API_KEY&keyword=VALUE
HTTP 方法: GET
身份验证: 在 URL 中传入 token 查询参数。
OpenAPI 定义: https://docs.justoneapi.com/openapi/douyin-tiktok-china/video-search-v4-zh.json
请求参数说明:
- token (query): 此 API 服务的访问令牌。 (必填)
- keyword (query): 搜索关键词。 (必填)
- sortType (query): 搜索结果排序标准。
可用值:
- `_0`:综合
- `_1`:点赞最多
- `_2`:最新
- publishTime (query): 按视频发布时间范围筛选。
可用值:
- `_0`: 不限
- `_1`: 最近24小时
- `_7`: 最近7天
- `_180`: 最近6个月
- duration (query): 按视频时长筛选。
可用值:
- `_0`: 不限时长
- `_1`: 1分钟以内
- `_2`: 1-5分钟
- `_3`: 超过5分钟
- page (query): 页码(从1开始)。
- searchId (query): 搜索ID;页面大于1时需要。使用前一次响应中的 data.business_config.next_page.search_id,当 data.business_config.has_more 为 0 时停止分页。
返回格式: 请根据实际 Content-Type 安全处理 JSON 或文本响应。
响应处理与错误码:
1. 需通过返回体中的 "code" 字段判断业务结果(code 为 0 表示成功)。
2. 超时建议:建议将请求超时时间设置为 120 秒;如果 120 秒偏长,请至少设置为 60 秒,但可能会有少量请求因超时而未接收到结果。
3. 业务码说明:
- 0: 成功
- 100: Token 无效或已失效
- 301: 采集失败,请重试
- 302: 超出速率限制
- 303: 超出每日配额
- 400: 参数错误
- 500: 内部服务器错误
- 600: 权限不足
- 601: 账户余额不足
- 602: TOKEN 限额超限
4. code 601 表示账户共享余额不足。code 602 表示当前 API TOKEN 自身的累计消费上限已达到。TOKEN 限额不是资金划拨,多个 TOKEN 仍共享同一个账户余额。
请帮我用我擅长的编程语言写一个脚本来调用这个接口,并处理返回结果。python
import requests
BASE_URL = "https://api.justoneapi.com" # 由 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")js
const BASE_URL = "https://api.justoneapi.com"; // 由 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`);
}
}java
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"; // 由 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");
}
}
}go
package main
import (
"fmt"
"io"
"os"
"strings"
"net/http"
"time"
)
const BASE_URL = "https://api.justoneapi.com" // 由 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
<?php
$BASE_URL = 'https://api.justoneapi.com'; // 由 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;
}返回字段
业务成功时(code = 0)的主要返回字段。
搜索结果与分页8 个字段
data
抖音关键词搜索的结果及分页信息。
| 字段 | 类型 | 说明 |
|---|---|---|
business_data | array | 搜索结果卡片列表。同一视频可能出现在多页,可按 aweme_id 对视频结果去重。 |
business_config | object | 分页和查询信息。 |
business_config.keyword | string | 平台返回的搜索关键词。 |
business_config.card_count | integer | 平台返回的当前页结果卡片数量。 |
business_config.has_more | integer | string | 该值为 0 时停止翻页,即使响应仍包含搜索 ID。结果结束时可能只返回此分页标记。 |
business_config.next_page | object | 后续分页信息,有相关信息时返回。 |
business_config.next_page.search_id | string | 用于请求下一页的搜索 ID。将该值传入 searchId,将 page 加 1,并保持关键词和筛选条件一致。连续页面可能返回相同的搜索 ID。 |
status_code | number | string | 抖音搜索状态码,有该值时返回。 |
结果卡片2 个字段
data.business_data[]
| 字段 | 类型 | 说明 |
|---|---|---|
data_id | string | 卡片在当前响应中的标识。 |
type | integer | 结果类型编码。已观察到 1 表示视频结果,66667 表示相关搜索。 |
视频基础信息12 个字段
data.business_data[].data.aweme_info
卡片包含视频结果时返回的抖音视频信息。
| 字段 | 类型 | 说明 |
|---|---|---|
aweme_id | string | 抖音视频的稳定 ID,以字符串返回。可用该值在搜索结果的不同页面中识别同一个视频。 |
group_id | string | 平台返回的作品分组标识。 |
author_user_id | integer | 发布账号的数字型 ID。 |
desc | string | 抖音提供的作品描述。 |
caption | string | 抖音提供的作品文案。 |
item_title | string | 作品标题,有该值时返回。 |
preview_title | string | 作品预览使用的标题。 |
create_time | integer | 视频发布时间,Unix 时间戳,单位为秒。 |
duration | integer | 视频时长,单位为毫秒。 |
aweme_type | integer | 抖音返回的作品类型编码。 |
media_type | integer | 抖音返回的媒体类型编码。 |
ip_attribution | string | 抖音返回的 IP 属地标识,有该值时返回。 |
作者26 个字段
data.business_data[].data.aweme_info.author
随视频返回的作者资料。
| 字段 | 类型 | 说明 |
|---|---|---|
uid | string | 抖音账号 ID,以字符串返回。 |
sec_uid | string | 抖音用户资料接口使用的备用账号标识。 |
nickname | string | 作者的显示昵称。 |
unique_id | string | 公开展示的抖音号,有该值时返回。 |
short_id | string | 抖音返回的账号短标识。 |
follower_count | integer | 平台返回的作者粉丝数。 |
is_verified | boolean | 抖音是否将作者标记为已认证。 |
verification_type | integer | 平台返回的作者认证类别编码。 |
avatar_thumb | object | 作者头像缩略图。 |
avatar_thumb.uri | string | 抖音返回的资源标识。 |
avatar_thumb.url_list | array | 资源的链接列表。 |
avatar_thumb.url_list[] | string | 一条资源链接。 |
avatar_thumb.width | integer | 资源信息中记录的宽度,单位为像素。 |
avatar_thumb.height | integer | 资源信息中记录的高度,单位为像素。 |
avatar_medium | object | 作者头像的中等尺寸版本。 |
avatar_medium.uri | string | 抖音返回的资源标识。 |
avatar_medium.url_list | array | 资源的链接列表。 |
avatar_medium.url_list[] | string | 一条资源链接。 |
avatar_medium.width | integer | 资源信息中记录的宽度,单位为像素。 |
avatar_medium.height | integer | 资源信息中记录的高度,单位为像素。 |
avatar_larger | object | 作者头像的大尺寸版本。 |
avatar_larger.uri | string | 抖音返回的资源标识。 |
avatar_larger.url_list | array | 资源的链接列表。 |
avatar_larger.url_list[] | string | 一条资源链接。 |
avatar_larger.width | integer | 资源信息中记录的宽度,单位为像素。 |
avatar_larger.height | integer | 资源信息中记录的高度,单位为像素。 |
互动指标7 个字段
data.business_data[].data.aweme_info.statistics
平台返回的视频互动统计。
| 字段 | 类型 | 说明 |
|---|---|---|
aweme_id | string | 该统计关联的抖音视频 ID。 |
digg_count | integer | 平台返回的视频点赞数。 |
comment_count | integer | 平台返回的视频评论数。 |
collect_count | integer | 平台返回的视频收藏数。 |
share_count | integer | 平台返回的视频分享数。 |
forward_count | integer | 响应中返回的转发数。 |
download_count | integer | 平台返回的视频下载数。 |
视频封面22 个字段
data.business_data[].data.aweme_info.video
| 字段 | 类型 | 说明 |
|---|---|---|
cover | object | 视频封面图片。 |
cover.uri | string | 抖音返回的资源标识。 |
cover.url_list | array | 资源的链接列表。 |
cover.url_list[] | string | 一条资源链接。 |
cover.width | integer | 资源信息中记录的宽度,单位为像素。 |
cover.height | integer | 资源信息中记录的高度,单位为像素。 |
origin_cover | object | 原始封面字段中的封面图片。 |
origin_cover.uri | string | 抖音返回的资源标识。 |
origin_cover.url_list | array | 资源的链接列表。 |
origin_cover.url_list[] | string | 一条资源链接。 |
origin_cover.width | integer | 资源信息中记录的宽度,单位为像素。 |
origin_cover.height | integer | 资源信息中记录的高度,单位为像素。 |
dynamic_cover | object | 动态封面资源,有相关信息时返回。 |
dynamic_cover.uri | string | 抖音返回的资源标识。 |
dynamic_cover.url_list | array | 资源的链接列表。 |
dynamic_cover.url_list[] | string | 一条资源链接。 |
dynamic_cover.width | integer | 资源信息中记录的宽度,单位为像素。 |
dynamic_cover.height | integer | 资源信息中记录的高度,单位为像素。 |
animated_cover | object | 动画封面资源,有相关信息时返回。 |
animated_cover.uri | string | 抖音返回的资源标识。 |
animated_cover.url_list | array | 资源的链接列表。 |
animated_cover.url_list[] | string | 一条资源链接。 |
播放与清晰度51 个字段
data.business_data[].data.aweme_info.video
视频信息及可用的播放资源。
| 字段 | 类型 | 说明 |
|---|---|---|
duration | integer | 视频时长,单位为毫秒。 |
width | integer | 抖音返回的视频宽度,单位为像素。 |
height | integer | 抖音返回的视频高度,单位为像素。 |
format | string | 抖音返回的视频格式。 |
ratio | string | 抖音返回的清晰度标签。 |
has_watermark | boolean | 视频信息中返回的水印标记。 |
play_addr | object | 视频的主要播放地址。 |
play_addr.uri | string | 抖音返回的资源标识。 |
play_addr.url_list | array | 资源的链接列表。 |
play_addr.url_list[] | string | 一条资源链接。 |
play_addr.width | integer | 资源信息中记录的宽度,单位为像素。 |
play_addr.height | integer | 资源信息中记录的高度,单位为像素。 |
play_addr.data_size | integer | 资源信息中记录的文件大小,单位为字节。 |
play_addr_h264 | object | H.264 版本的播放地址。 |
play_addr_h264.uri | string | 抖音返回的资源标识。 |
play_addr_h264.url_list | array | 资源的链接列表。 |
play_addr_h264.url_list[] | string | 一条资源链接。 |
play_addr_h264.width | integer | 资源信息中记录的宽度,单位为像素。 |
play_addr_h264.height | integer | 资源信息中记录的高度,单位为像素。 |
play_addr_h264.data_size | integer | 资源信息中记录的文件大小,单位为字节。 |
play_addr_265 | object | H.265 播放字段中返回的地址。 |
play_addr_265.uri | string | 抖音返回的资源标识。 |
play_addr_265.url_list | array | 资源的链接列表。 |
play_addr_265.url_list[] | string | 一条资源链接。 |
play_addr_265.width | integer | 资源信息中记录的宽度,单位为像素。 |
play_addr_265.height | integer | 资源信息中记录的高度,单位为像素。 |
play_addr_265.data_size | integer | 资源信息中记录的文件大小,单位为字节。 |
download_addr | object | 视频下载地址。 |
download_addr.uri | string | 抖音返回的资源标识。 |
download_addr.url_list | array | 资源的链接列表。 |
download_addr.url_list[] | string | 一条资源链接。 |
download_addr.width | integer | 资源信息中记录的宽度,单位为像素。 |
download_addr.height | integer | 资源信息中记录的高度,单位为像素。 |
download_addr.data_size | integer | 资源信息中记录的文件大小,单位为字节。 |
bit_rate | array | 视频的播放编码版本和码率信息。 |
bit_rate[] | object | 视频的一个播放编码版本。 |
bit_rate[].bit_rate | integer | 编码码率,单位为比特每秒。 |
bit_rate[].FPS | integer | 帧率,单位为帧每秒。 |
bit_rate[].format | string | 平台返回的该编码版本媒体格式。 |
bit_rate[].gear_name | string | 平台返回的该版本编码档位标签。 |
bit_rate[].quality_type | integer | 平台返回的该编码版本画质类别编码。 |
bit_rate[].is_h265 | integer | 平台返回的该版本 H.265 编码标记。 |
bit_rate[].HDR_type | string | 该编码版本返回的 HDR 类别标签。 |
bit_rate[].HDR_bit | string | 该编码版本返回的 HDR 位深标签。 |
bit_rate[].play_addr | object | 该编码版本的播放地址。 |
bit_rate[].play_addr.uri | string | 抖音返回的资源标识。 |
bit_rate[].play_addr.url_list | array | 资源的链接列表。 |
bit_rate[].play_addr.url_list[] | string | 一条资源链接。 |
bit_rate[].play_addr.width | integer | 资源信息中记录的宽度,单位为像素。 |
bit_rate[].play_addr.height | integer | 资源信息中记录的高度,单位为像素。 |
bit_rate[].play_addr.data_size | integer | 资源信息中记录的文件大小,单位为字节。 |
音乐与音频17 个字段
data.business_data[].data.aweme_info.music
与视频关联的音乐或声音信息。
| 字段 | 类型 | 说明 |
|---|---|---|
id | integer | 数字型音乐 ID。在 JavaScript 中使用支持无损数字解析的 JSON 解析器保留完整值。 |
id_str | string | 音乐 ID,以字符串返回。 |
mid | string | mid 字段返回的音乐 ID。 |
title | string | 声音或音乐音轨的标题。 |
author | string | 随音轨返回的艺人或声音创作者名称。 |
album | string | 专辑名称,有该值时返回。 |
is_original_sound | boolean | 抖音是否将该音轨标记为原声。 |
cover_thumb | object | 声音或音乐音轨的封面缩略图。 |
cover_thumb.uri | string | 抖音返回的资源标识。 |
cover_thumb.url_list | array | 资源的链接列表。 |
cover_thumb.url_list[] | string | 一条资源链接。 |
cover_thumb.width | integer | 资源信息中记录的宽度,单位为像素。 |
cover_thumb.height | integer | 资源信息中记录的高度,单位为像素。 |
play_url | object | 声音或音乐音轨的播放资源。 |
play_url.uri | string | 抖音返回的资源标识。 |
play_url.url_list | array | 资源的链接列表。 |
play_url.url_list[] | string | 一条资源链接。 |
分享、话题与提及19 个字段
data.business_data[].data.aweme_info
| 字段 | 类型 | 说明 |
|---|---|---|
share_url | string | 视频的抖音分享链接。 |
share_info | object | 分享视频时使用的信息。 |
share_info.share_url | string | 分享视频时使用的链接。 |
share_info.share_title | string | 分享视频时使用的标题。 |
share_info.share_desc | string | 分享视频时使用的说明文本。 |
text_extra | array | null | 作品文本关联的话题标签与提及的账号列表,可能为 null。 |
text_extra[] | object | 一项文本标注。 |
text_extra[].type | integer | 抖音返回的文本标注类型编码。 |
text_extra[].hashtag_id | string | 标注表示话题标签时,对应的话题标签 ID。 |
text_extra[].hashtag_name | string | 被标注的话题标签名称。 |
text_extra[].user_id | string | 标注提及用户时,对应的抖音账号 ID。 |
text_extra[].sec_uid | string | 被提及用户的抖音备用账号标识。 |
text_extra[].is_commerce | boolean | 抖音是否将该话题标签标记为商业内容。 |
cha_list | array | null | 与作品关联的话题或挑战列表,可能为 null。 |
cha_list[] | object | 一个话题或挑战。 |
cha_list[].cid | string | 抖音话题或挑战的 ID。 |
cha_list[].cha_name | string | 话题或挑战的名称。 |
cha_list[].desc | string | 话题或挑战的说明。 |
cha_list[].is_commerce | boolean | 抖音是否将该话题或挑战标记为商业内容。 |
相关搜索3 个字段
data.business_data[].data
| 字段 | 类型 | 说明 |
|---|---|---|
related_word_list | array | 结果卡片包含相关搜索时返回的推荐词列表。 |
related_word_list[] | object | 一条相关搜索建议。 |
related_word_list[].related_word | string | 推荐的相关搜索词。 |
其他字段2 个字段
| 字段路径 | 类型 | 说明 |
|---|---|---|
data.business_data[] | object | 搜索结果列表中的一张卡片。 |
data.business_data[].data | object | 结果卡片的内容,具体字段取决于卡片类型。 |
响应示例
正在加载响应示例…