Polyv Help Center

Help Center

Query Video Play Count Ranking

Updated: 2025-01-14 16:15:01

API Description

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

API URL

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

Online API Call

Request Method

GET

API Constraints

  1. The API supports both HTTP and HTTPS. HTTPS is recommended for security. API calls have frequency limits. See details

  2. When both start and end are not empty, dr is invalid. When one of start or end is empty, the last 7 days of data are queried. When both start and end are empty, dr takes effect.

Request Parameters

Parameter Required Type Description
ptime true Long Current time in milliseconds, valid for 3 minutes
sign true String Signature, a 40-character uppercase SHA1 value. The secretkey used to generate the signature is critical for communication data security. It must not be stored or used directly on the client side. All API calls must be relayed through the customer's own server to the POLYV server for response data. See signature generation rules
start false String Start date, format yyyy-MM-dd, e.g., 2019-11-11
end false String End date, format yyyy-MM-dd, e.g., 2019-11-11
dr false String Time range, default is 7days
today: Today
yesterday: Yesterday
7days: Last 7 days
30days: Last 30 days

Example

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

Response Parameters

Parameter Type Description
code Integer Response status code, 200 for success, non-200 for failure See global error description
status String Response status text
message String Response description, auxiliary error reason when code is 400 or 500
data Object Video play count ranking information on success See data field description
data Parameter Description
Parameter Type Description
totalMoVideoView Integer Total mobile play count
pcVideoDailys Array PC play count ranking list array See pcVideoDailys field description
moVideoDailys Array Mobile play count ranking list array See moVideoDailys field description
totalPcVideoView Integer Total PC play count
pcVideoDailys Parameter Description
Parameter Type Description
videoId String Video ID
title String Video title
duration String Play duration, format: hh:mm:ss
pcVideoView Integer PC play count
mobileVideoView Integer Mobile play count
moVideoDailys Parameter Description
Parameter Type Description
videoId String Video ID
title String Video title
duration String Play duration, format: hh:mm:ss
pcVideoView Integer PC play count
mobileVideoView Integer Mobile play count

Java Request Example

For quick integration, please download the relevant dependency source code. Click to download source code. After downloading, add it to your own source project. The test cases include HttpUtil.java and VodSignUtil.java in the downloaded file.

It is strongly recommended to use the VOD Java SDK for API integration. The VOD Java SDK provides unified encapsulation and optimization for API call logic, exception handling, data signing, and HTTP request thread pools.

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("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

}

Response Example

See Global Error Description for system-wide error explanations.

Success Example

{
    "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
    }
}

Error Example

{
  "code": 400,
  "status": "error",
  "message": "ptime is too old.",
  "data": ""
}
联系客服,在线咨询