在 K 歌场景中,你可能需要根据搜索关键字来搜索歌曲。你可以使用 SearchMusics 这个 OpenAPI 来实现这一功能。
你可以调用 SearchMusics 接口,指定搜索关键字,搜索曲库中符合筛选条件的歌曲。
关于调用接口的服务地址、通信协议、字符编码和签名机制,参看调用 OpenAPI。
使用 Post 方式发起请求。
以下是接口特有的请求参数。关于其他公共请求参数,参看请求参数。
| 参数名 | 类型 | 必填 | 示例值 | 描述 |
|---|---|---|---|---|
| Action | String | 是 | SearchMusics | 接口名称,本接口取值:SearchMusics |
| Version | String | 是 | 2020-12-01 | 接口版本,本接口取值:2020-12-01 |
| 参数名 | 类型 | 必填 | 示例值 | 描述 |
|---|---|---|---|---|
| AppId | String | 是 | Your_AppId | 应用的唯一标志 |
| PageNum | Int | 否 | 1 | 分页序号,默认值为1 |
| PageSize | Int | 否 | 10 | 每页歌曲数量,取值范围为(0,100],默认值为10 |
| Filters | Array of Int | 否 | 1 | 过滤选项:1:过滤没有歌词的歌曲2:过滤不支持打分的歌曲3:过滤不支持伴唱切换的歌曲4:过滤没有高潮片段的歌曲 |
| KeyWord | String | 否 | 告白气球 | 搜索关键字。匹配优先级为:精准歌曲名匹配 -> 精准歌手名匹配 -> 歌曲名模糊匹配 |
https://rtc.volcengineapi.com?Action=SearchMusics&Version=2020-12-01
postscript{
"AppId": "Your_AppId",
"PageSize": 10,
"PageNum": 1,
"KeyWord": "告白气球",
"Filters": [
1
]
}
json返回结果参看 BaseResponse。
其中 Result 的结构如下:
| 参数名 | 类型 | 示例值 | 描述 |
|---|---|---|---|
| Total | Int | 866 | 按照搜索条件返回的歌曲总数 |
| List | Array of List | 返回歌曲详细信息 |
返回值 Result 仅在请求成功时返回以上参数,失败时为空
{
"ResponseMetadata": {
"Action": "SearchMusics",
"Version": "2020-12-01",
"RequestId": "Your_RequestId",
"Region": "cn-north-1",
"Service": "rtc"
},
"Result": {
"Total": 866,
"List": [
{
"SongId": "Your_SongId",
"BgmType": 2,
"Duration": 186,
"LyricType": [
1
],
"PosterUrl": "http://www.com/xxx.jpg",
"VendorName": "Your_VendorName",
"Singer": "周杰伦",
"Songname": "告白气球",
"RecordType": 1,
"PitchType": 1,
"UpdateAt": 1670518801,
"Segment": "[65.088, 87.168]",
"VendorId": 1,
"LyricUrl": {
"KrcUrl": "http://www.xxx.krc",
"LrcUrl": "http://www.xxx.lrc",
"MidiUrl": "http://www.xxx.mid"
}
}
]
}
}
json