dataStatisticsService
1. Query Video Viewing Logs for a Specific Day
Description
通过日志时间查询某一天的视频观看日志
接口地址(仅做说明使用):https://api.polyv.net/v2/data/%s/viewlog
Call Constraints
The API call has a frequency limit. For details, please refer to [/vod/java/limit]. For common call exceptions, please refer to [/vod/java/exceptionDoc].
The interval from when a playback behavior occurs to when the data becomes queryable is 1 to 2 hours. However, the traffic calculation for each viewing record (the
flowSizefield) depends on CDN logs. To ensure data integrity, traffic data is generated only after a full calendar day. For example, traffic consumption generated on the 1st will be available on the 2nd.
Summary calculation is performed on the evening of the 1st, and traffic data can only be queried on the 3rd.
- Note: When the video ID and category ID are empty, query all video logs for the account on the current day; when the video ID is empty but the category ID is not empty, query logs under the corresponding category ID; when the video ID is not empty, query logs for the corresponding video ID.
Unit Test
@Test
public void testQueryViewLogByDay() throws IOException, NoSuchAlgorithmException {
VodQueryViewLogByDayRequest vodQueryViewLogByDayRequest = new VodQueryViewLogByDayRequest();
List<VodQueryViewLogByDayResponse> vodQueryViewLogByDayResponseList = null;
try {
int year = new Date().getYear() + 1900;
vodQueryViewLogByDayRequest.setDay(super.getDate(year, 2, 4))
.setVideoId(super.getTestVideoId())
.setCategoryId("1602300731843")
.setSessionId(null)
.setViewerId(null);
vodQueryViewLogByDayResponseList = new VodDataStatisticsServiceImpl().queryViewLogByDay(
vodQueryViewLogByDayRequest);
Assert.assertNotNull(vodQueryViewLogByDayResponseList);
if (vodQueryViewLogByDayResponseList != null) {
log.debug("测试查询某一天视频观看日志成功,{}", JSON.toJSONString(vodQueryViewLogByDayResponseList));
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Test Description
If the request is correct, return a VodQueryViewLogByDayResponse object, and the B-side processes business logic based on this object.
If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message can be found viaPloyvSdkException.getMessage(), for example: [ Input parameter [xxx.chat.VodxxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty] ]The server encountered an exception and threw a PloyvSdkException. For error details, refer to PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| day | true | Date | Query log time for a specific day, format: yyyy-MM-dd |
| timeStart | false | String | Range query, specific time (hours, minutes, seconds) for log information, format: HHmmss, e.g., 000000. timeStart and timeEnd must be used together. |
| timeEnd | false | String | Range query, specific time (hours, minutes, seconds) for log information, format: HHmmss, e.g., 235959. timeStart and timeEnd must be used together. |
| videoId | false | String | Video ID [corresponds to the vid field in the API documentation] |
| categoryId | false | String | Category ID [corresponds to the cataid field in the API documentation] |
| sessionId | false | String | User-defined ID, custom value (e.g., student ID representing learner information), maximum length of 50 English characters. |
| viewerId | false | String | User-defined ID. When passed together with sessionId, viewerId takes precedence. |
| param4 | false | String | Custom parameter |
Return Object Description
The return object is List<VodQueryViewLogByDayResponse>. The specific elements of VodQueryViewLogByDayResponse are as follows:
| Parameter Name | Type | Description |
|---|---|---|
| playId | String | ID representing this playback action |
| userId | String | User ID |
| videoId | String | Video ID |
| playDuration | Integer | Playback duration in seconds (total time the user watched, e.g., starting a video at 18:00 and watching until 18:30, the 30 minutes is the playback duration) |
| stayDuration | Integer | Buffering duration in seconds |
| currentTimes | Integer | Playback time in seconds (the last time the user watched, e.g., when stopping the video, the progress bar shows 35 minutes, so the playback time is 35 minutes) |
| duration | Integer | Total video duration in seconds |
| flowSize | Long | Traffic size in bytes |
| sessionId | String | User-defined parameter, such as student ID |
| param1 | String | POLYV system parameter |
| param2 | String | POLYV system parameter |
| param3 | String | POLYV system parameter |
| param4 | String | POLYV system parameter |
| param5 | String | POLYV system parameter |
| ipAddress | String | IP address |
| country | String | Country |
| province | String | Province |
| city | String | City |
| isp | String | ISP provider |
| referer | String | URL of the page playing the video |
| userAgent | String | User device |
| operatingSystem | String | Operating system |
| browser | String | Browser |
| isMobile | String | Whether it is a mobile device, Y: Yes; N: No |
| currentDay | Date | Log query date (format: yyyy-MM-dd) |
| currentHour | Integer | Log view time in hours |
| viewSource | String | User viewing channel, values include: vod_ios_sdk: iOS, vod_android_sdk: Android, vod_flash: Flash, vod_wechat_mini_program: WeChat Mini Program; vod_pc_html5: PC web, vod_mobile_html5: Mobile web, vod_mobile_html5_v2: Mobile web v2 |
| createdTime | Date | Log creation time, format: yyyy-MM-dd HH:mm |
| lastModified | Date | Log update date, format: yyyy-MM-dd HH:mm |
2. Batch Query Video Watch Logs
Description
通过日志月份批量查询视频观看日志信息
接口地址(仅做说明使用):https://api.polyv.net/v2/viewlog/%s/monthly/%s
Call Constraints
- The API call has a frequency limit. For details, please refer to [/vod/java/limit]. For common call exceptions, please refer to [/vod/java/exceptionDoc].
Unit Testing
@Test
public void testGetVideoPlayLog() throws IOException, NoSuchAlgorithmException {
VodGetVideoPlayLogRequest vodGetVideoPlayLogRequest = new VodGetVideoPlayLogRequest();
VodGetVideoPlayLogResponse vodGetVideoPlayLogResponse = null;
try {
int year = new Date().getYear() + 1900;
vodGetVideoPlayLogRequest.setMonth(super.getDate(year, 2, 1))
//根据自己实际需要传 Date 即可
.setStartTime(super.getDate(year, 2, 1))
//根据自己实际需要传 Date 即可
.setEndTime(super.getDate(year, 2, 31))
.setVideoId(super.getTestVideoId())
.setCurrentDay(null)
.setCurrentPage(1)
.setPageSize(10);
vodGetVideoPlayLogResponse = new VodDataStatisticsServiceImpl().getVideoPlayLog(vodGetVideoPlayLogRequest);
Assert.assertNotNull(vodGetVideoPlayLogResponse);
if (vodGetVideoPlayLogResponse != null) {
log.debug("测试批量查询视频观看日志成功,{}", JSON.toJSONString(vodGetVideoPlayLogResponse));
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Testing Instructions
If the request is correct, return a
VodGetVideoPlayLogResponseobject, based on which the B-side processes the business logic.If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message can be found viaPloyvSdkException.getMessage(), for example: [ Input parameter [xxx.chat.VodxxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty] ]The server encountered an exception and threw a PloyvSdkException. For error details, see PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter Name | Required | Type | Description |
|---|---|---|---|
| month | true | Date | Query month, format is yyyyMM |
| startTime | false | Date | Query start date, format is yyyy-MM-dd [corresponds to the start field in the API documentation] |
| endTime | false | Date | Query end date, format is yyyy-MM-dd [corresponds to the end field in the API documentation] |
| videoId | false | String | The video vid to query; when vid is empty, query logs for all videos of the user [corresponds to the vid field in the API documentation] |
| sessionId | false | String | User-defined ID, custom value |
| currentDay | false | Date | Data for a specific day within the month, format is yyyy-MM-dd |
| param4 | false | String | Custom parameter |
| currentPage | false | Integer | Page number, default is 1 [corresponds to the page field in the API documentation] |
| pageSize | false | Integer | Number of data entries displayed per page, default is 20 entries per page |
Return Object Description
| Parameter Name | Type | Description |
|---|---|---|
| contents | Array | Returned result set [See VideoPlayLog Parameter Description for details] |
| pageSize | Integer | Number of data items displayed per page, default is 20 items per page |
| currentPage | Integer | Current page [Corresponds to the pageNumber field in the API documentation] |
| totalItems | Integer | Total number of records |
| totalPage | Integer | Total number of pages [Corresponds to the totalPages field in the API documentation] |
VideoPlayLog Parameter Description
| Parameter Name | Type | Description |
|---|---|---|
| playId | String | ID representing this playback action |
| userId | String | User ID |
| videoId | String | Video ID |
| playDuration | Integer | Playback duration (total time the user watched, e.g., starting at 18:00 and watching until 18:30, the 30 minutes is the playback duration). Unit: seconds |
| stayDuration | Integer | Buffering duration. Unit: seconds |
| currentTimes | Integer | Playback time (the last time the user watched, e.g., when stopping the video, the progress bar shows 35 minutes, so the playback time is 35 minutes). Unit: seconds |
| duration | Integer | Total video duration. Unit: seconds |
| flowSize | Long | Traffic size, unit: Bytes |
| sessionId | String | User-defined parameter, such as student ID. This parameter is encrypted with UrlSafeBase64 and needs to be decrypted |
| param1 | String | POLYV system parameter |
| param2 | String | POLYV system parameter |
| param3 | String | POLYV system parameter |
| param4 | String | POLYV system parameter |
| param5 | String | POLYV system parameter |
| ipAddress | String | IP address |
| country | String | Country |
| province | String | Province |
| city | String | City |
| isp | String | ISP provider |
| referer | String | URL of the page playing the video |
| userAgent | String | User device |
| operatingSystem | String | Operating system |
| browser | String | Browser |
| isMobile | String | Whether it is a mobile device |
| currentDay | Date | Log query date (format: yyyy-MM-dd) |
| currentHour | Integer | Log viewing time. Unit: hours |
| viewSource | String | User viewing channel, possible values: vod_ios_sdk, vod_android_sdk, vod_flash, vod_pc_html5, vod_wechat_mini_program, vod_mobile_html5 |
| createdTime | Date | Log creation time |
| lastModified | Date | Log update date |
3. Query Video Playback Statistics
Description
通过视频id或时间范围查询视频播放量统计数据
接口地址(仅做说明使用):https://api.polyv.net/v2/videoview/%s
Call Constraints
The API call has a frequency limit. For details, please refer to [/vod/java/limit]. For common call exceptions, please refer to [/vod/java/exceptionDoc].
Query video playback statistics. The interval between when a playback action occurs and when the data becomes available for querying is 1 to 2 hours.
Unit Test
@Test
public void testQueryVideoPlaybackStatistics() throws IOException, NoSuchAlgorithmException {
VodQueryVideoPlaybackStatisticsRequest vodQueryVideoPlaybackStatisticsRequest =
new VodQueryVideoPlaybackStatisticsRequest();
List<VodQueryVideoPlaybackStatisticsResponse> vodQueryVideoPlaybackStatisticsResponseList = null;
try {
vodQueryVideoPlaybackStatisticsRequest.setDr("7days").setPeriod("daily");
vodQueryVideoPlaybackStatisticsResponseList =
new VodDataStatisticsServiceImpl().queryVideoPlaybackStatistics(
vodQueryVideoPlaybackStatisticsRequest);
Assert.assertNotNull(vodQueryVideoPlaybackStatisticsResponseList);
if (vodQueryVideoPlaybackStatisticsResponseList != null) {
log.debug("测试查询视频播放量统计数据成功,{}", JSON.toJSONString(vodQueryVideoPlaybackStatisticsResponseList));
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Test Description
If the request is correct, a
VodQueryVideoPlaybackStatisticsResponseobject is returned, and the B-side processes business logic based on this object.If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message can be found viaPloyvSdkException.getMessage(), for example: [ Input parameter [xxx.chat.VodxxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty] ]The server encountered an exception and threw a PloyvSdkException. For error details, see PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| videoId | false | String | Video videoId. If not filled, it will query the playback statistics of all videos [corresponds to the vid field in the API documentation] |
| dr | false | String | Time range. Possible values: today, yesterday, this_week, last_week, 7days, this_month, last_month, this_year, last_year. Default value is 7days: last 7 days |
| period | false | String | Display period. Possible values: daily (display by day), weekly (display by week), monthly (display by month). Default value is daily: display by day. The value of period is constrained by dr. When dr is today, yesterday, this_week, last_week, or 7days, period can only be daily. When dr is this_month or last_month, period can only be daily or weekly |
Return Object Description
The return object is List<VodQueryVideoPlaybackStatisticsResponse>. The specific elements of VodQueryVideoPlaybackStatisticsResponse are as follows:
| Parameter Name | Type | Description |
|---|---|---|
| currentTime | String | Current date, format: yyyy-MM-dd or yyyy-MM |
| pcVideoView | Integer | PC video views |
| mobileVideoView | Integer | Mobile video views |
4. Query Playback Domain Statistics
Description
通过时间范围查询播放域名统计数据
接口地址(仅做说明使用):https://api.polyv.net/v2/domain/%s
Call Constraints
The API call is subject to rate limits. For details, please refer to [/vod/java/limit]. For common call exceptions, please refer to [/vod/java/exceptionDoc].
Query Playback Domain Statistics
The interval from when playback behavior occurs to when the data becomes queryable is 1–2 hours. However, the calculation of traffic consumption (PCFlowSize field) depends on CDN logs. To ensure data integrity, traffic data is generated only after a full calendar day. For example, traffic consumption generated on the 1st will be available on the 2nd.
The summary calculation is performed on the night of the 3rd, and traffic data can only be queried on the 3rd.
Unit Test
@Test
public void testQueryPlayDomainNameStatistics() throws IOException, NoSuchAlgorithmException {
VodQueryPlayDomainNameStatisticsRequest vodQueryPlayDomainNameStatisticsRequest =
new VodQueryPlayDomainNameStatisticsRequest();
List<VodQueryPlayDomainNameStatisticsResponse> vodQueryPlayDomainNameStatisticsResponseList = null;
try {
int year = new Date().getYear() + 1900;
vodQueryPlayDomainNameStatisticsRequest.setDr("7days")
//根据自己实际需要传 Date 即可
.setStartTime(super.getDate(year, 2, 18))
//根据自己实际需要传 Date 即可
.setEndTime(super.getDate(year, 2, 24));
vodQueryPlayDomainNameStatisticsResponseList =
new VodDataStatisticsServiceImpl().queryPlayDomainNameStatistics(
vodQueryPlayDomainNameStatisticsRequest);
Assert.assertNotNull(vodQueryPlayDomainNameStatisticsResponseList);
if (vodQueryPlayDomainNameStatisticsResponseList != null) {
log.debug("测试查询播放域名统计数据成功,{}", JSON.toJSONString(vodQueryPlayDomainNameStatisticsResponseList));
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Test Description
If the request is correct, a VodQueryPlayDomainNameStatisticsResponse object is returned, and the B-side processes business logic based on this object.
If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message can be found inPloyvSdkException.getMessage(), for example: [ Input parameter [xxx.chat.VodxxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty] ]The server encountered an exception and threw a PloyvSdkException. For error details, refer to PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| dr | false | String | Time period. Possible values: today, yesterday, this_week, last_week, 7days, this_month, last_month, this_year, last_year. Default value is 7days: Last 7 days |
| startTime | false | Date | Query start date, format: yyyy-MM-dd [Corresponds to the start field in the API documentation] |
| endTime | false | Date | Query end date, format: yyyy-MM-dd [Corresponds to the end field in the API documentation] |
Return Object Description
The return object is List<VodQueryPlayDomainNameStatisticsResponse>. The specific elements of VodQueryPlayDomainNameStatisticsResponse are as follows:
| Parameter Name | Type | Description |
|---|---|---|
| domain | String | Domain name |
| pcPlayDuration | Integer | PC playback duration (in seconds) |
| pcFlowSize | Long | PC data consumption (in bytes) |
| pcVideoView | Integer | Total PC video views |
| pcUniqueViewer | Integer | Unique PC viewers |
| mobilePlayDuration | Integer | Mobile playback duration (in seconds) |
| mobileVideoView | Integer | Mobile video views |
| mobileUniqueViewer | Integer | Unique mobile viewers |
5. Query Video Terminal Environment Statistics
Description
通过时间范围查询视频终端环境统计数据
接口地址(仅做说明使用):https://api.polyv.net/v2/device/%s
Call Constraints
The API call has a frequency limit. For details, please refer to [/vod/java/limit]. For common call exceptions, please refer to [/vod/java/exceptionDoc].
Query video terminal environment statistics, including browser environment, operating system environment, and terminal environment. The interval from when playback behavior occurs to when data becomes queryable is 1 to 2 hours.
Unit Test
@Test
public void testQueryVideoDeviceStatistics() throws IOException, NoSuchAlgorithmException {
VodQueryVideoDeviceStatisticsRequest vodQueryVideoDeviceStatisticsRequest =
new VodQueryVideoDeviceStatisticsRequest();
VodQueryVideoDeviceStatisticsResponse vodQueryVideoDeviceStatisticsResponse = null;
try {
int year = new Date().getYear() + 1900;
vodQueryVideoDeviceStatisticsRequest.setDr("7days")
//根据自己实际需要传 Date 即可
.setStartTime(super.getDate(year, 2, 18))
//根据自己实际需要传 Date 即可
.setEndTime(super.getDate(year, 2, 24));
vodQueryVideoDeviceStatisticsResponse = new VodDataStatisticsServiceImpl().queryVideoDeviceStatistics(
vodQueryVideoDeviceStatisticsRequest);
Assert.assertNotNull(vodQueryVideoDeviceStatisticsResponse);
if (vodQueryVideoDeviceStatisticsResponse != null) {
log.debug("测试查询视频终端环境统计数据成功,{}", JSON.toJSONString(vodQueryVideoDeviceStatisticsResponse));
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Test Description
If the request is correct, a VodQueryVideoDeviceStatisticsResponse object is returned, and the B-side processes business logic based on this object.
If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message can be found viaPloyvSdkException.getMessage(), for example: [ Input parameter [xxx.chat.VodxxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty] ]The server encountered an exception and threw a PloyvSdkException. For error details, refer to PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| dr | false | String | Time period, with specific values as follows: today, yesterday, this_week, last_week, 7days, this_month, last_month, this_year, last_year. Default value is 7days: last 7 days |
| startTime | false | Date | Query start date, format is yyyy-MM-dd [corresponds to the start field in the API documentation] |
| endTime | false | Date | Query end date, format is yyyy-MM-dd [corresponds to the end field in the API documentation] |
Return Object Description
| Parameter Name | Type | Description |
|---|---|---|
| device | Array | Terminal environment statistics [See Device Parameter Description] |
| operatingSystem | Array | Operating system environment statistics [See OperatingSystem Parameter Description] |
| browser | Array | Browser environment statistics [See Browser Parameter Description] |
Device Parameter Description
| Parameter Name | Type | Description |
|---|---|---|
| deviceName | String | Terminal environment name, PC or mobile |
| videoView | Integer | Total video views |
| formatPlayDuration | String | Total video play duration, format hh:mm:ss e.g., 00:03:22 |
| playDuration | Integer | Total video play duration, unit: seconds |
| uniqueViewer | Integer | Total unique viewers |
| percentage | Float | Total percentage |
OperatingSystem parameter description
| Parameter Name | Type | Description |
|---|---|---|
| operateSystemName | String | Operating system environment name |
| videoView | Integer | Total video views |
| formatPlayDuration | String | Total video play duration, format hh:mm:ss e.g., 00:03:22 |
| playDuration | String | Total video play duration, format hh:mm:ss e.g., 00:03:22 |
| uniqueViewer | Integer | Total unique viewers |
| percentage | Float | Total percentage |
Browser Parameter Description
| Parameter Name | Type | Description |
|---|---|---|
| browserName | String | Browser environment name |
| formatPcPlayDuration | String | Formatted PC play duration, format hh:mm:ss e.g., 00:00:00 |
| pcPlayDuration | Integer | PC play duration, in seconds |
| pcVideoView | Integer | PC play count |
| pcUniqueViewer | Integer | PC unique viewers |
| formatMobilePlayDuration | String | Formatted mobile play duration, format hh:mm:ss e.g., 00:00:00 |
| mobilePlayDuration | Integer | Mobile play duration, in seconds |
| mobileVideoView | Integer | Mobile play count |
| mobileUniqueViewer | Integer | Mobile unique viewers |
| pcPercentage | Float | PC data percentage |
| mobilePercentage | Float | Mobile data percentage |
6. Query Video Playback Time Period Statistics
Description
通过时间范围查询视频播放时段统计数据
接口地址(仅做说明使用):https://api.polyv.net/v2/hourly/%s
Call Constraints
The API call has a frequency limit. For details, please refer to [/vod/java/limit]. For common call exceptions, please refer to [/vod/java/exceptionDoc].
The interval from when a playback behavior occurs to when the data becomes queryable is 1 to 2 hours. However, the calculation of traffic consumption (PCFlowSize, mobileFlowSize fields) in the statistical results depends on the CDN.
Logs: To ensure data integrity, traffic data is generated only after a natural day interval. For example, traffic consumption generated on the 1st will be aggregated and calculated on the night of the 2nd, and the traffic data will only be available for query on the 3rd.
Unit Test
@Test
public void testQueryVideoPlaybackHourlyStatistics() throws IOException, NoSuchAlgorithmException {
VodQueryVideoPlaybackHourlyStatisticsRequest vodQueryVideoPlaybackHourlyStatisticsRequest =
new VodQueryVideoPlaybackHourlyStatisticsRequest();
List<VodQueryVideoPlaybackHourlyStatisticsResponse> vodQueryVideoPlaybackHourlyStatisticsResponseList = null;
try {
vodQueryVideoPlaybackHourlyStatisticsRequest.setDr("7days");
vodQueryVideoPlaybackHourlyStatisticsResponseList =
new VodDataStatisticsServiceImpl().queryVideoPlaybackHourlyStatistics(
vodQueryVideoPlaybackHourlyStatisticsRequest);
Assert.assertNotNull(vodQueryVideoPlaybackHourlyStatisticsResponseList);
if (vodQueryVideoPlaybackHourlyStatisticsResponseList != null) {
log.debug("测试查询视频播放时段统计数据成功,{}", JSON.toJSONString(vodQueryVideoPlaybackHourlyStatisticsResponseList));
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Test Description
If the request is correct, a
VodQueryVideoPlaybackHourlyStatisticsResponseobject is returned, and the B-side processes business logic based on this object.If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message can be found viaPloyvSdkException.getMessage(), for example: [ Input parameter [xxx.chat.VodxxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty] ]The server encountered an exception and threw a PloyvSdkException. For error details, see PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| dr | false | String | Time period, with specific values as follows: today, yesterday, this_week, last_week, 7days, this_month, last_month, this_year, last_year. Default value is 7days: last 7 days |
| startTime | false | Date | Query start date, format is yyyy-MM-dd [corresponds to the start field in the API documentation] |
| endTime | false | Date | Query end date, format is yyyy-MM-dd [corresponds to the end field in the API documentation] |
Return Object Description
The return object is List<VodQueryVideoPlaybackHourlyStatisticsResponse>. The specific elements of VodQueryVideoPlaybackHourlyStatisticsResponse are as follows:
| Parameter Name | Type | Description |
|---|---|---|
| currentHour | Integer | Time period, 24-hour format, e.g., 18 |
| pcPlayDuration | Integer | PC playback duration, in seconds |
| formatPcPlayDuration | String | PC playback duration, format hh:mm:ss, e.g., 03:02:22 |
| pcFlowSize | Long | PC data consumption, in bytes |
| pcVideoView | Integer | PC play count |
| pcUniqueViewer | Integer | PC unique viewers |
| mobilePlayDuration | Integer | Mobile playback duration, in seconds |
| formatMobilePlayDuration | String | Mobile playback duration, format hh:mm:ss, e.g., 03:02:22 |
| mobileFlowSize | Long | Mobile data consumption, in bytes |
| mobileVideoView | Integer | Mobile play count |
| mobileUniqueViewer | Integer | Mobile unique viewers |
7. Query Video Playback Traffic Statistics
Description
通过时间范围查询视频播放流量统计数据
接口地址(仅做说明使用):https://api.polyv.net/v2/traffic/%s/video/%s
Call Constraints
The API call has a frequency limit. For details, please refer to [/vod/java/limit]. For common call exceptions, please refer to [/vod/java/exceptionDoc].
Starting from July 10, 2018, mobile traffic data for individual videos can be tracked. No mobile traffic data is available prior to this date.
Traffic consumption calculation relies on CDN logs. To ensure data integrity, traffic data is generated with a one-day delay. For example, traffic consumed on the 1st will be aggregated and calculated on the night of the 2nd, and the traffic data will only be available for query on the 3rd.
Unit Test
@Test
public void testQueryVideoPlaybackFlowSizeStatistics() throws IOException, NoSuchAlgorithmException {
VodQueryVideoPlaybackFlowSizeStatisticsRequest vodQueryVideoPlaybackFlowSizeStatisticsRequest =
new VodQueryVideoPlaybackFlowSizeStatisticsRequest();
List<VodQueryVideoPlaybackFlowSizeStatisticsResponse> vodQueryVideoPlaybackFlowSizeStatisticsResponseList =
null;
try {
int year = new Date().getYear() + 1900;
vodQueryVideoPlaybackFlowSizeStatisticsRequest.setDr("7days")
.setVideoId("1b448be32345b255cabc3fe8d65a4d00_1")
//根据自己实际需要传 Date 即可
.setStartTime(super.getDate(year, 2, 18))
//根据自己实际需要传 Date 即可
.setEndTime(super.getDate(year, 2, 24));
vodQueryVideoPlaybackFlowSizeStatisticsResponseList =
new VodDataStatisticsServiceImpl().queryVideoPlaybackFlowSizeStatistics(
vodQueryVideoPlaybackFlowSizeStatisticsRequest);
Assert.assertNotNull(vodQueryVideoPlaybackFlowSizeStatisticsResponseList);
if (vodQueryVideoPlaybackFlowSizeStatisticsResponseList != null) {
log.debug("测试查询视频播放流量统计数据成功,{}",
JSON.toJSONString(vodQueryVideoPlaybackFlowSizeStatisticsResponseList));
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Test Description
If the request is correct, a
VodQueryVideoPlaybackFlowSizeStatisticsResponseobject is returned, and the B-side processes business logic based on this object.If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message can be found viaPloyvSdkException.getMessage(), for example: [ Input parameter [xxx.chat.VodxxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty] ]The server encountered an exception and threw a PloyvSdkException. For error details, see PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| videoId | true | String | Video ID [Corresponds to the vid field in the API documentation] |
| dr | false | String | Time range, with specific values as follows: today, yesterday, this_week, last_week, 7days, this_month, last_month, this_year, last_year. Default value is 7days: last 7 days |
| startTime | false | Date | Query start date, format is yyyy-MM-dd [Corresponds to the start field in the API documentation] |
| endTime | false | Date | Query end date, format is yyyy-MM-dd [Corresponds to the end field in the API documentation] |
Return Object Description
The return object is List<VodQueryVideoPlaybackFlowSizeStatisticsResponse>. The specific elements of VodQueryVideoPlaybackFlowSizeStatisticsResponse are as follows:
| Parameter Name | Type | Description |
|---|---|---|
| currentDay | Date | Date in yyyy-MM-dd format, e.g., 2021-03-24 |
| pcFlowSize | Long | PC traffic consumption, in bytes |
| mobileFlowSize | Long | Mobile traffic consumption, in bytes |
| totalFlowSize | Long | Total traffic consumption, in bytes |
8. Query Video Playback Geographic Statistics
Description
通过时间范围查询视频播放地理位置统计数据
接口地址(仅做说明使用):https://api.polyv.net/v2/geo/%s
Call Constraints
The API call has a frequency limit. For details, please refer to [/vod/java/limit]. For common call exceptions, please refer to [/vod/java/exceptionDoc].
The interval from when a playback behavior occurs to when the data becomes queryable is 1 to 2 hours. However, the calculation of traffic consumption (PCFlowSize, mobileFlowSize fields) in the statistical results depends on the CDN.
Logs: To ensure data integrity, traffic data is generated only after a natural day has passed. For example, traffic consumption generated on the 1st will be aggregated and calculated on the night of the 2nd, and the traffic data will only be available for query on the 3rd.
Unit Test
@Test
public void testQueryVideoGeographicStatistics() throws IOException, NoSuchAlgorithmException {
VodQueryVideoGeographicStatisticsRequest vodQueryVideoGeographicStatisticsRequest =
new VodQueryVideoGeographicStatisticsRequest();
List<VodQueryVideoGeographicStatisticsResponse> vodQueryVideoGeographicStatisticsResponseList = null;
try {
int year = new Date().getYear() + 1900;
vodQueryVideoGeographicStatisticsRequest.setDr("7days")
//根据自己实际需要传 Date 即可
.setStartTime(super.getDate(year, 2, 18))
//根据自己实际需要传 Date 即可
.setEndTime(super.getDate(year, 2, 24));
vodQueryVideoGeographicStatisticsResponseList =
new VodDataStatisticsServiceImpl().queryVideoGeographicStatistics(
vodQueryVideoGeographicStatisticsRequest);
Assert.assertNotNull(vodQueryVideoGeographicStatisticsResponseList);
if (vodQueryVideoGeographicStatisticsResponseList != null) {
log.debug("测试查询视频播放地理位置统计数据成功,{}", JSON.toJSONString(vodQueryVideoGeographicStatisticsResponseList));
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Test Description
If the request is correct, a
VodQueryVideoGeographicStatisticsResponseobject is returned, and the B-side processes business logic based on this object.If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message can be found viaPloyvSdkException.getMessage(), for example: [ Input parameter [xxx.chat.VodxxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty] ]The server encountered an exception and threw a PloyvSdkException. For error details, see PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| dr | false | String | Time period, with specific values as follows: today, yesterday, this_week, last_week, 7days, this_month, last_month, this_year, last_year. Default value is 7days: last 7 days |
| startTime | false | Date | Query start date, format is yyyy-MM-dd [corresponds to the start field in the API documentation] |
| endTime | false | Date | Query end date, format is yyyy-MM-dd [corresponds to the end field in the API documentation] |
Return Object Description
The return object is List<VodQueryVideoGeographicStatisticsResponse>. The specific elements of VodQueryVideoGeographicStatisticsResponse are as follows:
| Parameter Name | Type | Description |
|---|---|---|
| province | String | Province |
| pcPlayDuration | Integer | PC playback duration, in seconds |
| formatPcPlayDuration | String | Playback duration, format hh:mm:ss, e.g., 00:03:22 |
| pcFlowSize | Long | PC data consumption, in bytes |
| pcVideoView | Integer | PC video views |
| pcUniqueViewer | Integer | PC unique viewers |
| mobilePlayDuration | Integer | Mobile playback duration, in seconds |
| formatMobilePlayDuration | String | Mobile playback duration, format hh:mm:ss, e.g., 00:03:22 |
| mobileFlowSize | Long | Mobile data consumption, in bytes |
| mobileVideoView | Integer | Mobile video views |
| mobileUniqueViewer | Integer | Mobile unique viewers |
9. Query Video Audience Statistics
Description
通过视频id或时间范围查询视频观众量统计数据
接口地址(仅做说明使用):https://api.polyv.net/v2/data/visitor/%s
Call Constraints
The API call has a frequency limit. For details, please refer to [/vod/java/limit]. For common call exceptions, please refer to [/vod/java/exceptionDoc].
Query the audience count statistics for videos by date range or segment and video ID. If the
vidparameter is not provided, it indicates querying the audience count for all videos under the user account.The interval from when a playback behavior occurs to when the data becomes queryable is 1 to 2 hours.
Unit Test
@Test
public void testQueryVideoViewership() throws IOException, NoSuchAlgorithmException {
VodQueryVideoViewershipRequest vodQueryVideoViewershipRequest = new VodQueryVideoViewershipRequest();
List<VodQueryVideoViewershipResponse> vodQueryVideoViewershipResponseList = null;
try {
int year = new Date().getYear() + 1900;
vodQueryVideoViewershipRequest.setDr("7days")
//根据自己实际需要传 Date 即可
.setStartTime(super.getDate(year, 2, 18))
//根据自己实际需要传 Date 即可
.setEndTime(super.getDate(year, 2, 24));
vodQueryVideoViewershipResponseList = new VodDataStatisticsServiceImpl().queryVideoViewership(
vodQueryVideoViewershipRequest);
Assert.assertNotNull(vodQueryVideoViewershipResponseList);
if (vodQueryVideoViewershipResponseList != null) {
log.debug("测试查询视频观众量统计数据成功,{}", JSON.toJSONString(vodQueryVideoViewershipResponseList));
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Test Description
If the request is correct, a VodQueryVideoViewershipResponse object is returned, and the B-side processes business logic based on this object.
If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message can be found viaPloyvSdkException.getMessage(), for example: [ Input parameter [xxx.chat.VodxxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty] ]The server encountered an exception and threw a PloyvSdkException. For error details, see PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| videoId | false | String | Video ID [corresponds to the vid field in the API documentation] |
| dr | false | String | Time range, with specific values as follows: today, yesterday, this_week, last_week, 7days, this_month, last_month, this_year, last_year. Default value is 7days: last 7 days |
| startTime | false | Date | Query start date, format is yyyy-MM-dd [corresponds to the startDate field in the API documentation] |
| endTime | false | Date | Query end date, format is yyyy-MM-dd [corresponds to the endDate field in the API documentation] |
Return Object Description
The return object is List<VodQueryVideoViewershipResponse>. The specific elements of VodQueryVideoViewershipResponse are as follows:
| Parameter | Type | Description |
|---|---|---|
| date | Date | Date in yyyy-MM-dd format, e.g., 2021-03-24 |
| pcUniqueViewer | Integer | Number of viewers on PC |
| mobileUniqueViewer | Integer | Number of viewers on mobile |
| totalUniqueViewer | Integer | Total number of viewers |
10. Query Video Playback Duration Statistics
Description
描述:通过视频id或时间范围查询视频的播放时长统计数据
接口地址(仅做说明使用):https://api.polyv.net/v2/play-duration/%s
Call Constraints
The API call has a frequency limit. For details, please refer to [/vod/java/limit]. For common call exceptions, please refer to [/vod/java/exceptionDoc].
Query video playback duration statistics by date range or time period. The interval from when playback behavior occurs to when data becomes queryable is 1–2 hours.
Unit Test
@Test
public void testQueryVideoPlayTimeStatistics() throws IOException, NoSuchAlgorithmException {
VodQueryVideoPlayTimeStatisticsRequest vodQueryVideoPlayTimeStatisticsRequest =
new VodQueryVideoPlayTimeStatisticsRequest();
List<VodQueryVideoPlayTimeStatisticsResponse> vodQueryVideoPlayTimeStatisticsResponseList = null;
try {
int year = new Date().getYear() + 1900;
vodQueryVideoPlayTimeStatisticsRequest.setDr("7days")
.setVideoId("1b448be32345b255cabc3fe8d65a4d00_1")
//根据自己实际需要传 Date 即可
.setStartTime(super.getDate(year, 2, 18))
//根据自己实际需要传 Date 即可
.setEndTime(super.getDate(year, 2, 24));
vodQueryVideoPlayTimeStatisticsResponseList =
new VodDataStatisticsServiceImpl().queryVideoPlayTimeStatistics(
vodQueryVideoPlayTimeStatisticsRequest);
Assert.assertNotNull(vodQueryVideoPlayTimeStatisticsResponseList);
if (vodQueryVideoPlayTimeStatisticsResponseList != null) {
log.debug("测试查询视频的播放时长统计数据成功,{}", JSON.toJSONString(vodQueryVideoPlayTimeStatisticsResponseList));
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Test Description
If the request is correct, a
VodQueryVideoPlayTimeStatisticsResponseobject is returned, and the B-side processes business logic based on this object.If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message can be found viaPloyvSdkException.getMessage(), for example: [ Input parameter [xxx.chat.VodxxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty] ]The server encountered an exception and threw a PloyvSdkException. For error details, refer to PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| videoId | false | String | Video ID. If not provided, user-level statistics are queried [Corresponds to the vid field in the API documentation]. |
| dr | false | String | Time period. Possible values: today, yesterday, this_week, last_week, 7days, this_month, last_month, this_year, last_year. Default value is 7days: last 7 days. |
| startTime | false | Date | Query start date, format: yyyy-MM-dd [Corresponds to the start field in the API documentation]. |
| endTime | false | Date | Query end date, format: yyyy-MM-dd [Corresponds to the end field in the API documentation]. |
Return Object Description
The return object is List<VodQueryVideoPlayTimeStatisticsResponse>. The specific elements of VodQueryVideoPlayTimeStatisticsResponse are as follows:
| Parameter Name | Type | Description |
|---|---|---|
| currentDay | Date | Date in yyyy-MM-dd format, e.g., 2021-03-24 |
| pcPlayDuration | Integer | PC playback duration (in seconds) |
| formatPcPlayDuration | String | Formatted PC playback duration in hh:mm:ss format, e.g., 00:03:22 |
| pcPlayDurationVideoAvg | Integer | Average video playback duration on PC (in seconds) |
| formatPcPlayDurationVideoAvg | String | Formatted average video playback duration on PC in hh:mm:ss format, e.g., 00:03:22 |
| pcPlayDurationPersonAvg | Integer | Average playback duration per person on PC (in seconds) |
| formatPcPlayDurationPersonAvg | String | Formatted average playback duration per person on PC in hh:mm:ss format, e.g., 00:03:22 |
| mobilePlayDuration | Integer | Mobile playback duration (in seconds) |
| formatMobilePlayDuration | String | Formatted mobile playback duration in hh:mm:ss format, e.g., 00:03:22 |
| mobilePlayDurationVideoAvg | Integer | Average video playback duration on mobile (in seconds) |
| formatMobilePlayDurationVideoAvg | String | Formatted average video playback duration on mobile in hh:mm:ss format, e.g., 00:03:22 |
| mobilePlayDurationPersonAvg | Integer | Average playback duration per person on mobile (in seconds) |
| formatMobilePlayDurationPersonAvg | String | Formatted average playback duration per person on mobile in hh:mm:ss format, e.g., 00:03:22 |
11. Query Viewing Hotspot Statistics for a Single Video
Description
通过视频id查询单个视频的观看热点统计数据
接口地址(仅做说明使用):https://api.polyv.net/v2/videohot/%s
Call Constraints
The API call is subject to rate limits. Click here for details. For common call exceptions, click here for details.
Query the viewing hotspot statistics for a single video by date range or time period. The interval from when playback behavior occurs to when data becomes queryable is 1–2 hours.
Unit Test
@Test
public void testQueryVideoViewingHotspotStatistics() throws IOException, NoSuchAlgorithmException {
VodQueryVideoViewingHotspotStatisticsRequest vodQueryVideoViewingHotspotStatisticsRequest =
new VodQueryVideoViewingHotspotStatisticsRequest();
List<VodQueryVideoViewingHotspotStatisticsResponse> vodQueryVideoViewingHotspotStatisticsResponseList = null;
try {
int year = new Date().getYear() + 1900;
vodQueryVideoViewingHotspotStatisticsRequest.setDr("7days")
.setVideoId("1b448be3234406608b7838c7ef6b597c_1")
//根据自己实际需要传 Date 即可
.setStartTime(super.getDate(year, 2, 18))
//根据自己实际需要传 Date 即可
.setEndTime(super.getDate(year, 2, 24));
vodQueryVideoViewingHotspotStatisticsResponseList =
new VodDataStatisticsServiceImpl().queryVideoViewingHotspotStatistics(
vodQueryVideoViewingHotspotStatisticsRequest);
Assert.assertNotNull(vodQueryVideoViewingHotspotStatisticsResponseList);
if (vodQueryVideoViewingHotspotStatisticsResponseList != null) {
log.debug("测试查询单个视频的观看热点统计数据成功,{}",
JSON.toJSONString(vodQueryVideoViewingHotspotStatisticsResponseList));
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Test Description
If the request is correct, a
VodQueryVideoViewingHotspotStatisticsResponseobject is returned, and the B-side processes business logic based on this object.If request parameter validation fails, a
PloyvSdkExceptionis thrown. For error details, refer toPloyvSdkException.getMessage(), e.g., [ Validation failed for input parameter [xxx.chat.VodxxxRequest] object, failed field [pic cannot be empty / msg cannot be empty] ]The server encountered an exception and threw a PloyvSdkException. For error details, see PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| videoId | true | String | Video ID [corresponds to the vid field in the API documentation] |
| dr | false | String | Time period, specific values are as follows: today, yesterday, this_week, last_week, 7days, this_month, last_month, this_year, last_year. Default value is 7days: last 7 days |
| startTime | false | Date | Query start date, format is yyyy-MM-dd [corresponds to the start field in the API documentation] |
| endTime | false | Date | Query end date, format is yyyy-MM-dd [corresponds to the end field in the API documentation] |
Return Object Description
The return object is List<VodQueryVideoViewingHotspotStatisticsResponse>. The specific elements of VodQueryVideoViewingHotspotStatisticsResponse are as follows:
| Parameter | Type | Description |
|---|---|---|
| second | Integer | Video duration (in seconds) |
| viewCount | Integer | View count [corresponds to the viewcount field in the API documentation] |
12. Query Video Viewing Ratio Statistics
Description
通过视频id或时间范围查询视频的观看比例统计数据
接口地址(仅做说明使用):https://api.polyv.net/v2/play-ratio/%s
Call Constraints
The API call is subject to rate limits. See details. For common call exceptions, see details.
Query the viewing ratio statistics for a single video or all videos within a specific time range. The interval from when the playback behavior occurs to when the data becomes queryable is 1 to 2 hours.
Unit Test
@Test
public void testQueryVideoViewingRatioStatistics() throws IOException, NoSuchAlgorithmException {
VodQueryVideoViewingRatioStatisticsRequest vodQueryVideoViewingRatioStatisticsRequest =
new VodQueryVideoViewingRatioStatisticsRequest();
List<VodQueryVideoViewingRatioStatisticsResponse> vodQueryVideoViewingRatioStatisticsResponseList = null;
try {
vodQueryVideoViewingRatioStatisticsRequest.setDr("7days");
vodQueryVideoViewingRatioStatisticsResponseList =
new VodDataStatisticsServiceImpl().queryVideoViewingRatioStatistics(
vodQueryVideoViewingRatioStatisticsRequest);
Assert.assertNotNull(vodQueryVideoViewingRatioStatisticsResponseList);
if (vodQueryVideoViewingRatioStatisticsResponseList != null) {
log.debug("测试查询视频的观看比例统计数据成功,{}", JSON.toJSONString(vodQueryVideoViewingRatioStatisticsResponseList));
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Test Description
If the request is correct, a
VodQueryVideoViewingRatioStatisticsResponseobject is returned, and the B-side processes the business logic based on this object.If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message can be found viaPloyvSdkException.getMessage(), for example: [ Input parameter [xxx.chat.VodxxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty] ]The server encountered an exception and threw a PloyvSdkException. For error details, see PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| videoId | false | String | Video ID. If not provided, the query is at the user dimension [corresponds to the vid field in the API documentation]. |
| dr | false | String | Time range. Specific values are as follows: today, yesterday, this_week, last_week, 7days, this_month, last_month, this_year, last_year. Default value is 7days: last 7 days. |
| startTime | false | Date | Query start date, format is yyyy-MM-dd [corresponds to the start field in the API documentation]. |
| endTime | false | Date | Query end date, format is yyyy-MM-dd [corresponds to the end field in the API documentation]. |
Return Object Description
The return object is List<VodQueryVideoViewingRatioStatisticsResponse>. The specific elements of VodQueryVideoViewingRatioStatisticsResponse are as follows:
| Parameter Name | Type | Description |
|---|---|---|
| percentage | String | Viewing percentage range, unit: % e.g., 70-80 |
| playCount | Integer | Number of views |
13. Query Video Watch Completion Rate
Description
通过视频id和观众id查询视频观看完成度
接口地址(仅做说明使用):https://api.polyv.net/v2/video/engagement/%s/get
Call Constraints
The API call has a frequency limit. For details, please refer to [/vod/java/limit]. For common call exceptions, please refer to [/vod/java/exceptionDoc].
This interface allows you to check the cumulative viewing completion rate of a specific video for a particular viewer. Regardless of the terminal used or how many times the viewer watches, the interface returns the final aggregated completion rate. For example, if video A is 50 minutes long and the viewer uses a PC...
H5 watched from 0 to 20 minutes, used mobile H5 to watch from 10 to 30 minutes, and then used the app to watch from 40 to 50 minutes. The cumulative watch time is 20 + 20 + 10 = 50 minutes, but the video content watched is from 0 to 30 and
For the 40–50 portion. Although the cumulative watch time equals the video duration, the completion rate is (30+10)/50 = 80%.
Data is updated every other day.
This interface can only be used after contacting customer service to activate it.
Unit Test
@Test
public void testGetVideoViewingCompletion() throws IOException, NoSuchAlgorithmException {
VodGetVideoViewingCompletionRequest vodGetVideoViewingCompletionRequest =
new VodGetVideoViewingCompletionRequest();
Float vodGetVideoViewingCompletionResponse = null;
try {
vodGetVideoViewingCompletionRequest.setVideoId("1b448be3234406608b7838c7ef6b597c_1")
.setViewerId("1555313336634");
vodGetVideoViewingCompletionResponse = new VodDataStatisticsServiceImpl().getVideoViewingCompletion(
vodGetVideoViewingCompletionRequest);
Assert.assertNotNull(vodGetVideoViewingCompletionResponse);
if (vodGetVideoViewingCompletionResponse != null) {
log.debug("测试查询视频观看完成度成功,已完成进度比例{}", vodGetVideoViewingCompletionResponse);
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Test Description
If the request is correct, a Float object is returned, and the B-side processes business logic based on this object.
If request parameter validation fails, a
PloyvSdkExceptionis thrown. SeePloyvSdkException.getMessage()for error details, e.g., [ Validation failed for input parameter [xxx.chat.VodxxxRequest] object, failed field [pic cannot be empty / msg cannot be empty] ]The server encountered an exception and threw a PloyvSdkException. For error details, see PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| videoId | true | String | Video ID [corresponds to the vid field in the API documentation] |
| viewerId | true | String | Custom viewer ID, e.g., 1555313336634 |
Return Object Description
Progress percentage completed
14. Query Viewing Behavior List
Description
通过视频id或时间范围分页查询观看行为列表
接口地址(仅做说明使用):https://api.polyv.net/v2/advance/play/%s
Call Constraints
The API call has a frequency limit. For details, please refer to [/vod/java/limit]. For common call exceptions, please refer to [/vod/java/exceptionDoc].
For details on advanced analysis features, see: Video Advanced Analysis
Due to the large volume of data and high computational demands, the data analysis results will only be available for query the following day.
The query time span must not exceed 31 days;
When the request parameter
startTimehas a value butendTimeis empty, return data for 31 days after the start date.When the request parameter
startTimeis empty butendTimeis not empty, return data within the 31 days prior to the end date.When both request parameters
startTimeandendTimeare empty, return data from the last 31 days.This interface requires contacting customer service to activate before use.
Unit Test
@Test
public void testQueryViewingBehaviorList() throws IOException, NoSuchAlgorithmException {
VodQueryViewingBehaviorListRequest vodQueryViewingBehaviorListRequest =
new VodQueryViewingBehaviorListRequest();
VodQueryViewingBehaviorListResponse vodQueryViewingBehaviorListResponse = null;
try {
vodQueryViewingBehaviorListRequest.setStartTime(super.getDate(2021, 2, 1))
.setEndTime(super.getDate(2021, 2, 30))
.setVideoId("1b448be3234406608b7838c7ef6b597c_1")
.setPageSize(10);
vodQueryViewingBehaviorListResponse = new VodDataStatisticsServiceImpl().queryViewingBehaviorList(
vodQueryViewingBehaviorListRequest);
Assert.assertNotNull(vodQueryViewingBehaviorListResponse);
if (vodQueryViewingBehaviorListResponse != null) {
log.debug("测试分页查询观看行为列表成功{}", JSON.toJSONString(vodQueryViewingBehaviorListResponse));
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Test Description
If the request is correct, a VodQueryViewingBehaviorListResponse object is returned, and the B-side processes business logic based on this object.
If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message can be found viaPloyvSdkException.getMessage(), for example: [ Input parameter [xxx.chat.VodxxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty] ]The server encountered an exception and threw a PloyvSdkException. For error details, see PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| videoId | false | String | Video ID [Corresponds to the vid field in the API documentation] |
| startTime | false | Date | Start time, format: yyyy-MM-dd or yyyy-MM-dd HH:mm:ss, query range does not exceed 31 days [Corresponds to the start field in the API documentation] |
| endTime | false | Date | End time, format: yyyy-MM-dd or yyyy-MM-dd HH:mm:ss, query range does not exceed 31 days [Corresponds to the end field in the API documentation] |
| viewerId | false | String | Viewer ID, e.g., 1555313336634 |
| viewerName | false | String | Viewer nickname |
| token | false | String | Token for the next page, obtained from the current page's response data; not required for the first page |
| pageSize | false | Integer | Number of data entries displayed per page, default is 20 entries per page |
Return Object Description
| Parameter | Type | Description |
|---|---|---|
| contents | Array | Returned result set [See ViewingBehaviorInfo parameter description] |
| token | String | Credential passed when querying the next page |
| pageSize | Integer | Number of data items displayed per page, default is 20 items per page |
| currentPage | Integer | Current page [Corresponds to the pageNumber field in the API documentation] |
| totalItems | Integer | Total number of records |
| totalPage | Integer | Total number of pages [Corresponds to the totalPages field in the API documentation] |
ViewingBehaviorInfo Parameter Description
| Parameter Name | Type | Description |
|---|---|---|
| startTime | Date | First viewing date, format yyyy-MM-dd HH:mm:ss e.g., 2019-10-01 11:12:05 |
| videoId | String | Video ID |
| videoName | String | Video name |
| videoImage | String | Video thumbnail (without protocol header) |
| videoDuration | Integer | Video duration, in seconds |
| deviceClass | String | Device name |
| osName | String | Operating system |
| agentName | String | Client name |
| agentVersion | String | Client version |
| referer | String | Referrer |
| ip | String | IP address |
| country | String | Country |
| province | String | Province |
| city | String | City |
| isp | String | ISP |
| viewerId | String | Viewer ID |
| viewerNickName | String | Viewer nickname |
| viewerAvatar | String | Viewer avatar |
| totalVideoCount | Integer | Total number of videos watched by the viewer |
| heatmap | String | Heatmap (["0-1:1","3-4:2"] indicates 1 view from 0 to 1 second, 2 views from 3 to 4 seconds) |
| completionRate | Float | Viewing completion rate |
| status | Integer | Video status: 60/61 Published; 10 Waiting for encoding; 20 Encoding; 50 Waiting for review; 51 Review failed; -1 Deleted; |
15. Query Video Analysis Data
Description
通过视频id查询视频分析数据
接口地址(仅做说明使用):https://api.polyv.net/v2/advance/video/%s
Call Constraints
The API call is subject to frequency limits. For details, please refer to [/vod/java/limit]. For common call exceptions, please refer to [/vod/java/exceptionDoc].
For details on advanced analysis features, see: Video Advanced Analysis
Due to the large volume of data and high computational demands, the data analysis results will only be available for query the following day.
This interface requires contacting customer service to activate before use.
Unit Test
@Test
public void testQueryVideoAnalysisData() throws IOException, NoSuchAlgorithmException {
VodQueryVideoAnalysisDataRequest vodQueryVideoAnalysisDataRequest = new VodQueryVideoAnalysisDataRequest();
VodQueryVideoAnalysisDataResponse vodQueryVideoAnalysisDataResponse = null;
try {
vodQueryVideoAnalysisDataRequest.setVideoId("1b448be3234406608b7838c7ef6b597c_1");
vodQueryVideoAnalysisDataResponse = new VodDataStatisticsServiceImpl().queryVideoAnalysisData(
vodQueryVideoAnalysisDataRequest);
Assert.assertNotNull(vodQueryVideoAnalysisDataResponse);
if (vodQueryVideoAnalysisDataResponse != null) {
log.debug("测试根据视频id查询视频分析数据成功{}", JSON.toJSONString(vodQueryVideoAnalysisDataResponse));
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Test Description
If the request is correct, a VodQueryVideoAnalysisDataResponse object is returned, and the B-side processes business logic based on this object.
If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message can be found inPloyvSdkException.getMessage(), for example: [ Input parameter [xxx.chat.VodxxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty] ]The server encountered an exception and threw a PloyvSdkException. For error details, see PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| videoId | true | String | Video ID [corresponds to the vid field in the API documentation] |
Return Object Description
| Parameter Name | Type | Description |
|---|---|---|
| videoId | String | Video ID |
| videoName | String | Video name |
| duration | Integer | Video duration, in seconds |
| playTimes | Integer | Number of plays |
| uniqueViewerCount | Integer | Number of unique viewers |
| avgCompletionRate | Float | Average completion rate |
| viewHeatmap | String | View heatmap, e.g., ["0-20:662","21-100:665"] indicates 662 views for seconds 0-20 and 665 views for seconds 21-100 of the video content |
| uniqueViewHeatmap | String | Unique view heatmap, e.g., ["0-20:614","21-100:615"] indicates 614 viewers for seconds 0-20 and 615 viewers for seconds 21-100 of the video content |
16. Query Audience Analysis Results
Description
通过观众id查询观众分析结果
接口地址(仅做说明使用):https://api.polyv.net/v2/advance/viewer/%s
Call Constraints
The API call has a frequency limit. For details, please refer to [/vod/java/limit]. For common call exceptions, please refer to [/vod/java/exceptionDoc].
This interface can only be used after contacting customer service to activate it.
For details on advanced analysis features, see: Video Advanced Analysis
Due to the large volume of data and high computational demands, the data analysis results will only be available for query the next day.
This interface can only be used after contacting customer service to activate it.
Unit Test
@Test
public void testQueryAudienceAnalysisResults() throws IOException, NoSuchAlgorithmException {
VodQueryAudienceAnalysisResultsRequest vodQueryAudienceAnalysisResultsRequest =
new VodQueryAudienceAnalysisResultsRequest();
VodQueryAudienceAnalysisResultsResponse vodQueryAudienceAnalysisResultsResponse = null;
try {
vodQueryAudienceAnalysisResultsRequest.setViewerId("1555313336634");
vodQueryAudienceAnalysisResultsResponse = new VodDataStatisticsServiceImpl().queryAudienceAnalysisResults(
vodQueryAudienceAnalysisResultsRequest);
Assert.assertNotNull(vodQueryAudienceAnalysisResultsResponse);
if (vodQueryAudienceAnalysisResultsResponse != null) {
log.debug("测试根据观众id查询观众分析结果成功{}", JSON.toJSONString(vodQueryAudienceAnalysisResultsResponse));
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Test Description
If the request is correct, a VodQueryAudienceAnalysisResultsResponse object is returned, and the B-side processes business logic based on this object.
If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message can be found viaPloyvSdkException.getMessage(), for example: [ Input parameter [xxx.chat.VodxxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty] ]The server encountered an exception and threw a PloyvSdkException. For error details, see PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| viewerId | true | String | Viewer ID, e.g., 1555313336634 |
Return Object Description
| Parameter Name | Type | Description |
|---|---|---|
| userId | String | User ID |
| viewerId | String | Viewer ID |
| viewerNickName | String | Viewer nickname |
| viewerAvatar | String | Viewer avatar [corresponds to the viewerAatar field in the API documentation] |
| ip | String | IP address |
| firstWatchTime | Date | First watch time, format yyyy-MM-dd HH:mm:ss |
| lastWatchTime | Date | Last watch time, format yyyy-MM-dd HH:mm:ss |
| totalVideoCount | Integer | Total number of videos watched |
| totalWatchDuration | Integer | Total viewer duration (seconds) |
| avgCompletionRate | Float | Average watch completion rate |
