频道汇总统计
更新时间:2022-05-23 19:02:59
接口URL
https://api.polyv.net/live/v3/user/statistics/channels-summary
接口说明
1、接口用于查询多个频道的直播观看数据汇总统计
2、接口支持https
支持格式
JSON
请求方式
GET
请求数限制
TRUE
请求参数
| 参数名 | 必选 | 类型 | 说明 |
|---|---|---|---|
| appId | 是 | string | 从API设置中获取,在直播系统登记的appId |
| timestamp | 是 | long | 13位当前毫秒级时间戳 |
| sign | 是 | string | 签名值 |
| startDate | 是 | string | 开始时间,格式 yyyy-MM-dd |
| endDate | 是 | string | 结束时间,格式 yyyy-MM-dd |
| channelIds | 是 | string | 频道ID,多个频道使用','分隔 |
响应成功JSON示例:
{
"code": 200,
"status": "success",
"message": "",
"data": {
"list": [
{
"channelId": 1938990,
"pcPlayDuration": 3,
"pcFlowSize": 0,
"pcVideoView": 2,
"pcUniqueViewer": 1,
"mobilePlayDuration": 0,
"mobileFlowSize": 0,
"mobileVideoView": 0,
"concurrenceCount": 2,
"mobileUniqueViewer": 0
},
{
"channelId": 1947328,
"pcPlayDuration": 320,
"pcFlowSize": 0,
"pcVideoView": 183,
"pcUniqueViewer": 58,
"mobilePlayDuration": 16,
"mobileFlowSize": 0,
"mobileVideoView": 12,
"concurrenceCount": 5,
"mobileUniqueViewer": 5
}
]
}
}
响应字段说明
| 参数名 | 说明 |
|---|---|
| code | 状态码,成功为200,签名失败为403,参数错误为400,服务端错误为500 |
| status | 成功为success,错误时为error |
| message | 成功为"",错误时为错误描述信息 |
| data | 响应数据 |
| data.list.channelId | 频道ID |
| data.list.pcPlayDuration | PC端播放时长,单位:分钟 |
| data.list.pcFlowSize | PC端消耗流量,单位:bytes |
| data.list.pcVideoView | PC端总播放量,类似PV |
| data.list.pcUniqueViewer | PC端唯一观众数,类似UV |
| data.list.mobilePlayDuration | 移动端播放时长,单位:分钟 |
| data.list.mobileFlowSize | 移动端消耗流量,单位:bytes |
| data.list.mobileVideoView | 移动端总播放量,类似PV |
| data.list.mobileUniqueViewer | 移动端唯一观众数,类似UV |
| data.list.concurrenceCount | 最高并发人数 |
响应失败JSON示例:
参数错误
{
"code": 400,
"status": "error",
"message": "param validate error",
"data": ""
}
未输入appId
{
"code": 400,
"status": "error",
"message": "appId is required.",
"data": ""
}
appId不正确
{
"code": 400,
"status": "error",
"message": "application not found.",
"data": ""
}
时间戳错误
{
"code": 400,
"status": "error",
"message": "invalid timestamp.",
"data": ""
}
签名错误
{
"code": 403,
"status": "error",
"message": "invalid signature.",
"data": ""
}
非法频道号
{
"code": 403,
"status": "error",
"message": "illegal channel id: %s",
"data": ""
}
java请求示例
public void testAddRecordTask() {
String url = "https://api.polyv.net/live/v3/user/statistics/channels-summary";
// appId和加密串
String appId = "xxxxxxx";
String appSecret = "xxxxxxxxxxxxxxxxxx";
Map params = new HashMap<>();
params.put("channelIds", "2232850");
params.put("startDate", "2020-12-01");
params.put("endDate", "2021-01-11");
// 调用Polyv的工具类方法设置sign
PolyvTool.setLiveSign(params, appId, appSecret);
String content = HttpClientUtil.getInstance()
.sendHttpPost(url, params);
System.out.println(content);
}
