搜索视频
简介
POST /v1/generations;请求头 Authorization: Bearer <ANYCAP_API_KEY>。固定 type=social,通过 model 选择平台、input.operation 选择查询内容,其余参数见下表及示例。
| 平台 | 查询内容 | model | input.operation |
|---|---|---|---|
| TikTok | 视频搜索 | tiktok | fetch_video_search_result |
TikTok · 视频搜索
换成你的接入密钥和实际参数。新查询使用新的 Idempotency-Key,确认同一次提交时复用原键。在线体验使用登录会话和当前空间。
BASH
curl -sS -X POST 'https://api.anycap.io/v1/generations' \ -H 'Authorization: Bearer ANYCAP_API_KEY' \ -H 'Content-Type: application/json' \ -H 'Idempotency-Key: YOUR_UNIQUE_LOOKUP_ID' \ -d '{"type":"social","model":"tiktok","input":{"operation":"fetch_video_search_result","keyword":"city walk","offset":0,"count":20,"sort_type":0,"publish_time":0,"region":"US"}}'| input 字段 | 类型 | 必填 / 默认值 | 说明 |
|---|---|---|---|
keyword | string | 必填 | 搜索关键词。 |
offset | integer | 0 | 结果偏移量。 |
count | integer | 20 | 每页数量。 |
sort_type | integer | 0 | 0 相关度,1 最多点赞。 |
publish_time | integer | 0 | 0 不限,1、7、30、90、180 分别表示最近的天数。 |
region | string | US | TikTok 地区代码或 ISO 3166-1 alpha-2 国家代码。 |
读取 call.data 中的原始视频搜索结果。下一页使用 offset 控制偏移量。
HTTP 200 且 call.state 为 succeeded 时直接读取 call.data。业务数据保留原有字段、嵌套结构和 JSON 类型。如果原样返回的是字符串,call.data 也为字符串。
收到 HTTP 202 时,将 call.id 填入下方 CALL_ID 并用原接入密钥查询。started 表示处理中,unknown 表示待核对。每一页都是一次独立查询。
BASH
curl -sS 'https://api.anycap.io/v1/generations/CALL_ID' \ -H 'Authorization: Bearer ANYCAP_API_KEY'提交失败时查看 error.code 和 error.message。若执行已记录,error.details 包含 call_id、state、error_code 和 error_message。在查询已保存的调用时,从 call.state、call.error_code 和 call.error_message 读取。错误示例为数据来源拒绝查询参数。
JSON
{ "error": { "code": "social_lookup_rejected", "message": "The data source rejected the query parameters. Check the account identifier or filters.", "details": { "call_id": "00000000-0000-4000-8000-000000000001", "state": "failed", "error_code": "social_lookup_rejected", "error_message": "The data source rejected the query parameters. Check the account identifier or filters.", "charged_microcredits": "0" } }}