批量查询视频观看日志

接口描述

1、通过自然月批量获取视频观看日志
2、从播放行为产生到数据可查询的间隔时间为1~2小时
3、响应参数消耗流量(flowSize字段)的计算依赖于CDN日志,为了保证数据完整性,流量数据需要间隔一个自然日才会生成
4、接口URL中的{userid}为点播账号userid,具体参考【获取密钥】
5、接口URL中的{month}为查询月份,格式:yyyyMM
6、接口支持https协议

接口URL

http://api.polyv.net/v2/viewlog/{userid}/monthly/{month}

在线API调用

请求方式

GET

接口约束

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

请求参数描述

示例

http://api.polyv.net/v2/viewlog/1b448be323/monthly/202104?currentDay=2021-04-07&month=202104&sign=504AD715A14CE68DA568B2935953A1796994B3D1&numPerPage=2&userid=1b448be323&ptime=1617852294166&pageNum=1

响应参数描述

data字段说明

返回错误代码列表

Java请求示例

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

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

private static final Logger log = LoggerFactory.getLogger(VodStatisticsTest.class);

/**
 * 批量查询视频观看日志
 * @throws Exception
 * @throws NoSuchAlgorithmException
 */
@Test
public void testGetViewlog() throws Exception, NoSuchAlgorithmException {
    //公共参数,填写自己的实际参数
    String secretKey = super.secretKey;
    String userId = super.userId;
    String ptime = String.valueOf(System.currentTimeMillis());
    //业务参数
    String month = "202104";
    String url = String.format("http://api.polyv.net/v2/viewlog/%s/monthly/%s", userId, month);
    String currentDay = "2021-04-07";
    String numPerPage = String.valueOf(2);
    String pageNum = String.valueOf(1);

    Map<String, String> requestMap = new HashMap<>();
    requestMap.put("userid", userId);
    requestMap.put("ptime", ptime);
    requestMap.put("currentDay", currentDay);
    requestMap.put("month", month);
    requestMap.put("numPerPage", numPerPage);
    requestMap.put("pageNum", pageNum);
    requestMap.put("sign", VodSignUtil.getSign(requestMap, secretKey));

    String response = HttpUtil.get(url, requestMap);
    log.debug("测试批量查询视频观看日志,{}", response);
    //do somethings
}

响应示例

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

成功示例

{
	"code": 200,
	"status": "success",
	"message": "success",
	"data": [{
		"playId": "1617791143803X1210954",
		"userId": "1b448be323",
		"videoId": "1b448be323a146649ad0cc89d0faed9c_1",
		"playDuration": 21,
		"stayDuration": 30,
		"currentTimes": 22,
		"duration": 191,
		"flowSize": 0,
		"sessionId": "",
		"param1": "",
		"param2": "",
		"param3": "",
		"param4": "",
		"param5": "",
		"ipAddress": "xxxxxxx",
		"country": "中国",
		"province": "湖南",
		"city": "长沙",
		"isp": "湖南电信",
		"referer": "https://share.plvideo.cn/front/video/preview?vid=1b448be323a146649ad0cc89d0faed9c_1",
		"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36",
		"operatingSystem": "Windows",
		"browser": "Chrome",
		"isMobile": "N",
		"currentDay": "2021-04-07",
		"currentHour": 18,
		"createdTime": 1617791314000,
		"lastModified": 1617802680000,
		"viewerId": "",
		"viewerName": "",
		"viewSource": "vod_pc_html5"
	}, {
		"playId": "1617791015552X1409047",
		"userId": "1b448be323",
		"videoId": "1b448be323a146649ad0cc89d0faed9c_1",
		"playDuration": 33,
		"stayDuration": 40,
		"currentTimes": 35,
		"duration": 191,
		"flowSize": 0,
		"sessionId": "",
		"param1": "",
		"param2": "",
		"param3": "",
		"param4": "",
		"param5": "",
		"ipAddress": "xxxxxxx",
		"country": "中国",
		"province": "湖南",
		"city": "长沙",
		"isp": "湖南电信",
		"referer": "https://share.plvideo.cn/front/video/preview?vid=1b448be323a146649ad0cc89d0faed9c_1",
		"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36",
		"operatingSystem": "Windows",
		"browser": "Chrome",
		"isMobile": "N",
		"currentDay": "2021-04-07",
		"currentHour": 18,
		"createdTime": 1617791294000,
		"lastModified": 1617802668000,
		"viewerId": "",
		"viewerName": "",
		"viewSource": "vod_pc_html5"
	}],
	"total": 8
}

异常示例

 {
	"code": 400,
	"status": "error",
	"message": "ptime is too old.",
	"data": ""
}

Last updated