You need to enable JavaScript to run this app.
导航

内容搜索

最近更新时间2023.11.21 14:58:44

首次发布时间2023.11.21 14:58:44

本接口主要用于有搜索场景需求的客户,通过搜索词查询相关内容,目前支持搜索的内容体裁包括图文、横版短视频、竖版小视频。
若不指定返回条数count,则默认每次最多返回10条内容。返回的内容信息包括标题、封面图、发布时间、视频时长、作者名称与头像等,客户侧可使用这些数据,自定义实现搜索页UI。

请求方式

请求方法

GET(Content-Type: application/x-www-form-urlencoded)

请求url

https://mercury.volcengineapi.com/?Action=SearchV2&Version=2021-01-01

请求header

ServiceName:content

请求参数

参数描述类型是否必填说明
Partner渠道号String
AccessToken用户唯一标识String
Keyword搜索字符串String
Offset分页起始int默认为0,用于翻页,当HasMore为true时,Offset=当前偏移量+Count
Count每页数量int指定返回数据条数,最大不超过20,默认返回10条。
SearchId搜索IDString客户侧搜索id,代表本次搜索的唯一ID
Dt设备型号String如iphone5s、Galaxy。主要用于推荐分析,提升推荐效果
DeviceBrand设备厂商String如Apple、Samsung。主要用于推荐分析,提升推荐效果
Os操作系统String如 Android、IOS。主要用于推荐分析,提升推荐效果。注意:IOS系统如果没有正确传入此参数,返回的封面图可能为webp格式,导致图片解析失败。
OsVersion操作系统版本String如4.0.4。主要用于推荐分析,提升推荐效果。火山引擎侧内容详情页会根据此参数进行适配。
ClientVersion应用的版本号String比如1.0.1。主要用于数据排查,提升业务指标

响应参数

参数
描述
类型
说明
Result
内容列表
List<Result>
搜索内容列表

请求示例

public static void main(String[] args) {
        SearchService searchService = SearchServiceImpl.getInstance();
        searchService.setAccessKey("ak");
        searchService.setSecretKey("sk");

        searchService.SetNeedMonitor(true);
        SearchRequest request = new SearchRequest();
        request.setPartner("partner");
        request.setAccessToken("accesstoken");
        request.setKeyword("美食");
        request.setNeedVideoDetail("1");
        request.setOffset(0);
        request.setCount(10);

        try {
            SearchGroupResponseV2 response = searchService.searchGroupV2(request);
            System.out.println(JSON.toJSONString(response));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

响应示例

{
    "ResponseMetadata": {
        "RequestId": "20231116114828E802AEC4E763C142CB43",
        "Action": "SearchV2",
        "Version": "2021-01-01",
        "Service": "content",
        "Region": "cn-beijing",
        "Error": {
            "CodeN": 0,
            "Code": "",
            "Message": ""
        }
    },
    "Result": {
        "SearchId": "ee9c257aea521c430ab6db9adaada5a9",
        "HasMore": true,
        "Data": [
            {
                "Abstract": "",
                "ArticleType": "短视频",
                "ArticleUrl": "https://open.toutiao.com/a7280303591146193463/?***",
                "CommentUrl": "https://open.toutiao.com/a7280303591146193463/comment/?***",
                "CoverImages": [
                    {
                        "Url": "https://p3-open-sign.onewsimg.com/***",
                        "Height": 1080,
                        "Width": 1920
                    }
                ],
                "CoverMode": 1,
                "DiggCount": 2,
                "GroupId": "7280303591146193463",
                "HasVideo": true,
                "PublishTime": 1695077771,
                "ShareUrl": "https://open.toutiao.com/a7280303591146193463/?***",
                "Title": "《健康》节目现场花絮",
                "UserInfo": {
                    "AvatarUrl": "https://p6-open-sign.onewsimg.com/***",
                    "Description": "",
                    "Follow": false,
                    "FollowerCount": 2354,
                    "HomePage": "https://open.toutiao.com/u2307191414457355/?***",
                    "Name": "月色江声神采张扬",
                    "UserId": 2307191414457355,
                    "UserVerified": false,
                    "VerifiedContent": ""
                },
                "VideoWatchCount": 203,
                "VideoDetail": {
                    "VideoDuration": 24.637,
                    "VideoList": [
                        {
                            "Url": "http://open.toutiao.com/video/url/v1/?***",
                            "Height": 720,
                            "Width": 1280,
                            "Definition": "720p"
                        }
                    ]
                }
            }
        ]
    }
}