查询视频播放的时段分布

接口描述

1、通过时间范围查询用户视频播放时段统计数据,播放后生成数据需间隔一到两小时,其中流量数据间隔一个自然日生成
2、接口URL中的{userid}为点播账号userid,具体参考菜单【使用须知】->【获取密钥】
3、接口支持https协议

接口URL

http://api.polyv.net/v2/hourly/{userid}

在线API调用

请求方式

GET

接口约束

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

2、请求参数中start(开始日期)与end(结束日期)需要同时传入,仅传一个参数不生效

3、同时传入dr(时间段)与start、end的情况下,仅start、end有效;都不传则dr为默认值7days

请求参数描述

参数名必选类型说明

userid

true

String

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

ptime

true

Long

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

sign

true

String

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

dr

false

String

时间段,默认值为7days,最近7天 today:今天 yesterday:昨天 this_week:本周 last_week:上周 7days:最近7天 this_month:本月 last_month:上个月 this_year:今年 last_year:去年

start

false

String

开始日期,格式为yyyy-MM-dd,例如:2021-03-31

end

false

String

结束日期,格式为yyyy-MM-dd,例如:2021-04-02

示例

http://api.polyv.net/v2/hourly/1b448be323?sign=571A6C9924A207BF92635FE5661144844519E0F2&userId=1b448be323&ptime=1617785134079&dr=last_month

响应参数描述

参数名类型说明

code

Integer

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

status

String

响应状态文本信息

message

String

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

data

Array

响应成功返回视频播放时段统计数据,响应失败返回空【详见data字段说明

data参数描述

字段类型说明

currentHour

Integer

播放时段,单位小时

formatPcPlayDuration

String

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

pcPlayDuration

Integer

pc播放时长,单位为秒

pcFlowSize

Long

pc消耗流量,单位为字节

pcVideoView

Integer

pc端播放量

pcUniqueViewer

Integer

pc端唯一观众量

formatMobilePlayDuration

String

移动端播放时长,格式为:时:分:秒

mobilePlayDuration

Integer

移动端播放时长,单位为秒

mobileFlowSize

Long

移动端消耗流量,单位为字节

mobileVideoView

Integer

移动端播放量

mobileUniqueViewer

Integer

移动端唯一观众量

返回错误代码列表

错误代码message说明

400

sign can not be empty.

加密串为空

400

ptime is too old.

时间戳过期

400

ptime is illegal.

时间戳参数格式不对或者超过当前时间3分钟

400

Could not find user by userid.

userid不存在

400

the sign is not right.

加密串不正确

401

start and end illegal.

