快手(中国)
快手视频批量查询 API
一次请求最多查询 20 条快手(中国)视频:每条的文案、播放 / 点赞 / 评论 / 分享 / 收藏数、时长、发布时间、封面和 MP4 地址,以 JSON 返回。无论列表多长,每次调用固定消耗 40 积分:这是该平台最贵的调用,只有 id 数量接近 20 时,才比 2 积分的单条视频接口划算。列表上限为 20 条,超出会在计费前被拒绝。
POST/api/v1/kuaishou/videos/batch
Authorizations
AuthorizationstringheaderrequiredBearer authentication header of the form Bearer <token>, where <token> is your Scavio API key (e.g. Bearer sk_live_your_key).
Body
application/jsonphoto_idsarray<string>required快手 photo(视频)id,1 到 20 个,每个都不能为空。超过 20 个会返回 400,而不是截断。这里请使用数字形式的 id(5228960823332207296),批量接口按这种形式检索。如果 id 来自信息流,请从该信息流的 share_info 中取,或使用之前批量响应中的 originalPhotoId,因为信息流自带的 photo_id 字段返回时已被舍入。
Example: ["5228960823332207296", "5196309727975443273"]
Request
from scavio import ScavioClient
client = ScavioClient(api_key="sk_live_your_key")
# 固定 40 积分,1 个 id 和 20 个 id 一样。少于约 20 个 id 时,
# 2 积分的视频详情接口更便宜,所以请凑满一批再发送。
ids = ["5228960823332207296", "5196309727975443273"]
assert len(ids) <= 20, "the API rejects more than 20"
batch = client.kuaishou.videos_batch(photo_ids=ids)
for photo in batch["data"].get("photos", []):
print(photo["originalPhotoId"], photo["view_count"], photo["caption"])
# 返回条数少于发送的 id 数 = 有些 id 已失效。这次调用仍然消耗 40 积分。
print(len(batch["data"].get("photos", [])), "of", len(ids))Response
"result": 1,
"host-name": "public-bjy-c91-kce-node-arm1.idchb1az2.hb1.kwaidc.com"
},
"response_time": 1762,
"credits_used": 40,
"credits_remaining": 4773
}