快手视频搜索 API (V2)
接口健康状态
健康 可用 少量可用 基本不可用 暂无数据
正在加载健康状态…
通过关键词搜索快手公开视频,支持页码分页。用于发现相关视频并按页浏览结果。
请求参数
| 参数名 | 位置 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|---|
token | query | string | 是 | - | 此 API 服务的访问令牌。 |
keyword | query | string | 是 | - | 用于查找视频的搜索关键词。 |
page | query | integer | 否 | 1 | 结果页码,从1开始。 |
代码示例
bash
curl --max-time 120 -X GET 'https://api.justoneapi.com/api/kuaishou/search-video/v2?token=YOUR_API_KEY&keyword=VALUE'text
我想使用 JustOneAPI 提供的“视频搜索 (V2)”接口。
接入地址: https://api.justoneapi.com。
接口路径: /api/kuaishou/search-video/v2?token=YOUR_API_KEY&keyword=VALUE
接口地址: BASE_URL + /api/kuaishou/search-video/v2?token=YOUR_API_KEY&keyword=VALUE
HTTP 方法: GET
身份验证: 在 URL 中传入 token 查询参数。
OpenAPI 定义: https://docs.justoneapi.com/openapi/kuaishou/video-search-v2-zh.json
请求参数说明:
- token (query): 此 API 服务的访问令牌。 (必填)
- keyword (query): 用于查找视频的搜索关键词。 (必填)
- page (query): 结果页码,从1开始。
返回格式: 请根据实际 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/kuaishou/search-video/v2?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/kuaishou/search-video/v2?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/kuaishou/search-video/v2?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/kuaishou/search-video/v2?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/kuaishou/search-video/v2?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)的主要返回字段。
作品基本信息15 个字段
data.feeds[]
一条快手作品搜索结果。
| 字段 | 类型 | 说明 |
|---|---|---|
photo_id | integer | 快手作品 ID,以 JSON 整数返回。请使用无损 JSON 解析保留完整 ID。 |
caption | string | 作品展示的描述文本。 |
time | string | 发布时间展示文本。 |
timestamp | integer | 作品发布时间,以 Unix 毫秒级时间戳返回。 |
type | integer | 搜索结果的数字内容类型。 |
photo_status | integer | 快手作品的数字状态码。 |
longVideo | boolean | 作品是否被标记为长视频,此字段可能返回。 |
editInfo | object | 作品的编辑信息,可能返回。 |
editInfo.editVersion | integer | 作品的编辑版本。 |
editInfo.editTime | integer | 作品编辑时间,以 Unix 毫秒级时间戳返回。 |
editInfo.coverVersion | integer | 作品封面的编辑版本。 |
disclaimerMessage | string | 作品附带的提示文本,可能返回。 |
hasVote | boolean | 作品是否被标记为含有投票。 |
hasMusicTag | boolean | 作品是否带有音乐标签。 |
tags | array | 作品的标签列表。 |
分页与结果2 个字段
data
所请求关键词的快手公开作品分页结果。
| 字段 | 类型 | 说明 |
|---|---|---|
result | integer | 平台返回的结果码。已核验的成功搜索响应中返回 1。 |
feeds | array | 请求页返回的作品列表。同一作品可能出现在多页,可用 photo_id 匹配跨页作品。 |
作者8 个字段
data.feeds[]
| 字段 | 类型 | 说明 |
|---|---|---|
user_id | integer | 快手作者的数字 ID。 |
user_name | string | 发布者的展示名称。 |
kwaiId | string | 作者展示的快手号,可能返回。 |
verified | boolean | 作者是否标记为已认证。 |
headurl | string | 作者头像图片 URL。 |
headurls | array | 作者头像的可用图片链接。 |
headurls[] | object | 该媒体的一条备选链接。 |
headurls[].url | string | 该媒体版本的 URL。 |
互动数据5 个字段
data.feeds[]
| 字段 | 类型 | 说明 |
|---|---|---|
like_count | integer | 作品的点赞数。 |
comment_count | integer | 作品的评论数。 |
view_count | integer | 作品的观看次数。 |
forward_count | integer | 作品的转发次数。 |
share_count | integer | 作品的分享次数。 |
媒体链接与相册24 个字段
data.feeds[]
| 字段 | 类型 | 说明 |
|---|---|---|
duration | integer | 视频返回的时长。图片作品可能没有此字段。 |
main_url | string | 作品的主图 URL。 |
thumbnail_url | string | 作品缩略图 URL。 |
main_mv_url | string | 作品返回的主要视频 URL。 |
main_mv_urls | array | 主要视频的可用 URL 列表。 |
main_mv_urls[] | object | 该媒体的一条备选链接。 |
main_mv_urls[].url | string | 该媒体版本的 URL。 |
thumbnail_urls | array | 作品缩略图的可用 URL 列表。 |
thumbnail_urls[] | object | 该媒体的一条备选链接。 |
thumbnail_urls[].url | string | 该媒体版本的 URL。 |
cover_thumbnail_urls | array | 作品封面缩略图的可用 URL 列表。 |
cover_thumbnail_urls[] | object | 该媒体的一条备选链接。 |
cover_thumbnail_urls[].url | string | 该媒体版本的 URL。 |
ext_params | object | 作品的尺寸和可选相册信息。 |
ext_params.mtype | integer | 作品的数字媒体类型。 |
ext_params.w | integer | 媒体宽度,单位为像素。 |
ext_params.h | integer | 媒体高度,单位为像素。 |
ext_params.atlas | object | 多图作品的相册信息。 |
ext_params.atlas.list | array | 按展示顺序返回的相册图片引用,已核验的条目为路径字符串。 |
ext_params.atlas.list[] | string | 一张相册图片的引用路径。 |
ext_params.atlas.size | array | 相册图片尺寸列表,已核验的响应中与 list 按位置对应。 |
ext_params.atlas.size[] | object | 相册中一张图片的尺寸。 |
ext_params.atlas.size[].w | integer | 图片宽度,单位为像素。 |
ext_params.atlas.size[].h | integer | 图片高度,单位为像素。 |
播放清单22 个字段
data.feeds[]
| 字段 | 类型 | 说明 |
|---|---|---|
streamManifest | object | 视频媒体的播放清单。 |
streamManifest.version | string | 播放清单版本。 |
streamManifest.videoId | string | 播放清单中使用的视频标识符。 |
streamManifest.adaptationSet | array | 播放清单中的播放版本分组。 |
streamManifest.adaptationSet[] | object | 一组播放版本。 |
streamManifest.adaptationSet[].id | integer | 此播放分组的数字标识符。 |
streamManifest.adaptationSet[].duration | integer | 此播放分组返回的时长。 |
streamManifest.adaptationSet[].representation | array | 此分组可用的播放版本。 |
streamManifest.adaptationSet[].representation[] | object | 一个可用的播放版本。 |
streamManifest.adaptationSet[].representation[].id | integer | 该播放版本的数字标识符。 |
streamManifest.adaptationSet[].representation[].url | string | 该播放版本的播放 URL。 |
streamManifest.adaptationSet[].representation[].backupUrl | array | 该播放版本的备用播放 URL 列表。 |
streamManifest.adaptationSet[].representation[].backupUrl[] | string | 一个备用播放 URL。 |
streamManifest.adaptationSet[].representation[].maxBitrate | integer | 该播放版本返回的最大码率。 |
streamManifest.adaptationSet[].representation[].avgBitrate | integer | 该播放版本返回的平均码率。 |
streamManifest.adaptationSet[].representation[].width | integer | 播放画面宽度,单位为像素。 |
streamManifest.adaptationSet[].representation[].height | integer | 播放画面高度,单位为像素。 |
streamManifest.adaptationSet[].representation[].frameRate | number | 该播放版本的帧率。 |
streamManifest.adaptationSet[].representation[].quality | number | 该播放版本的数字清晰度级别。 |
streamManifest.adaptationSet[].representation[].qualityType | string | 该播放版本的清晰度类型标签。 |
streamManifest.adaptationSet[].representation[].qualityLabel | string | 播放版本的清晰度展示标签。 |
streamManifest.adaptationSet[].representation[].defaultSelect | boolean | 该播放版本是否被标记为默认选择。 |
画面尺寸与地点17 个字段
data.feeds[]
| 字段 | 类型 | 说明 |
|---|---|---|
photoDisplayLocationInfo | object | 作品的展示区域与画面尺寸。 |
photoDisplayLocationInfo.leftRatio | number | 展示区域的相对左侧位置。 |
photoDisplayLocationInfo.topRatio | number | 展示区域的相对顶部位置。 |
photoDisplayLocationInfo.widthRatio | number | 展示区域的相对宽度。 |
photoDisplayLocationInfo.heightRatio | number | 展示区域的相对高度。 |
photoDisplayLocationInfo.displayWidth | integer | 展示区域宽度,单位为像素。 |
photoDisplayLocationInfo.displayHeight | integer | 展示区域高度,单位为像素。 |
photoDisplayLocationInfo.photoWidth | integer | 作品画面宽度,单位为像素。 |
photoDisplayLocationInfo.photoHeight | integer | 作品画面高度,单位为像素。 |
poi | object | 作品关联的地点,可能返回。 |
poi.id | integer | 关联地点的数字标识符。 |
poi.title | string | 关联地点的显示名称。 |
poi.city | string | 关联地点所在城市的显示名称。 |
poi.address | string | 关联地点的地址文本。 |
poi.latitude | number | 关联地点的纬度。 |
poi.longitude | number | 关联地点的经度。 |
poi.category | integer | 关联地点的数字分类代码。 |
响应示例
正在加载响应示例…