查询频道某段时间的直播观看详情数据

接口描述

1、通过频道号获取该频道某段时间的直播观看的统计数据
2、接口URL中的{channelId}为频道号
3、接口支持https协议

接口URL

http://api.polyv.net/live/v2/statistics/{channelId}/summary

在线API调用

请求方式

GET

接口约束

1、接口同时支持HTTP 、HTTPS ,建议使用HTTPS 确保接口安全,接口调用有频率限制,详细请查看

请求参数描述

参数名必选类型说明

appId

true

String

账号appId【详见获取密钥

timestamp

true

Long

当前13位毫秒级时间戳,3分钟内有效

sign

true

String

签名,为32位大写的MD5值,生成签名的appSecret密钥作为通信数据安全的关键信息,严禁保存在客户端直接使用,所有API都必须通过客户自己服务器中转调用POLYV服务器获取响应数据【详见签名生成规则

startDay

true

String

开始日期,格式:yyyy-MM-dd

endDay

true

String

结束日期,格式:yyyy-MM-dd

示例

http://api.polyv.net/live/v2/statistics/1965681/summary?startDay=2020-1-1&appId=frlr1zazn3&endDay=2020-5-11&sign=311D8B0532DC5BC3F75CE25F4A9EF36A&timestamp=1621842602591

响应参数描述

字段类型说明

status

String

状态值

result

Array

相应的结果 【详见Result参数描述

Result参数描述

参数名类型说明

currentDay

String

查询日期,格式:yyyy-MM-dd

channelId

String

频道号

userId

String

直播账号ID

pcPlayDuration

Integer

PC端播放时长,单位:分钟

pcFlowSize

Long

PC端消耗流量,单位:bytes

pcVideoView

Integer

PC端总播放量,类似PV

mobilePlayDuration

Integer

移动端播放时长,单位:分钟

mobileFlowSize

Long

移动端消耗流量,单位:bytes

mobileVideoView

Integer

移动端总播放量,类似PV

mobileUniqueViewer

Integer

移动端唯一观众数,类似UV

createdTime

Long

记录添加的时间,13位毫秒级时间戳

lastModified

Long

记录修改的时间,13位毫秒级时间戳

creatorId

String

创建账号的子账号用户ID(为空则为主账号创建)

creatorName

String

创建频道的子账号名称(主账号创建的则显示"主账号")

Java请求示例

快速接入基础代码请下载相关依赖源码, 点击下载源代码 ,下载后加入到自己的源码工程中即可。测试用例中的HttpUtil.java 和 LiveSignUtil.java 都包含在下载文件中。

强烈建议您使用直播Java SDK完成API的功能对接,直播Java SDK 对API调用逻辑、异常处理、数据签名、HTTP请求线程池进行了统一封装和优化。

private static final Logger log = LoggerFactory.getLogger(ChannelViewDataTest.class);
/**
 * 查询频道某段时间的直播观看详情数据
 * @throws IOException
 */
@Test
public void testSummary() throws IOException, NoSuchAlgorithmException {
    //公共参数,填写自己的实际参数
    String appId = super.appId;
    String appSecret = super.appSecret;
    String userId = super.userId;
    String timestamp = String.valueOf(System.currentTimeMillis());
    //业务参数
    String url = String.format("http://api.polyv.net/live/v2/statistics/%s/summary","1965681");
    String startDay = "2020-1-1";
    String endDay = "2020-5-11";

    //http 调用逻辑
    Map<String,String> requestMap = new HashMap<>();
    requestMap.put("appId", appId);
    requestMap.put("timestamp",timestamp);
    requestMap.put("startDay",startDay);
    requestMap.put("endDay",endDay);
    requestMap.put("sign",LiveSignUtil.getSign(requestMap, appSecret));
    String response = HttpUtil.get(url, requestMap);
    log.info("测试查询频道某段时间的直播观看详情数据,返回值:{}",response);
    //do somethings

}

响应示例

系统全局错误说明详见全局错误说明

成功示例

{
    "status":"success",
    "result":[
        {
            "currentDay":"2020-10-20",
            "channelId":1965681,
            "userId":"1b448be323",
            "pcPlayDuration":7,
            "pcFlowSize":0,
            "pcVideoView":7,
            "pcUniqueViewer":1,
            "mobilePlayDuration":0,
            "mobileFlowSize":0,
            "mobileVideoView":0,
            "mobileUniqueViewer":0,
            "createdTime":1603218100000,
            "lastModified":1603218100000,
            "creatorId":"1b448be323",
            "creatorName":"主账号"
        },
        {
            "currentDay":"2020-10-26",
            "channelId":1965681,
            "userId":"1b448be323",
            "pcPlayDuration":17,
            "pcFlowSize":0,
            "pcVideoView":12,
            "pcUniqueViewer":1,
            "mobilePlayDuration":2,
            "mobileFlowSize":0,
            "mobileVideoView":1,
            "mobileUniqueViewer":1,
            "createdTime":1603736505000,
            "lastModified":1603736505000,
            "creatorId":"1b448be323",
            "creatorName":"主账号"
        },
        {
            "currentDay":"2020-11-12",
            "channelId":1965681,
            "userId":"1b448be323",
            "pcPlayDuration":1,
            "pcFlowSize":0,
            "pcVideoView":1,
            "pcUniqueViewer":1,
            "mobilePlayDuration":0,
            "mobileFlowSize":0,
            "mobileVideoView":0,
            "mobileUniqueViewer":0,
            "createdTime":1605205271000,
            "lastModified":1605205271000,
            "creatorId":"1b448be323",
            "creatorName":"主账号"
        },
        {
            "currentDay":"2020-12-03",
            "channelId":1965681,
            "userId":"1b448be323",
            "pcPlayDuration":1,
            "pcFlowSize":0,
            "pcVideoView":1,
            "pcUniqueViewer":1,
            "mobilePlayDuration":0,
            "mobileFlowSize":0,
            "mobileVideoView":0,
            "mobileUniqueViewer":0,
            "createdTime":1607019680000,
            "lastModified":1607019680000,
            "creatorId":"1b448be323",
            "creatorName":"主账号"
        }
    ]
}

异常示例

{
    "code":"invalid.request",
    "msg":"signature error."
}

Last updated