保利威文档中心

帮助中心

查询视频播放的终端环境分布

更新时间:2025-01-14 16:19:48

接口描述

1、查询视频终端环境统计数据,包括浏览器环境,操作系统环境,终端环境。从播放行为产生到数据可查询的间隔时间为1~2小时
2、接口URL中的{userid}为点播账号userid,具体参考【获取密钥】
3、接口支持https协议

接口URL

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

在线API调用

请求方式

GET

接口约束

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

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

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

请求参数描述

参数名 必选 类型 说明
ptime true Long 当前时间的毫秒级时间戳,3分钟内有效
sign true String 签名,为40位大写的SHA1值,生成签名的secretkey密钥作为通信数据安全的关键信息,严禁保存在客户端直接使用,所有API都必须通过客户自己服务器中转调用POLYV服务器获取响应数据【详见签名生成规则
dr false String 时间段,具体值为以下几个,默认值为7days
today:今天
yesterday:昨天
this_week:本周
last_week:上周
7days:最近7天
this_month:本月
last_month:上个月
this_year:今年
last_year:去年
start false String 开始日期,格式为:yyyy-MM-dd,例如:2021-04-07
end false String 结束日期,格式为:yyyy-MM-dd,例如:2021-04-10

示例

http://api.polyv.net/v2/device/1b448be323?start=2021-03-16&sign=F3A24F3621CE3D0B0B5366E56D95A6E3CF34B2AA&end=2021-03-24&ptime=1617875576619&dr=this_year

响应参数描述

参数名 类型 说明
code Integer 响应状态码,200为成功返回,非200为失败【详见全局错误说明
status String 响应状态文本信息
message String 响应描述信息,当code为400或者500的时候,辅助描述错误原因
data Object 响应成功时返回域名统计信息【详见Data字段说明】,响应失败时返回空
Data参数描述
字段 类型 说明
device Array 终端环境统计数据【详见Device字段说明
operatingSystem Array 操作系统环境统计数据【详见OperatingSystem字段说明
browser Array 浏览器环境统计数据【详见Browser字段说明
Device参数描述
字段 类型 说明
deviceName String 终端环境名称,pc端或移动端
videoView Integer 视频总播放量
formatPlayDuration String 格式化的总播放时长,格式为:时:分:秒,例如:00:00:00
playDuration Integer 视频总播放时长,单位秒
uniqueViewer Integer 视频总观众数
percentage Float 总占比
OperatingSystem参数描述
字段 类型 说明
operateSystemName String 操作系统环境名称
videoView Integer 视频总播放量
formatPlayDuration String 格式化的总播放时长,格式为:时:分:秒,例如:00:00:00
playDuration Integer 视频总播放时长,单位秒
uniqueViewer Integer 视频总观众数
pcPercentage Float 总占比
Browser参数描述
字段 类型 说明
browserName String 浏览器环境名称
mobilePlayDuration Integer 移动端播放时长,单位秒
formatMobilePlayDuration String 格式化的移动端播放时长,格式为:时:分:秒,例如:00:00:00
mobileVideoView Integer 移动端播放量
mobileUniqueViewer Integer 移动端唯一观众数
mobilePercentage Float 移动端数据占比
pcPlayDuration Integer pc端播放时长,单位秒
formatPcPlayDuration String 格式化的pc端播放时长,格式为:时:分:秒,例如:00:00:00
pcVideoView Integer pc端播放量
pcUniqueViewer Integer pc端唯一观众数
pcPercentage Float pc端数据占比

返回错误代码列表

错误代码 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日期
500 query failed. 后台程序抛异常

Java请求示例

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

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

private static final Logger log = LoggerFactory.getLogger(VodStatisticsTest.class);
/**
 * 查询视频播放的终端环境分布
 */
@Test
public void testGetDeviceStat() throws Exception, NoSuchAlgorithmException {
    //公共参数,填写自己的实际参数
    String secretKey = super.secretKey;
    String userId = super.userId;
    String ptime = String.valueOf(System.currentTimeMillis());
    //业务参数
    String url = String.format("https://api.polyv.net/v2/device/%s", userId);
    String dr = "this_year";
    String start = "2021-03-16";
    String end = "2021-03-24";

    Map<String, String> requestMap = new HashMap<>();
    requestMap.put("ptime", ptime);
    requestMap.put("dr", dr);
    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": {
        "device": [{
            "deviceName": "PC端",
            "videoView": 17,
            "formatPlayDuration": "00:03:10",
            "playDuration": 190,
            "uniqueViewer": 4,
            "percentage": "80.95"
        }, {
            "deviceName": "移动端",
            "videoView": 4,
            "formatPlayDuration": "00:00:57",
            "playDuration": 57,
            "uniqueViewer": 3,
            "percentage": "19.05"
        }],
        "operatingSystem": [{
            "operateSystemName": "Windows",
            "videoView": 17,
            "formatPlayDuration": "00:03:10",
            "playDuration": 190,
            "uniqueViewer": 4,
            "percentage": "80.95"
        }, {
            "operateSystemName": "Android",
            "videoView": 4,
            "formatPlayDuration": "00:00:57",
            "playDuration": 57,
            "uniqueViewer": 3,
            "percentage": "19.05"
        }],
        "browser": [{
            "browserName": "Chrome",
            "formatPcPlayDuration": "00:02:47",
            "pcPlayDuration": 167,
            "pcVideoView": 14,
            "pcUniqueViewer": 3,
            "formatMobilePlayDuration": "00:00:00",
            "mobilePlayDuration": 0,
            "mobileVideoView": 0,
            "mobileUniqueViewer": 0,
            "pcPercentage": "82.35",
            "mobilePercentage": "0.00"
        }, {
            "browserName": "Firefox",
            "formatPcPlayDuration": "00:00:23",
            "pcPlayDuration": 23,
            "pcVideoView": 3,
            "pcUniqueViewer": 1,
            "formatMobilePlayDuration": "00:00:00",
            "mobilePlayDuration": 0,
            "mobileVideoView": 0,
            "mobileUniqueViewer": 0,
            "pcPercentage": "17.65",
            "mobilePercentage": "0.00"
        }, {
            "browserName": "微信",
            "formatPcPlayDuration": "00:00:00",
            "pcPlayDuration": 0,
            "pcVideoView": 0,
            "pcUniqueViewer": 0,
            "formatMobilePlayDuration": "00:00:57",
            "mobilePlayDuration": 57,
            "mobileVideoView": 4,
            "mobileUniqueViewer": 3,
            "pcPercentage": "0.00",
            "mobilePercentage": "100.00"
        }]
    }
}

异常示例

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