start日期大于end日期

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 testGetPlayTimesByPeriod() throws Exception, NoSuchAlgorithmException {
    //公共参数,填写自己的实际参数
    String secretKey = super.secretKey;
    String userId = super.userId;
    String ptime = String.valueOf(System.currentTimeMillis());
    //业务参数
    String url = String.format("http://api.polyv.net/v2/hourly/%s", userId);
    String dr = "last_month";
    String start = "2021-03-31";
    String end = "2021-04-02";

    Map<String, String> requestMap = new HashMap<>();
    requestMap.put("userId", userId);
    requestMap.put("ptime", ptime);
    requestMap.put("dr", dr);
    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": [
    {
      "currentHour": 0,
      "formatPcPlayDuration": "00:00:00",
      "pcPlayDuration": 0,
      "pcFlowSize": 0,
      "pcVideoView": 0,
      "pcUniqueViewer": 0,
      "formatMobilePlayDuration": "00:00:00",
      "mobilePlayDuration": 0,
      "mobileFlowSize": 0,
      "mobileVideoView": 0,
      "mobileUniqueViewer": 0
    },
    {
      "currentHour": 1,
      "formatPcPlayDuration": "00:00:00",
      "pcPlayDuration": 0,
      "pcFlowSize": 0,
      "pcVideoView": 0,
      "pcUniqueViewer": 0,
      "formatMobilePlayDuration": "00:00:00",
      "mobilePlayDuration": 0,
      "mobileFlowSize": 0,
      "mobileVideoView": 0,
      "mobileUniqueViewer": 0
    },
    {
      "currentHour": 2,
      "formatPcPlayDuration": "00:00:00",
      "pcPlayDuration": 0,
      "pcFlowSize": 0,
      "pcVideoView": 0,
      "pcUniqueViewer": 0,
      "formatMobilePlayDuration": "00:00:00",
      "mobilePlayDuration": 0,
      "mobileFlowSize": 0,
      "mobileVideoView": 0,
      "mobileUniqueViewer": 0
    },
    {
      "currentHour": 3,
      "formatPcPlayDuration": "00:00:00",
      "pcPlayDuration": 0,
      "pcFlowSize": 0,
      "pcVideoView": 0,
      "pcUniqueViewer": 0,
      "formatMobilePlayDuration": "00:00:00",
      "mobilePlayDuration": 0,
      "mobileFlowSize": 0,
      "mobileVideoView": 0,
      "mobileUniqueViewer": 0
    },
    {
      "currentHour": 4,
      "formatPcPlayDuration": "00:00:00",
      "pcPlayDuration": 0,
      "pcFlowSize": 0,
      "pcVideoView": 0,
      "pcUniqueViewer": 0,
      "formatMobilePlayDuration": "00:00:00",
      "mobilePlayDuration": 0,
      "mobileFlowSize": 0,
      "mobileVideoView": 0,
      "mobileUniqueViewer": 0
    },
    {
      "currentHour": 5,
      "formatPcPlayDuration": "00:00:00",
      "pcPlayDuration": 0,
      "pcFlowSize": 0,
      "pcVideoView": 0,
      "pcUniqueViewer": 0,
      "formatMobilePlayDuration": "00:00:00",
      "mobilePlayDuration": 0,
      "mobileFlowSize": 0,
      "mobileVideoView": 0,
      "mobileUniqueViewer": 0
    },
    {
      "currentHour": 6,
      "formatPcPlayDuration": "00:00:00",
      "pcPlayDuration": 0,
      "pcFlowSize": 0,
      "pcVideoView": 0,
      "pcUniqueViewer": 0,
      "formatMobilePlayDuration": "00:00:00",
      "mobilePlayDuration": 0,
      "mobileFlowSize": 0,
      "mobileVideoView": 0,
      "mobileUniqueViewer": 0
    },
    {
      "currentHour": 7,
      "formatPcPlayDuration": "00:00:00",
      "pcPlayDuration": 0,
      "pcFlowSize": 0,
      "pcVideoView": 0,
      "pcUniqueViewer": 0,
      "formatMobilePlayDuration": "00:00:00",
      "mobilePlayDuration": 0,
      "mobileFlowSize": 0,
      "mobileVideoView": 0,
      "mobileUniqueViewer": 0
    },
    {
      "currentHour": 8,
      "formatPcPlayDuration": "00:00:00",
      "pcPlayDuration": 0,
      "pcFlowSize": 0,
      "pcVideoView": 0,
      "pcUniqueViewer": 0,
      "formatMobilePlayDuration": "00:00:00",
      "mobilePlayDuration": 0,
      "mobileFlowSize": 0,
      "mobileVideoView": 0,
      "mobileUniqueViewer": 0
    },
    {
      "currentHour": 9,
      "formatPcPlayDuration": "00:00:21",
      "pcPlayDuration": 21,
      "pcFlowSize": 3627536,
      "pcVideoView": 2,
      "pcUniqueViewer": 2,
      "formatMobilePlayDuration": "00:00:00",
      "mobilePlayDuration": 0,
      "mobileFlowSize": 0,
      "mobileVideoView": 0,
      "mobileUniqueViewer": 0
    },
    {
      "currentHour": 10,
      "formatPcPlayDuration": "00:01:32",
      "pcPlayDuration": 92,
      "pcFlowSize": 43331003,
      "pcVideoView": 6,
      "pcUniqueViewer": 2,
      "formatMobilePlayDuration": "00:02:35",
      "mobilePlayDuration": 155,
      "mobileFlowSize": 33535828,
      "mobileVideoView": 3,
      "mobileUniqueViewer": 1
    },
    {
      "currentHour": 11,
      "formatPcPlayDuration": "00:03:10",
      "pcPlayDuration": 190,
      "pcFlowSize": 76230820,
      "pcVideoView": 13,
      "pcUniqueViewer": 5,
      "formatMobilePlayDuration": "00:00:40",
      "mobilePlayDuration": 40,
      "mobileFlowSize": 4046327,
      "mobileVideoView": 1,
      "mobileUniqueViewer": 1
    },
    {
      "currentHour": 12,
      "formatPcPlayDuration": "00:00:30",
      "pcPlayDuration": 30,
      "pcFlowSize": 18708078,
      "pcVideoView": 3,
      "pcUniqueViewer": 1,
      "formatMobilePlayDuration": "00:00:00",
      "mobilePlayDuration": 0,
      "mobileFlowSize": 0,
      "mobileVideoView": 0,
      "mobileUniqueViewer": 0
    },
    {
      "currentHour": 13,
      "formatPcPlayDuration": "00:00:00",
      "pcPlayDuration": 0,
      "pcFlowSize": 0,
      "pcVideoView": 0,
      "pcUniqueViewer": 0,
      "formatMobilePlayDuration": "00:00:00",
      "mobilePlayDuration": 0,
      "mobileFlowSize": 0,
      "mobileVideoView": 0,
      "mobileUniqueViewer": 0
    },
    {
      "currentHour": 14,
      "formatPcPlayDuration": "00:03:40",
      "pcPlayDuration": 220,
      "pcFlowSize": 99915723,
      "pcVideoView": 13,
      "pcUniqueViewer": 4,
      "formatMobilePlayDuration": "00:00:00",
      "mobilePlayDuration": 0,
      "mobileFlowSize": 0,
      "mobileVideoView": 0,
      "mobileUniqueViewer": 0
    },
    {
      "currentHour": 15,
      "formatPcPlayDuration": "00:02:53",
      "pcPlayDuration": 173,
      "pcFlowSize": 103330520,
      "pcVideoView": 18,
      "pcUniqueViewer": 5,
      "formatMobilePlayDuration": "00:00:37",
      "mobilePlayDuration": 37,
      "mobileFlowSize": 5371656,
      "mobileVideoView": 2,
      "mobileUniqueViewer": 2
    },
    {
      "currentHour": 16,
      "formatPcPlayDuration": "00:06:23",
      "pcPlayDuration": 383,
      "pcFlowSize": 93677801,
      "pcVideoView": 25,
      "pcUniqueViewer": 5,
      "formatMobilePlayDuration": "00:01:00",
      "mobilePlayDuration": 60,
      "mobileFlowSize": 22594584,
      "mobileVideoView": 3,
      "mobileUniqueViewer": 3
    },
    {
      "currentHour": 17,
      "formatPcPlayDuration": "00:08:08",
      "pcPlayDuration": 488,
      "pcFlowSize": 70086213,
      "pcVideoView": 8,
      "pcUniqueViewer": 5,
      "formatMobilePlayDuration": "00:04:15",
      "mobilePlayDuration": 255,
      "mobileFlowSize": 67539370,
      "mobileVideoView": 7,
      "mobileUniqueViewer": 1
    },
    {
      "currentHour": 18,
      "formatPcPlayDuration": "00:01:53",
      "pcPlayDuration": 113,
      "pcFlowSize": 34434354,
      "pcVideoView": 8,
      "pcUniqueViewer": 3,
      "formatMobilePlayDuration": "00:00:10",
      "mobilePlayDuration": 10,
      "mobileFlowSize": 1196895,
      "mobileVideoView": 1,
      "mobileUniqueViewer": 1
    },
    {
      "currentHour": 19,
      "formatPcPlayDuration": "00:00:00",
      "pcPlayDuration": 0,
      "pcFlowSize": 0,
      "pcVideoView": 0,
      "pcUniqueViewer": 0,
      "formatMobilePlayDuration": "00:00:00",
      "mobilePlayDuration": 0,
      "mobileFlowSize": 0,
      "mobileVideoView": 0,
      "mobileUniqueViewer": 0
    },
    {
      "currentHour": 20,
      "formatPcPlayDuration": "00:00:00",
      "pcPlayDuration": 0,
      "pcFlowSize": 0,
      "pcVideoView": 0,
      "pcUniqueViewer": 0,
      "formatMobilePlayDuration": "00:00:00",
      "mobilePlayDuration": 0,
      "mobileFlowSize": 0,
      "mobileVideoView": 0,
      "mobileUniqueViewer": 0
    },
    {
      "currentHour": 21,
      "formatPcPlayDuration": "00:00:00",
      "pcPlayDuration": 0,
      "pcFlowSize": 0,
      "pcVideoView": 0,
      "pcUniqueViewer": 0,
      "formatMobilePlayDuration": "00:00:00",
      "mobilePlayDuration": 0,
      "mobileFlowSize": 0,
      "mobileVideoView": 0,
      "mobileUniqueViewer": 0
    },
    {
      "currentHour": 22,
      "formatPcPlayDuration": "00:00:00",
      "pcPlayDuration": 0,
      "pcFlowSize": 0,
      "pcVideoView": 0,
      "pcUniqueViewer": 0,
      "formatMobilePlayDuration": "00:00:00",
      "mobilePlayDuration": 0,
      "mobileFlowSize": 0,
      "mobileVideoView": 0,
      "mobileUniqueViewer": 0
    },
    {
      "currentHour": 23,
      "formatPcPlayDuration": "00:00:00",
      "pcPlayDuration": 0,
      "pcFlowSize": 0,
      "pcVideoView": 0,
      "pcUniqueViewer": 0,
      "formatMobilePlayDuration": "00:00:00",
      "mobilePlayDuration": 0,
      "mobileFlowSize": 0,
      "mobileVideoView": 0,
      "mobileUniqueViewer": 0
    }
  ]
}

异常示例

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

Last updated