Skip to content

快手视频搜索 API (V2) ​

GET
接口健康状态
健康 可用 少量可用 基本不可用 暂无数据
正在加载健康状态…

通过关键词搜索快手公开视频,支持页码分页。用于发现相关视频并按页浏览结果。

请求参数 ​

参数名位置类型必填默认值说明
tokenquerystring是-此 API 服务的访问令牌。
keywordquerystring是-用于查找视频的搜索关键词。
pagequeryinteger否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_idinteger快手作品 ID,以 JSON 整数返回。请使用无损 JSON 解析保留完整 ID。
captionstring作品展示的描述文本。
timestring发布时间展示文本。
timestampinteger作品发布时间,以 Unix 毫秒级时间戳返回。
typeinteger搜索结果的数字内容类型。
photo_statusinteger快手作品的数字状态码。
longVideoboolean作品是否被标记为长视频,此字段可能返回。
editInfoobject作品的编辑信息,可能返回。
editInfo.editVersioninteger作品的编辑版本。
editInfo.editTimeinteger作品编辑时间,以 Unix 毫秒级时间戳返回。
editInfo.coverVersioninteger作品封面的编辑版本。
disclaimerMessagestring作品附带的提示文本,可能返回。
hasVoteboolean作品是否被标记为含有投票。
hasMusicTagboolean作品是否带有音乐标签。
tagsarray作品的标签列表。
分页与结果2 个字段

data

所请求关键词的快手公开作品分页结果。

字段类型说明
resultinteger平台返回的结果码。已核验的成功搜索响应中返回 1。
feedsarray请求页返回的作品列表。同一作品可能出现在多页,可用 photo_id 匹配跨页作品。
作者8 个字段

data.feeds[]

字段类型说明
user_idinteger快手作者的数字 ID。
user_namestring发布者的展示名称。
kwaiIdstring作者展示的快手号,可能返回。
verifiedboolean作者是否标记为已认证。
headurlstring作者头像图片 URL。
headurlsarray作者头像的可用图片链接。
headurls[]object该媒体的一条备选链接。
headurls[].urlstring该媒体版本的 URL。
互动数据5 个字段

data.feeds[]

字段类型说明
like_countinteger作品的点赞数。
comment_countinteger作品的评论数。
view_countinteger作品的观看次数。
forward_countinteger作品的转发次数。
share_countinteger作品的分享次数。
媒体链接与相册24 个字段

data.feeds[]

字段类型说明
durationinteger视频返回的时长。图片作品可能没有此字段。
main_urlstring作品的主图 URL。
thumbnail_urlstring作品缩略图 URL。
main_mv_urlstring作品返回的主要视频 URL。
main_mv_urlsarray主要视频的可用 URL 列表。
main_mv_urls[]object该媒体的一条备选链接。
main_mv_urls[].urlstring该媒体版本的 URL。
thumbnail_urlsarray作品缩略图的可用 URL 列表。
thumbnail_urls[]object该媒体的一条备选链接。
thumbnail_urls[].urlstring该媒体版本的 URL。
cover_thumbnail_urlsarray作品封面缩略图的可用 URL 列表。
cover_thumbnail_urls[]object该媒体的一条备选链接。
cover_thumbnail_urls[].urlstring该媒体版本的 URL。
ext_paramsobject作品的尺寸和可选相册信息。
ext_params.mtypeinteger作品的数字媒体类型。
ext_params.winteger媒体宽度,单位为像素。
ext_params.hinteger媒体高度,单位为像素。
ext_params.atlasobject多图作品的相册信息。
ext_params.atlas.listarray按展示顺序返回的相册图片引用,已核验的条目为路径字符串。
ext_params.atlas.list[]string一张相册图片的引用路径。
ext_params.atlas.sizearray相册图片尺寸列表,已核验的响应中与 list 按位置对应。
ext_params.atlas.size[]object相册中一张图片的尺寸。
ext_params.atlas.size[].winteger图片宽度,单位为像素。
ext_params.atlas.size[].hinteger图片高度,单位为像素。
播放清单22 个字段

data.feeds[]

字段类型说明
streamManifestobject视频媒体的播放清单。
streamManifest.versionstring播放清单版本。
streamManifest.videoIdstring播放清单中使用的视频标识符。
streamManifest.adaptationSetarray播放清单中的播放版本分组。
streamManifest.adaptationSet[]object一组播放版本。
streamManifest.adaptationSet[].idinteger此播放分组的数字标识符。
streamManifest.adaptationSet[].durationinteger此播放分组返回的时长。
streamManifest.adaptationSet[].representationarray此分组可用的播放版本。
streamManifest.adaptationSet[].representation[]object一个可用的播放版本。
streamManifest.adaptationSet[].representation[].idinteger该播放版本的数字标识符。
streamManifest.adaptationSet[].representation[].urlstring该播放版本的播放 URL。
streamManifest.adaptationSet[].representation[].backupUrlarray该播放版本的备用播放 URL 列表。
streamManifest.adaptationSet[].representation[].backupUrl[]string一个备用播放 URL。
streamManifest.adaptationSet[].representation[].maxBitrateinteger该播放版本返回的最大码率。
streamManifest.adaptationSet[].representation[].avgBitrateinteger该播放版本返回的平均码率。
streamManifest.adaptationSet[].representation[].widthinteger播放画面宽度,单位为像素。
streamManifest.adaptationSet[].representation[].heightinteger播放画面高度,单位为像素。
streamManifest.adaptationSet[].representation[].frameRatenumber该播放版本的帧率。
streamManifest.adaptationSet[].representation[].qualitynumber该播放版本的数字清晰度级别。
streamManifest.adaptationSet[].representation[].qualityTypestring该播放版本的清晰度类型标签。
streamManifest.adaptationSet[].representation[].qualityLabelstring播放版本的清晰度展示标签。
streamManifest.adaptationSet[].representation[].defaultSelectboolean该播放版本是否被标记为默认选择。
画面尺寸与地点17 个字段

data.feeds[]

字段类型说明
photoDisplayLocationInfoobject作品的展示区域与画面尺寸。
photoDisplayLocationInfo.leftRationumber展示区域的相对左侧位置。
photoDisplayLocationInfo.topRationumber展示区域的相对顶部位置。
photoDisplayLocationInfo.widthRationumber展示区域的相对宽度。
photoDisplayLocationInfo.heightRationumber展示区域的相对高度。
photoDisplayLocationInfo.displayWidthinteger展示区域宽度,单位为像素。
photoDisplayLocationInfo.displayHeightinteger展示区域高度,单位为像素。
photoDisplayLocationInfo.photoWidthinteger作品画面宽度,单位为像素。
photoDisplayLocationInfo.photoHeightinteger作品画面高度,单位为像素。
poiobject作品关联的地点,可能返回。
poi.idinteger关联地点的数字标识符。
poi.titlestring关联地点的显示名称。
poi.citystring关联地点所在城市的显示名称。
poi.addressstring关联地点的地址文本。
poi.latitudenumber关联地点的纬度。
poi.longitudenumber关联地点的经度。
poi.categoryinteger关联地点的数字分类代码。

响应示例 ​

正在加载响应示例…