分类统计
接口描述
1、查询分类下视频播放情况及消耗流量汇总数据
2、接口URL中的{userid}为点播账号userid,具体参考菜单【使用须知】->【获取密钥】
3、从播放行为产生到数据可查询的间隔时间为1~2小时,流量消耗(flowSize字段)的计算依赖于CDN日志,为了保证数据完整性,流量数据需要间隔一个自然日才会生成
4、分类统计功能需开通使用
5、接口支持https协议
接口URL
http://api.polyv.net/v2/cata/{userid}/stats-info
请求方式
GET
接口约束
1、接口同时支持HTTP 、HTTPS ,建议使用HTTPS 确保接口安全,接口调用有频率限制,详细请查看
2、请求参数中startDate(开始日期)与endDate(结束日期)需要同时传入,仅传一个参数不生效
3、同时传入dr(时间段)与startDate、endDate的情况下,仅startDate、endDate有效;都不传则dr为默认值7days
请求参数描述
ptime
true
Long
当前时间的毫秒级时间戳,3分钟内有效
sign
true
String
签名,为40位大写的SHA1值,生成签名的secretkey密钥作为通信数据安全的关键信息,严禁保存在客户端直接使用,所有API都必须通过客户自己服务器中转调用POLYV服务器获取响应数据
【详见签名生成规则】
cataid
true
String
分类id
dr
false
String
时间段,具体值为以下几个,默认值为7days today:今天 yesterday:昨天 this_week:本周 last_week:上周 7days:最近7天 this_month:本月 last_month:上个月 this_year:今年 last_year:去年
startDate
false
String
开始日期,格式为:yyyy-MM-dd,例如:2021-04-07
endDate
false
String
结束日期,格式为:yyyy-MM-dd,例如:2021-04-10
containSubCategory
false
String
是否包含子分类的数据 Y:是 N:否
示例
http://api.polyv.net/v2/cata/1b448be323/stats-info?endDate=2021-09-07&containSubCategory=Y&sign=E83FE698438024F0A1AA81D589DB5690952C9AAC&cataid=1&ptime=1631242976511&startDate=2021-09-02
响应参数描述
data字段描述
current
String
日期,格式为:yyyy-MM-dd
pcVideoView
Integer
PC端播放量
mobileVideoView
Integer
移动端播放量
pcFlowSize
Long
PC端消耗流量,单位:字节
mobileFlowSize
Long
移动端消耗流量,单位:字节
pcPlayDuration
Integer
PC端播放时长,单位:秒
mobilePlayDuration
Integer
移动端播放时长,单位:秒
pcUniqueViewer
Integer
PC端唯一观众数
mobileUniqueViewer
Integer
移动端唯一观众数
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 testGetStatsInfo() throws Exception, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String secretKey = super.secretKey;
String userId = super.userId;
String ptime = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/v2/cata/" + userId + "/stats-info";
String dr = "this_month";
String startDate = "2021-09-02";
String endDate = "2021-09-07";
String cataid = "1";
String containSubCategory = "Y";
Map<String, String> requestMap = new HashMap<>();
requestMap.put("ptime", ptime);
requestMap.put("startDate", startDate);
requestMap.put("endDate", endDate);
requestMap.put("cataid", cataid);
requestMap.put("containSubCategory", containSubCategory);
requestMap.put("sign", VodSignUtil.getSign(requestMap, secretKey));
String response = HttpUtil.get(url, requestMap);
log.debug("测试分类统计接口,{}", response);
//do somethings
}
响应示例
系统全局错误说明详见全局错误说明
成功示例
{
"code": 200,
"status": "success",
"message": "",
"data": [
{
"current": "2021-09-02",
"pcFlowSize": 0,
"pcVideoView": 1,
"pcPlayDuration": 117,
"mobileFlowSize": 56787796,
"mobileVideoView": 3,
"mobilePlayDuration": 223,
"pcUniqueViewer": 1,
"mobileUniqueViewer": 2
},
{
"current": "2021-09-03",
"pcFlowSize": 4113247,
"pcVideoView": 1,
"pcPlayDuration": 17,
"mobileFlowSize": 0,
"mobileVideoView": 0,
"mobilePlayDuration": 0,
"pcUniqueViewer": 1,
"mobileUniqueViewer": 0
},
{
"current": "2021-09-04",
"pcFlowSize": 0,
"pcVideoView": 0,
"pcPlayDuration": 0,
"mobileFlowSize": 0,
"mobileVideoView": 0,
"mobilePlayDuration": 0,
"pcUniqueViewer": 0,
"mobileUniqueViewer": 0
},
{
"current": "2021-09-05",
"pcFlowSize": 0,
"pcVideoView": 0,
"pcPlayDuration": 0,
"mobileFlowSize": 0,
"mobileVideoView": 0,
"mobilePlayDuration": 0,
"pcUniqueViewer": 0,
"mobileUniqueViewer": 0
},
{
"current": "2021-09-06",
"pcFlowSize": 0,
"pcVideoView": 0,
"pcPlayDuration": 0,
"mobileFlowSize": 0,
"mobileVideoView": 0,
"mobilePlayDuration": 0,
"pcUniqueViewer": 0,
"mobileUniqueViewer": 0
},
{
"current": "2021-09-07",
"pcFlowSize": 0,
"pcVideoView": 0,
"pcPlayDuration": 0,
"mobileFlowSize": 12627,
"mobileVideoView": 0,
"mobilePlayDuration": 0,
"pcUniqueViewer": 0,
"mobileUniqueViewer": 0
}
]
}
异常示例
{
"code": 400,
"status": "error",
"message": "invalid signature.",
"data": ""
}
Last updated
Was this helpful?