快手(中国)
快手综合搜索 API
用快手(中国)自己的综合搜索查询一个关键词,拿到与 App 中一致的结果:排好序的视频及完整互动数据,以及快手同时展示的相关搜索推荐,以 JSON 返回。每页消耗 10 积分:快手按接口计费(1、2、10 或 40 积分),四个搜索接口都是 10 积分。采用游标分页。如果只需要一种结果类型,专门的视频、用户和直播搜索接口价格相同,且返回结果已经过滤好。
POST/api/v1/kuaishou/search
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/jsonkeywordstringrequired搜索关键词,1 到 200 个字符。快手是中文平台:中文关键词能检索到完整内容,拉丁字母关键词只返回快手自己匹配到的结果,通常少得多。不支持布尔运算或字段语法。
Example: 美妆
cursorstring不透明的分页游标(cursor)。第一页不传,之后传入上一次响应中的 pcursor 值。响应字段名是 pcursor,不是 next_cursor。不要传 recoPcursor,那是快手推荐流的另一个游标。pcursor 为 "no_more" 表示没有更多页。
Example: 1
Request
from scavio import ScavioClient
client = ScavioClient(api_key="sk_live_your_key")
# 每页 10 积分,循环之前先算好预算。
cursor = None
for _ in range(5):
page = client.kuaishou.search(keyword="美妆", cursor=cursor)
for item in page["data"].get("mixFeeds", []):
if item.get("itemType") == 5: # 视频
feed = item["feed"]
print(feed["caption"], feed["view_count"], feed["share_info"])
elif item.get("itemType") == 9: # 相关搜索
print([s["keyword"] for s in item["relatedSearches"]])
cursor = page["data"].get("pcursor") # 不是 next_cursor / recoPcursor
if not cursor or cursor == "no_more":
breakResponse
"result": 1,
"pcursor": "1",
"recoPcursor": "no_more",
"isRecommendResult": false,
"llsid": "2006159769548023890"
},
"response_time": 20171,
"credits_used": 10,
"credits_remaining": 4763
}