查询视频播放量排行

接口描述

1、查询视频在不同终端的播放量排行,从播放行为产生到数据可查询的间隔时间为1~2小时
2、接口URL中的{userid}为点播账号userid,具体参考菜单【使用须知】->【获取密钥】
3、接口支持https协议

接口URL

http://api.polyv.net/v2/videoview/{userid}/ranklist

在线API调用

请求方式

GET

接口约束

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

2、当start和end都不为空时,dr失效;当start和end其中一个为空,查询最近7天数据;当start和end都为空,以dr为准

请求参数描述

参数名必选类型说明

userid

true

String

保利威点播账户id,可以参考【获取密匙】获取,获取路径:官网->登录->点播(API接口)

ptime

true

Long

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

sign

true

String

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

start

false

String

开始日期,格式为yyyy-MM-dd,例如:2019-11-11

end

false

String

结束日期,格式为yyyy-MM-dd,例如:2019-11-11

dr

false

String

时间段,默认值为7days today:今天 yesterday:昨天 7days:最近7天 30days:最近30天

示例

http://api.polyv.net/v2/videoview/1b448be323/ranklist?start=2021-03-01&sign=F378D4041015727EA34C3CC58F9DC83334FA7266&end=2021-04-08&userId=1b448be323&ptime=1617875095741

响应参数描述

参数名类型说明

code

Integer

响应状态码,200为成功返回,非200为失败【详见全局错误说明

status

String

响应状态文本信息

message

String

响应描述信息,当code为400或者500的时候,辅助描述错误原因

data

Object

响应成功时返回视频播放量排行信息【详见data字段说明

data参数描述

参数名类型说明

totalMoVideoView

Integer

移动端总播放量

pcVideoDailys

Array

pc端播放量排行列表数组【详见pcVideoDailys字段说明

moVideoDailys

Array

移动端播放量排行列表数组【详见moVideoDailys字段说明

totalPcVideoView

Integer

pc端总播放量

pcVideoDailys参数描述

参数名类型说明

videoId

String

视频id

title

String

视频标题

duration

String

播放时长,格式为:时:分:秒

pcVideoView

Integer

pc端播放量

mobileVideoView

Integer

移动端播放量

moVideoDailys参数描述

参数名类型说明

videoId

String

视频id

title

String

视频标题

duration

String

播放时长,格式为:时:分:秒

pcVideoView

Integer

pc端播放量

mobileVideoView

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 testGetPlaytimesRank() throws Exception, NoSuchAlgorithmException {
    //公共参数,填写自己的实际参数
    String secretKey = super.secretKey;
    String userId = super.userId;
    String ptime = String.valueOf(System.currentTimeMillis());
    //业务参数
    String url = "http://api.polyv.net/v2/videoview/"+userId+"/ranklist";
    String start = "2021-03-01";
    String end = "2021-04-08";

    Map<String, String> requestMap = new HashMap<>();
    requestMap.put("userId", userId);
    requestMap.put("ptime", ptime);
    requestMap.put("start", start);
    requestMap.put("end", end);
    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":{
        "totalMoVideoView":0,
        "pcVideoDailys":[
            {
                "videoId":"1b448be32370f4822ac40fd926112a66_1",
                "title":"视频标题",
                "duration":"00:00:45",
                "pcVideoView":2,
                "mobileVideoView":0
            },
            {
                "videoId":"1b448be3233659acf35d430ba9210bd4_1",
                "title":"junit-远程批量上传视频",
                "duration":"00:01:25",
                "pcVideoView":2,
                "mobileVideoView":0
            },
            {
                "videoId":"1b448be323d66f3dae8db5af9f1fdce6_1",
                "title":"a",
                "duration":"00:00:44",
                "pcVideoView":2,
                "mobileVideoView":0
            },
            {
                "videoId":"1b448be323b452641878b54f21241188_1",
                "title":"合并美食视频",
                "duration":"00:01:06",
                "pcVideoView":2,
                "mobileVideoView":0
            },
            {
                "videoId":"1b448be323a8649edcfea26c0f870def_1",
                "title":"pro_compress-w431sfrmnq.mp4",
                "duration":"00:01:37",
                "pcVideoView":2,
                "mobileVideoView":0
            },
            {
                "videoId":"1b448be323a6a1a6c0c237856f555e88_1",
                "title":"hello,word",
                "duration":"00:00:24",
                "pcVideoView":1,
                "mobileVideoView":0
            },
            {
                "videoId":"1b448be323a146649ad0cc89d0faed9c_1",
                "title":"junit合并并修改_1",
                "duration":"00:03:11",
                "pcVideoView":1,
                "mobileVideoView":0
            },
            {
                "videoId":"1b448be3239482977934f099f2ceaa0a_1",
                "title":"测试异步上传视频1",
                "duration":"00:00:17",
                "pcVideoView":1,
                "mobileVideoView":0
            }
        ],
        "moVideoDailys":[
            {
                "videoId":"1b448be32370f4822ac40fd926112a66_1",
                "title":"视频标题",
                "duration":"00:00:45",
                "pcVideoView":2,
                "mobileVideoView":0
            },
            {
                "videoId":"1b448be3233659acf35d430ba9210bd4_1",
                "title":"junit-远程批量上传视频",
                "duration":"00:01:25",
                "pcVideoView":2,
                "mobileVideoView":0
            },
            {
                "videoId":"1b448be323d66f3dae8db5af9f1fdce6_1",
                "title":"a",
                "duration":"00:00:44",
                "pcVideoView":2,
                "mobileVideoView":0
            },
            {
                "videoId":"1b448be323b452641878b54f21241188_1",
                "title":"合并美食视频",
                "duration":"00:01:06",
                "pcVideoView":2,
                "mobileVideoView":0
            },
            {
                "videoId":"1b448be323a8649edcfea26c0f870def_1",
                "title":"pro_compress-w431sfrmnq.mp4",
                "duration":"00:01:37",
                "pcVideoView":2,
                "mobileVideoView":0
            },
            {
                "videoId":"1b448be323a6a1a6c0c237856f555e88_1",
                "title":"hello,word",
                "duration":"00:00:24",
                "pcVideoView":1,
                "mobileVideoView":0
            },
            {
                "videoId":"1b448be323a146649ad0cc89d0faed9c_1",
                "title":"junit合并并修改_1",
                "duration":"00:03:11",
                "pcVideoView":1,
                "mobileVideoView":0
            },
            {
                "videoId":"1b448be3239482977934f099f2ceaa0a_1",
                "title":"测试异步上传视频1",
                "duration":"00:00:17",
                "pcVideoView":1,
                "mobileVideoView":0
            }
        ],
        "totalPcVideoView":13
    }
}

异常示例

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

Last updated