channelViewdata
1. Get the Historical Peak Concurrent Users in a Channel Within a Specific Time Range
Description
获取频道一定时间范围之内的历史最高并发人数,粒度可以支持到分钟
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/statistics/get-max-history-concurrent
Call Constraints
- The API call is subject to rate limits. Click here for details. For common call exceptions, click here for details.
Unit Testing
@Test
public void testGetMaxChannelHistoryConcurrent() throws Exception, NoSuchAlgorithmException {
LiveChannelMaxHistoryConcurrentRequest liveChannelMaxHistoryConcurrentRequest =
new LiveChannelMaxHistoryConcurrentRequest();
Integer liveChannelMaxHistoryConcurrentResponse;
try {
long nowTime = System.currentTimeMillis();
long startTime = nowTime - 30 * 24 * 60 * 60 * 1000l;
liveChannelMaxHistoryConcurrentRequest.setChannelId(createChannel())
.setStartTime(super.getDate(startTime))
.setEndTime(super.getDate(nowTime));
liveChannelMaxHistoryConcurrentResponse =
new LiveChannelViewdataServiceImpl().getMaxChannelHistoryConcurrent(
liveChannelMaxHistoryConcurrentRequest);
Assert.assertNotNull(liveChannelMaxHistoryConcurrentResponse);
if (liveChannelMaxHistoryConcurrentResponse != null) {
//to do something ......
log.debug("测试获取频道一定时间范围之内的历史最高并发人数成功,并发人数为:{}", liveChannelMaxHistoryConcurrentResponse);
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage(),B
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, an Integer 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.LivexxxRequest] 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 |
|---|---|---|---|
| channelId | true | String | Channel ID |
| startTime | true | Date | Start time |
| endTime | true | Date | End time |
| appId | false | String | POLYV user APP_ID, required when calling with multiple accounts (i.e., when initMultiAccount() has been called to set up multi-account invocation). Obtain it by registering on the POLYV official website: Official website -> Login -> Live Streaming (Development Settings) |
| appSecret | false | String | POLYV user APP_SECRET, required when calling with multiple accounts (i.e., when initMultiAccount() has been called to set up multi-account invocation). Obtain it by registering on the POLYV official website: Official website -> Login -> Live Streaming (Development Settings) |
Return Object Description
Return the maximum number of concurrent users within the specified time range.
2. Paginated Retrieval of Co-connection Usage Details
Description
分页获取连麦情况使用详情
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/statistics/mic/list
Call Constraints
- The API call is subject to rate limits. For details, please refer to [/live/java/limit.md]. For common call exceptions, please refer to [/live/java/exceptionDoc].
Unit Testing
@Test
public void testListChannelMic() throws Exception, NoSuchAlgorithmException {
LiveListChannelMicRequest liveListChannelMicRequest = new LiveListChannelMicRequest();
LiveListChannelMicResponse liveListChannelMicResponse;
try {
liveListChannelMicRequest.setChannelIds("1951952,1958888")
.setStartDay(getDate(2020, 1, 1))
.setEndDay(getDate(2020, 11, 11));
liveListChannelMicResponse = new LiveChannelViewdataServiceImpl().listChannelMic(liveListChannelMicRequest);
Assert.assertNotNull(liveListChannelMicResponse);
if (liveListChannelMicResponse != null) {
//to do something ......
log.debug("测试分页获取连麦情况使用详情成功,{}", JSON.toJSONString(liveListChannelMicResponse));
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage(),B
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, a
LiveListChannelMicResponseobject is returned, and Party B 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.LivexxxRequest] object validation failed, failed fields: [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 |
|---|---|---|---|
| channelIds | false | String | Channel IDs, separated by commas, e.g., 100000,100001 |
| startDay | false | Date | Start time, format: yyyy-MM-dd |
| endDay | false | Date | End time, format: yyyy-MM-dd |
| currentPage | false | Integer | Page number, defaults to 1 (corresponds to the page field in the API documentation) |
| pageSize | false | Integer | Number of data items displayed per page, defaults to 20 (corresponds to the size field in the API documentation) |
| appId | false | String | POLYV user APP_ID, required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account calls). Obtain it by registering on the Polyv official website: Official Website -> Login -> Live Streaming (Development Settings) |
| appSecret | false | String | POLYV user APP_SECRET, required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account calls). Obtain it by registering on the Polyv official website: Official Website -> Login -> Live Streaming (Development Settings) |
Return Object Description
| Parameter | Type | Description |
|---|---|---|
| contents | Array | List information [See ChannelMic parameter description] |
| 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] |
ChannelMic Parameter Description
| Parameter | Type | Description |
|---|---|---|
| userId | String | User ID |
| channelId | String | Channel ID |
| currentDay | Date | Current day, e.g., 2019-10-25 |
| history | Integer | Minutes of co-hosting used, unit: minutes |
3. Paginated Query of Channel Viewing Logs
Description
分页查询频道观看日志
接口地址(仅做说明使用):https://api.polyv.net/live/v2/statistics/%s/viewlog
Call Constraints
The API call has a frequency limit. See details. For common call exceptions, see details.
To query records for a time period, pass
startTimeandendTime(both must be within the same month). To query records for a specific day, passcurrentDay.startTime,endTime, andcurrentDaycannot all be omitted.If
currentDayis passed together withstartTimeandendTime, the values ofstartTimeandendTimewill be used.
Unit Test
@Test
public void testListChannelViewlog() throws Exception, NoSuchAlgorithmException {
LiveListChannelViewlogRequest liveListChannelViewlogRequest = new LiveListChannelViewlogRequest();
LiveListChannelViewlogResponse liveListChannelViewlogResponse;
try {
liveListChannelViewlogRequest.setChannelId(createChannel()).setCurrentDay(getDate(2020, 11, 3));
liveListChannelViewlogResponse = new LiveChannelViewdataServiceImpl().listChannelViewlog(
liveListChannelViewlogRequest);
Assert.assertNotNull(liveListChannelViewlogResponse);
if (liveListChannelViewlogResponse != null) {
//to do something ......
log.debug("测试分页查询频道观看日志成功,{}", JSON.toJSONString(liveListChannelViewlogResponse));
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage(),B
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
LiveListChannelViewlogResponseobject 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.LivexxxRequest] object validation failed, failed fields: [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 |
|---|---|---|---|
| channelId | true | String | Channel ID |
| currentDay | false | Date | Query date, format: yyyy-MM-dd |
| startTime | false | Date | Query start time |
| endTime | false | Date | Query end time |
| viewerId | false | String | Viewer user ID [corresponds to the param1 field in the API documentation] |
| viewerName | false | String | Viewer user name [corresponds to the param2 field in the API documentation] |
| logType | false | String | Viewing log type, value vod indicates watching replay, value live indicates live streaming [corresponds to the param3 field in the API documentation] |
| viewLogType | false | String | Live/VOD log type, default is livevod: Query viewing data for VOD listlive: Query viewing data for live or replay list |
| sessionIds | false | String | Session IDs, multiple sessions separated by commas |
| 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 items per page, default is 20 items per page |
| appId | false | String | POLYV user APP_ID, required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account calls). Obtained by registering on the POLYV official website: Official Website -> Login -> Live Streaming (Development Settings) |
| appSecret | false | String | POLYV user APP_SECRET, required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account calls). Obtained by registering on the POLYV official website: Official Website -> Login -> Live Streaming (Development Settings) |
Return Object Description
| Parameter | Type | Description |
|---|---|---|
| contents | Array | Channel viewing logs [See LiveChannelViewlog Parameter Description] |
| 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] |
LiveChannelViewlog Parameter Description
| Parameter Name | Type | Description |
|---|---|---|
| playId | String | ID representing this playback action |
| userId | String | User ID |
| channelId | String | Channel number |
| playDuration | Integer | Playback duration, in seconds |
| stayDuration | Integer | Stay duration, in seconds |
| flowSize | Long | Traffic size |
| sessionId | String | Live session ID |
| viewerId | String | Viewer ID [corresponds to the param1 field in the API documentation] |
| viewerName | String | Viewer name, supports up to 64 characters [corresponds to the param2 field in the API documentation] |
| logType | String | Viewing type: value vod indicates watching a replay, value live indicates live streaming [corresponds to the param3 field in the API documentation] |
| 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 operator |
| referer | String | URL of the video playback page |
| userAgent | String | User device |
| operatingSystem | String | Operating system |
| browser | String | Browser |
| isMobile | String | Whether it is a mobile device, Y: mobile, N: non-mobile |
| currentDay | Date | Log query date |
| createdTime | Date | Log creation date, approximately the start time of the viewer watching the live stream, slightly slower than the actual viewing time. It is recommended to use createdTime + playDuration to obtain the viewing duration |
| lastModified | Date | Log update date |
| firstActiveTime | Date | Entry time |
| lastActiveTime | Date | Exit time |
4. Query Aggregated Statistics for Multiple Channels
Description
查询多个频道汇总的统计数据
接口地址(仅做说明使用):https://api.polyv.net/live/v2/statistics/%s/channel_summary
Call Constraints
- The API call is subject to rate limits. For details, please refer to [/live/java/limit.md]. For common call exceptions, please refer to [/live/java/exceptionDoc].
Unit Testing
@Test
public void testListChannelSummary() throws Exception, NoSuchAlgorithmException {
LiveListChannelSummaryRequest liveListChannelSummaryRequest = new LiveListChannelSummaryRequest();
LiveListChannelSummaryResponse liveListChannelSummaryResponse;
try {
liveListChannelSummaryRequest.setStartDate(getDate(2020, 01, 01))
.setEndDate(getDate(2020, 11, 11))
.setChannelIds("1951952,1958888");
liveListChannelSummaryResponse = new LiveChannelViewdataServiceImpl().listChannelSummary(
liveListChannelSummaryRequest);
Assert.assertNotNull(liveListChannelSummaryResponse);
if (liveListChannelSummaryResponse != null) {
//to do something ......
log.debug("测试查询多个频道汇总的统计数据成功,{}", JSON.toJSONString(liveListChannelSummaryResponse));
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage(),B
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
LiveListChannelSummaryResponseobject, based on which the B-side handles business logic.If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message can be found viaPloyvSdkException.getMessage(), for example: [ Input parameter [xxx.chat.LivexxxRequest] 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 |
|---|---|---|---|
| userId | false | String | POLYV user ID. This parameter is required for multi-account calls (i.e., when initMultiAccount() has been called to set up multi-account invocation). Obtain it by registering on the Polyv official website. Path: Official Website -> Login -> Live Streaming (Development Settings). |
| startDate | true | Date | The start date of the query, in the format yyyy-MM-dd. |
| endDate | true | Date | The end date of the query, in the format yyyy-MM-dd. |
| channelIds | false | String | The channel IDs to query. If not submitted, all channels are queried by default. Multiple channel IDs should be separated by commas, e.g., 105420,104400. |
| appId | false | String | POLYV user APP_ID. This parameter is required for multi-account calls (i.e., when initMultiAccount() has been called to set up multi-account invocation). Obtain it by registering on the Polyv official website. Path: Official Website -> Login -> Live Streaming (Development Settings). |
| appSecret | false | String | POLYV user APP_SECRET. This parameter is required for multi-account calls (i.e., when initMultiAccount() has been called to set up multi-account invocation). Obtain it by registering on the Polyv official website. Path: Official Website -> Login -> Live Streaming (Development Settings). |
Return Object Description
| Parameter Name | Type | Description |
|---|---|---|
| channelSummarys | Array | Statistical data [See ChannelSummary Parameter Description for details] |
ChannelSummary Parameter Description
| Parameter Name | Type | Description |
|---|---|---|
| channelId | String | Channel ID |
| name | String | Channel name |
| pcPlayDuration | Integer | PC playback duration, in minutes |
| pcFlowSize | Long | PC playback traffic, in bytes |
| pcVideoView | Integer | PC video views |
| pcUniqueViewer | Integer | PC unique viewers |
| mobilePlayDuration | Long | Mobile playback duration, in minutes |
| mobileFlowSize | Long | Mobile playback traffic, in bytes |
| mobileVideoView | Integer | Mobile video views |
| mobileUniqueViewer | Integer | Mobile unique viewers |
| livePcPlayDuration | Integer | PC live playback duration, in minutes |
| playbackPcPlayDuration | Long | PC replay playback duration, in minutes |
| liveMobilePlayDuration | Integer | Mobile live playback duration, in minutes |
| playbackMobilePlayDuration | Long | Mobile replay playback duration, in minutes |
| unknownPcPlayDuration | Integer | PC other playback duration, in minutes |
| unknownMobilePlayDuration | Integer | Mobile other playback duration, in minutes |
5. Query Real-Time Online Count for Multiple Channels
Description
查询多个频道的实时在线人数
接口地址(仅做说明使用):https://api.polyv.net/live/v2/statistics/get-realtime-viewers
Call Constraints
- The API call is subject to rate limits. Click here for details. For common call exceptions, click here for details.
Unit Testing
@Test
public void testListChannelViewerCount() throws Exception, NoSuchAlgorithmException {
LiveListChannelViewerCountRequest liveListChannelViewerCountRequest = new LiveListChannelViewerCountRequest();
LiveListChannelViewerCountResponse liveListChannelViewerCountResponse;
try {
liveListChannelViewerCountRequest.setChannelIds("1951952,1958888");
liveListChannelViewerCountResponse = new LiveChannelViewdataServiceImpl().listChannelViewerCount(
liveListChannelViewerCountRequest);
Assert.assertNotNull(liveListChannelViewerCountResponse);
if (liveListChannelViewerCountResponse != null) {
//to do something ......
log.debug("测试查询多个频道的实时在线人数成功,{}", JSON.toJSONString(liveListChannelViewerCountResponse));
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage(),B
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
LiveListChannelViewerCountResponseobject, based on which the B-side processes business logic.If request parameter validation fails, a
PloyvSdkExceptionis thrown. SeePloyvSdkException.getMessage()for error details, e.g., [ Validation failed for input parameter [xxx.chat.LivexxxRequest] 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 Name | Required | Type | Description |
|---|---|---|---|
| channelIds | true | String | Channel IDs, separated by commas, e.g., 100000,100001 |
| appId | false | String | POLYV user APP_ID, required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account calls). Obtained by registering on the Polyv official website: Official Website -> Login -> Live Streaming (Development Settings) |
| appSecret | false | String | POLYV user APP_SECRET, required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account calls). Obtained by registering on the Polyv official website: Official Website -> Login -> Live Streaming (Development Settings) |
Return Object Description
| Parameter Name | Type | Description |
|---|---|---|
| channelViewerCounts | Array | Real-time online viewer count for the channel [See ChannelViewerCount Parameter Description] |
ChannelViewerCount Parameter Description
| Parameter | Type | Description |
|---|---|---|
| channelId | String | Channel ID |
| time | String | Statistical time point (time format: 24H), e.g., 15:39:10 |
| count | String | Number of real-time viewers at a given time point |
6. Query Historical Concurrent Users of a Channel
Description
查询频道的历史并发人数
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/statistics/concurrence
Call Constraints
- The API call has a frequency limit. For details, please refer to [/live/java/limit.md]. For common call exceptions, please refer to [/live/java/exceptionDoc].
Unit Testing
@Test
public void testGetChannelViewerConcurrence() throws Exception, NoSuchAlgorithmException {
LiveChannelViewerConcurrenceRequest liveChannelViewerConcurrenceRequest =
new LiveChannelViewerConcurrenceRequest();
LiveChannelViewerConcurrenceResponse liveChannelViewerConcurrenceResponse;
try {
liveChannelViewerConcurrenceRequest.setChannelId(createChannel())
.setStartDate(getDate(2020, 10, 01))
.setEndDate(getDate(2020, 11, 11));
liveChannelViewerConcurrenceResponse = new LiveChannelViewdataServiceImpl().getChannelViewerConcurrence(
liveChannelViewerConcurrenceRequest);
Assert.assertNotNull(liveChannelViewerConcurrenceResponse);
if (liveChannelViewerConcurrenceResponse != null) {
//to do something ......
log.debug("测试查询频道的历史并发人数成功,{}", JSON.toJSONString(liveChannelViewerConcurrenceResponse));
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage(),B
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, a
LiveChannelViewerConcurrenceResponseobject 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.LivexxxRequest] object validation failed, failed fields [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 |
|---|---|---|---|
| channelId | true | String | Channel ID |
| startDate | true | Date | Start date format: yyyy-MM-dd. The time span between start date and end date: up to two months of data can be queried. |
| endDate | true | Date | End date format: yyyy-MM-dd. The time span between start date and end date: up to two months of data can be queried. |
| appId | false | String | POLYV user APP_ID. This parameter is required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account invocation). Obtain it by registering on the POLYV official website. Path: Official website -> Login -> Live Streaming (Development Settings). |
| appSecret | false | String | POLYV user APP_SECRET. This parameter is required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account invocation). Obtain it by registering on the POLYV official website. Path: Official website -> Login -> Live Streaming (Development Settings). |
Return Object Description
| Parameter Name | Type | Description |
|---|---|---|
| channelViewerConcurrences | Array | Concurrent online viewers in the channel [See ChannelViewerConcurrence Parameter Description] |
ChannelViewerConcurrence Parameter Description
| Parameter | Type | Description |
|---|---|---|
| day | Date | Date of statistics (time format: yyyy-MM-dd, e.g., 2019-04-10) |
| minute | String | Time point of statistics (time format: 12H, e.g., 10:30) |
| viewers | String | Number of real-time viewers at a given time point |
7. Query Live Streaming Session Data Within a Time Range
Description
查询时间内直播场次数据
接口地址(仅做说明使用):https://api.polyv.net/live/v4/statistics/session-stats/list
Call Constraints
The API call is subject to rate limits. For details, please refer to [/live/java/limit.md]. For common call exceptions, please refer to [/live/java/exceptionDoc].
When no query time range is specified, the default query returns session report data generated between the current time and one hour prior. The maximum interval for the query time range is 24 hours.
Unit Test
@Test
public void testGetLiveSession() throws IOException, NoSuchAlgorithmException {
LiveGetLiveSessionRequest liveGetLiveSessionRequest = new LiveGetLiveSessionRequest();
LiveGetLiveSessionResponse liveGetLiveSessionResponse;
try {
liveGetLiveSessionRequest.setStartTime(super.getDate(2021, 10, 16, 0, 31, 15));
liveGetLiveSessionRequest.setEndTime(super.getDate(2021, 10, 16, 20, 31, 15));
liveGetLiveSessionResponse = new LiveChannelViewdataServiceImpl().getLiveSession(liveGetLiveSessionRequest);
Assert.assertNotNull(liveGetLiveSessionResponse);
if (liveGetLiveSessionResponse != null) {
//to do something ......
log.debug("测试查询时间内直播场次数据成功{}", JSON.toJSONString(liveGetLiveSessionResponse));
}
} 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
LiveGetLiveSessionResponseobject 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.LivexxxRequest] 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 |
|---|---|---|---|
| startTime | false | Date | Start time |
| endTime | false | Date | End time |
| currentPage | false | Integer | Page number, defaults to 1 [corresponds to the pageNumber field in the API documentation] |
| pageSize | false | Integer | Number of data items displayed per page, defaults to 20 items per page |
| appId | false | String | POLYV user APP_ID, required when calling with multiple accounts (i.e., when initMultiAccount() has been called to set up multi-account invocation). Obtained by registering on the Polyv official website, path: Official website -> Login -> Live Streaming (Development Settings) |
| appSecret | false | String | POLYV user APP_SECRET, required when calling with multiple accounts (i.e., when initMultiAccount() has been called to set up multi-account invocation). Obtained by registering on the Polyv official website, path: Official website -> Login -> Live Streaming (Development Settings) |
Return Object Description
| Parameter | Type | Description |
|---|---|---|
| contents | Array | Live session data [see ChannelLiveSession parameter description] |
| 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] |
ChannelLiveSession Parameter Description
| Parameter | Type | Description |
|---|---|---|
| channelId | String | Channel ID |
| sessionId | String | Live session ID |
| name | String | Session name |
| startTime | Date | Live start time, format: yyyy-MM-dd HH:mm:ss |
| endTime | Date | Live end time, format: yyyy-MM-dd HH:mm:ss |
| userId | String | User ID |
8. Paginated Query of Account Live Streaming Viewing Details
Description
分页获取账号下所有频道观看详情数据
接口地址(仅做说明使用):https://api.polyv.net/live/v3/user/statistics/viewlog
Call Constraints
- The API call is subject to rate limits. For details, please refer to [/live/java/limit.md]. For common call exceptions, please refer to [/live/java/exceptionDoc].
Unit Testing
@Test
public void testGetChannelViewLog() throws IOException, NoSuchAlgorithmException {
LiveGetChannelViewLogRequest liveGetChannelViewLogRequest = new LiveGetChannelViewLogRequest();
LiveGetChannelViewLogResponse liveGetChannelViewLogResponse;
try {
String channelId = super.createChannel();
liveGetChannelViewLogRequest.setChannelId(channelId)
.setStartDate(super.getDate(1606924800000L))
.setEndDate(super.getDate(1607011200000L));
liveGetChannelViewLogResponse = new LiveChannelViewdataServiceImpl().getChannelViewLog(
liveGetChannelViewLogRequest);
Assert.assertNotNull(liveGetChannelViewLogResponse);
if (liveGetChannelViewLogResponse != null) {
//to do something ......
log.debug("测试分页查询账号直播观看详情数据成功 {}", JSON.toJSONString(liveGetChannelViewLogResponse));
}
} 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 Description
If the request is correct, a
LiveGetChannelViewLogResponseobject 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.LivexxxRequest] 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 |
|---|---|---|---|
| startDate | true | Date | Query start time, format: yyyy-MM-dd HH:mm:ss |
| endDate | true | Date | Query end time, format: yyyy-MM-dd HH:mm:ss |
| channelId | false | String | Channel ID; if not provided, all channels are queried |
| watchType | false | String | Watch type, live: live streaming, vod: playback |
| currentPage | false | Integer | Page number, defaults to 1 [corresponds to the page field in the API documentation] |
| pageSize | false | Integer | Number of data entries per page, defaults to 20 entries per page |
| appId | false | String | POLYV user APP_ID, required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account calls). Obtain it by registering on the Polyv official website: Official website -> Login -> Live Streaming (Development Settings) |
| appSecret | false | String | POLYV user APP_SECRET, required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account calls). Obtain it by registering on the Polyv official website: Official website -> Login -> Live Streaming (Development Settings) |
Return Object Description
| Parameter | Type | Description |
|---|---|---|
| contents | Array | List of viewing details data [see ViewLogList parameter description] |
| 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] |
ViewLogList Parameter Description
| Parameter Name | Type | Description |
|---|---|---|
| playId | String | ID representing this playback action |
| userId | String | POLYV user ID, consistent with the POLYV official website. Retrieval path: Official Website -> Login -> Live (Development Settings) |
| channelId | String | Channel number |
| playDuration | Integer | Playback duration, in seconds |
| stayDuration | Integer | Stay duration, in seconds |
| flowSize | Long | Traffic size, in bytes |
| sessionId | String | Live session ID |
| viewerId | String | Viewer ID using the POLYV watch page [corresponds to the param1 field in the API documentation] |
| viewerName | String | Viewer nickname using the POLYV watch page [corresponds to the param2 field in the API documentation] |
| logType | String | Watch log type, default is live vod: watching replay live: live streaming [corresponds to the param3 field in the API documentation] |
| 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 operator |
| 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 | Query date, format: yyyy-MM-dd |
| createdTime | Date | Log creation date, 13-digit millisecond timestamp |
| lastModified | Date | Log update date, 13-digit millisecond timestamp |
| pType | Integer | 1: No-delay viewing 0: Normal viewing [corresponds to the ptype field in the API documentation] |
| firstActiveTime | Date | Time of entering the page, may return null in some cases. Unless otherwise specified, use createdTime instead |
| lastActiveTime | Date | Time of leaving the page, may return null in some cases. Unless otherwise specified, use createdTime+stayDuration instead |
9. Query Multi-Session Overview Statistics for a Channel
Description
接口用于统计直播间内多场次的直播的观看数据,数据会根据场次号进行汇总,返回观看UV、观看PV等。
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/statistics/get-session-stats
Call Constraints
- The API call is subject to frequency limits. For details, please refer to [/live/java/limit.md]. For common call exceptions, please refer to [/live/java/exceptionDoc].
Unit Testing
@Test
public void testGetSessionStats() throws IOException, NoSuchAlgorithmException {
LiveGetSessionStatsRequest liveGetSessionStatsRequest = new LiveGetSessionStatsRequest();
LiveGetSessionStatsResponse liveGetSessionStatsResponse;
try {
String channelId = super.createChannel();
liveGetSessionStatsRequest.setChannelId(channelId)
.setStartTime(getDate(1610273359000L))
.setEndTime(getDate(1612001359000L));
liveGetSessionStatsResponse = new LiveChannelViewdataServiceImpl().getSessionStats(
liveGetSessionStatsRequest);
Assert.assertNotNull(liveGetSessionStatsResponse);
if (liveGetSessionStatsResponse != null) {
//to do something ......
log.debug("测试查询频道多场次概览统计数据成功 {}", JSON.toJSONString(liveGetSessionStatsResponse));
}
} 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, a
LiveGetSessionStatsResponseobject 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.LivexxxRequest] 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 |
|---|---|---|---|
| channelId | true | String | Channel ID |
| sessionIds | false | String | Session IDs, multiple sessions separated by commas, e.g., fw82mayhuy,fvipafupmh. Either session IDs or the live broadcast start and end times must be provided. When both session IDs and live broadcast start/end times are present, the session IDs are used for querying. |
| startTime | false | Date | Live broadcast start time. The interval between start time and end time must not exceed 30 days. |
| endTime | false | Date | Live broadcast end time. Either session IDs or the live broadcast start and end times must be provided. |
| appId | false | String | POLYV user APP_ID. Required for multi-account calls (i.e., when initMultiAccount() is invoked to set up multi-account calls). Obtained by registering on the POLYV official website: Official Website -> Login -> Live Broadcast (Development Settings). |
| appSecret | false | String | POLYV user APP_SECRET. Required for multi-account calls (i.e., when initMultiAccount() is invoked to set up multi-account calls). Obtained by registering on the POLYV official website: Official Website -> Login -> Live Broadcast (Development Settings). |
Return Object Description
| Parameter | Type | Description |
|---|---|---|
| list | Array | Viewing data list for multiple sessions within the live room [See ChannelSessionStats Parameter Description for details] |
ChannelSessionStats Parameter Description
| Parameter Name | Type | Description |
|---|---|---|
| channelId | String | Channel ID |
| sessionId | String | Session ID |
| name | String | Session name |
| startTime | Date | Session start time |
| endTime | Date | Session end time |
| duration | Integer | Live duration, in seconds |
| liveUV | Integer | Number of live viewers |
| livePV | Integer | Number of live views |
| playbackUV | Integer | Number of playback viewers |
| playbackPV | Integer | Number of playback views |
| totalPlayDuration | Integer | Total live viewing duration, in seconds |
| totalPlaybackDuration | Integer | Total playback viewing duration, in seconds |
10. Query Live Channel Viewing Details Within a Time Range
Description
通过频道号获取该频道某段时间的直播观看的统计数据
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/statistics/daily/summary
Call Constraints
- The API call is subject to rate limits. For details, please refer to [/live/java/limit.md]. For common call exceptions, please refer to [/live/java/exceptionDoc].
Unit Testing
@Test
public void testGetDailySummary() throws IOException, NoSuchAlgorithmException {
LiveDailySummaryRequest liveDailySummaryRequest = new LiveDailySummaryRequest();
List<LiveDailySummaryResponse> liveDailySummaryResponse;
try {
String channelId = super.createChannel();
liveDailySummaryRequest.setChannelId(channelId);
liveDailySummaryRequest.setStartDay(super.getDate(2021, 3, 01));
liveDailySummaryRequest.setEndDay(super.getDate(2021, 3, 30));
liveDailySummaryResponse = new LiveChannelViewdataServiceImpl().getDailySummary(liveDailySummaryRequest);
Assert.assertNotNull(liveDailySummaryResponse);
if (liveDailySummaryResponse != null) {
//to do something ......
log.debug("测试查询时间范围内频道直播观看详情数据成功 {}", JSON.toJSONString(liveDailySummaryResponse));
}
} 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
LiveDailySummaryResponseobject, 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.LivexxxRequest] 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 |
|---|---|---|---|
| channelId | true | String | Channel ID |
| startDay | true | Date | Start date, format: yyyy-MM-dd |
| endDay | true | Date | End date, format: yyyy-MM-dd |
| appId | false | String | POLYV user APP_ID, required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account calls). Obtained by registering on the POLYV official website: Official Website -> Login -> Live Streaming (Development Settings) |
| appSecret | false | String | POLYV user APP_SECRET, required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account calls). Obtained by registering on the POLYV official website: Official Website -> Login -> Live Streaming (Development Settings) |
Return Object Description
The return object is List<LiveDailySummaryResponse>. The specific elements of LiveDailySummaryResponse are as follows:
| Parameter Name | Type | Description |
|---|---|---|
| currentDay | Date | Query date |
| channelId | String | Channel ID |
| userId | String | Live streaming account ID |
| pcPlayDuration | Integer | PC playback duration, in minutes |
| pcVideoView | Integer | Total PC video views, similar to PV |
| pcUniqueViewer | Integer | Unique PC viewers, similar to UV |
| mobilePlayDuration | Integer | Mobile playback duration, in minutes |
| mobileVideoView | Integer | Total mobile video views, similar to PV |
| mobileUniqueViewer | Integer | Unique mobile viewers, similar to UV |
| createdTime | Date | Record creation time |
| lastModified | Date | Record last modified time |
| creatorId | String | Sub-account user ID of the creating account (empty if created by the main account) |
| creatorName | String | Sub-account name of the channel creator (displays "Main Account" if created by the main account) |
11. Query Channel Co-Streaming Details Data
Description
接口用于查询某个频道的一段时间区间内的连麦详情数据,支持分页
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/mic/log/list-detail
Call Constraints
- The API call has a frequency limit. For details, please refer to [/live/java/limit.md]. For common call exceptions, please refer to [/live/java/exceptionDoc].
Unit Testing
@Test
public void testListLinkMicDetail() throws IOException, NoSuchAlgorithmException {
LiveListLinkMicDetailRequest liveListLinkMicDetailRequest = new LiveListLinkMicDetailRequest();
LiveListLinkMicDetailResponse liveListLinkMicDetailResponse;
try {
String channelId = super.createChannel();
liveListLinkMicDetailRequest.setChannelId(channelId);
liveListLinkMicDetailRequest.setStartDate(super.getDate(2020, 11, 1));
liveListLinkMicDetailRequest.setEndDate(super.getDate(2020, 11, 03));
liveListLinkMicDetailResponse = new LiveChannelViewdataServiceImpl().listLinkMicDetail(
liveListLinkMicDetailRequest);
Assert.assertNotNull(liveListLinkMicDetailResponse);
if (liveListLinkMicDetailResponse != null) {
//to do something ......
log.debug("测试查询频道连麦详情数据成功 {}", JSON.toJSONString(liveListLinkMicDetailResponse));
}
} 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
LiveListLinkMicDetailResponseobject, based on which the B-side processes business logic.If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message can be found viaPloyvSdkException.getMessage(), for example: [ Input parameter [xxx.chat.LivexxxRequest] object validation failed, failed fields: [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 |
|---|---|---|---|
| channelId | true | String | Channel ID |
| startDate | true | Date | Start date, format: yyyy-MM-dd, e.g., 2020-10-01, time range must not exceed 30 days |
| endDate | true | Date | End date, format: yyyy-MM-dd, e.g., 2020-10-01, time range must not exceed 30 days |
| page | false | Integer | Current page number, defaults to 1 |
| pageSize | false | Integer | Number of records per page, defaults to 500, maximum 5000. For more than 5000 records, fetch in batches by incrementing page by 1 each time until the returned list contents is empty |
| appId | false | String | POLYV user APP_ID, required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account access). Obtain it by registering on the POLYV official website: Official Website -> Login -> Live Streaming (Development Settings) |
| appSecret | false | String | POLYV user APP_SECRET, required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account access). Obtain it by registering on the POLYV official website: Official Website -> Login -> Live Streaming (Development Settings) |
Return Object Description
| Parameter | Type | Description |
|---|---|---|
| page | Integer | Current page number, defaults to 1 |
| contents | Array | List of query results [See MicDetail Parameter Description for details] |
| pageSize | Integer | Number of data items displayed per page, defaults to 20 |
| 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] |
MicDetail Parameter Description
| Parameter | Type | Description |
|---|---|---|
| channelId | String | Channel ID |
| sessionId | String | Session ID |
| viewerId | String | Viewer ID |
| identity | String | Identity: guest (guest), student (student) |
| nickname | String | Nickname |
| joinTime | Date | Time of joining RTC, 13-digit millisecond timestamp |
| leaveTime | Date | Time of leaving RTC, 13-digit millisecond timestamp |
| duration | Integer | Duration of co-streaming (in minutes) |
12. Query Real-Time Concurrent Data of a Channel
Description
在直播中,查询频道实时在线人数
接口地址(仅做说明使用):https://api.polyv.net/live/v1/statistics/%s/realtime
Call Constraints
- The API call is subject to rate limits. For details, please refer to [/live/java/limit.md]. For common call exceptions, please refer to [/live/java/exceptionDoc].
Unit Testing
@Test
public void testGetRealviewers() throws IOException, NoSuchAlgorithmException {
LiveRealviewersRequest liveRealviewersRequest = new LiveRealviewersRequest();
List<LiveRealviewersResponse> liveRealviewersResponse;
try {
String channelId = super.createChannel();
liveRealviewersRequest.setChannelId(channelId);
liveRealviewersRequest.setUserId(LiveGlobalConfig.getUserId());
liveRealviewersResponse = new LiveChannelViewdataResultServiceImpl().getRealviewers(liveRealviewersRequest);
Assert.assertNotNull(liveRealviewersResponse);
if (liveRealviewersResponse != null) {
//to do something ......
log.debug("测试查询频道实时并发数据成功 {}", JSON.toJSONString(liveRealviewersResponse));
}
} 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, a
LiveRealviewersResponseobject is returned, and Party B 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.LivexxxRequest] 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 |
|---|---|---|---|
| userId | true | String | Live streaming account ID |
| channelId | true | String | Live streaming channel ID |
| appId | false | String | POLYV user APP_ID, required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account invocation). Obtained by registering on the POLYV official website. Path: Official website -> Login -> Live Streaming (Development Settings) |
| appSecret | false | String | POLYV user APP_SECRET, required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account invocation). Obtained by registering on the POLYV official website. Path: Official website -> Login -> Live Streaming (Development Settings) |
Return Object Description
The return object is List<LiveRealviewersResponse>. The specific elements of LiveRealviewersResponse are as follows:
| Parameter Name | Type | Description |
|---|---|---|
| time | String | Statistical time, format: HH:mm:ss |
| count | String | Real-time number of viewers at a given time |
13. Query Background Channel Statistics
Description
查询后台频道统计信息
接口地址(仅做说明使用):https://api.polyv.net/live/v4/channel/statistics/channel-statistic
Call Constraints
Unit Testing
@Test
public void testGetChannelStatistic() throws IOException, NoSuchAlgorithmException {
LiveChannelStatisticRequest liveChannelStatisticRequest = new LiveChannelStatisticRequest();
LiveChannelStatisticResponse liveChannelStatisticResponse;
try {
String channelId = super.createChannel();
liveChannelStatisticRequest.setChannelId(channelId)
.setStartDate(super.getDate(2023, 10, 1))
.setEndDate(super.getDate(2023, 10, 30));
liveChannelStatisticResponse = new LiveChannelViewdataServiceImpl().getChannelStatistic(
liveChannelStatisticRequest);
Assert.assertNotNull(liveChannelStatisticResponse);
if (liveChannelStatisticResponse != null) {
log.info("uniqueVisitor is "+ liveChannelStatisticResponse.getUniqueVisitor());
//to do something ......
log.debug("测试查询后台频道统计信息成功 {}", JSON.toJSONString(liveChannelStatisticResponse));
}
} 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, a
LiveChannelStatisticResponseobject 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.LivexxxRequest] 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 |
|---|---|---|---|
| channelId | true | String | Channel ID |
| startDate | true | Date | Query start date, format: yyyy-MM-dd |
| endDate | true | Date | Query end date, format: yyyy-MM-dd |
| appId | false | String | POLYV user APP_ID. This parameter is required for multi-account calls (i.e., when initMultiAccount() is invoked to set up multi-account calls). Obtain it by registering on the POLYV official website. Path: Official website -> Login -> Live Streaming (Development Settings) |
| appSecret | false | String | POLYV user APP_SECRET. This parameter is required for multi-account calls (i.e., when initMultiAccount() is invoked to set up multi-account calls). Obtain it by registering on the POLYV official website. Path: Official website -> Login -> Live Streaming (Development Settings) |
Return Object Description
| Parameter Name | Type | Description |
|---|---|---|
| averagePlayDuration | Integer | Average watch time, calculated as (total watch time / number of viewers) rounded down, unit: minutes |
| averageTime | Float | Average number of views per person, calculated as (total views / number of viewers) * 10, then rounded down and divided by 10, resulting in one decimal place, unit: times |
| ips | Integer | Number of viewers (deduplicated by IP address) |
| viewers | Integer | Number of viewers (calculated based on viewerId) |
| playDuration | Integer | Total watch time, unit: minutes |
| plays | Integer | Number of views |
| uniqueVisitor | Integer | Number of unique visitors |
14. Query Account Viewing History
Description
查询账号观看记录
接口地址(仅做说明使用):https://api.polyv.net/live/v4/user/viewlog/list
Call Constraints
- The API call is subject to rate limits. For details, please refer to [/live/java/limit.md]. For common call exceptions, please refer to [/live/java/exceptionDoc].
Unit Testing
@Test
public void testGetViewLogList() throws IOException, NoSuchAlgorithmException {
LiveListAccountViewlogRequest liveListAccountViewlogRequest = new LiveListAccountViewlogRequest();
LiveListAccountViewlogResponse liveListAccountViewlogResponse;
try {
liveListAccountViewlogRequest
.setStartDate(super.getDate(2023, 10, 1))
.setEndDate(super.getDate(2023, 10, 30));
liveListAccountViewlogResponse = new LiveChannelViewdataServiceImpl().listAccountViewlog(
liveListAccountViewlogRequest);
Assert.assertNotNull(liveListAccountViewlogResponse);
if (liveListAccountViewlogResponse != null) {
//to do something ......
log.debug("测试查询账号观看记录成功 {}", JSON.toJSONString(liveListAccountViewlogResponse));
}
} 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, a
LiveListAccountViewlogResponseobject 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.LivexxxRequest] object validation failed, failed fields: [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 |
|---|---|---|---|
| startDate | false | Date | The start date of the query. If not provided, the current month is queried. Format: yyyy-MM-dd |
| endDate | false | Date | The end date of the query. Must be in the same month as the start date. Format: yyyy-MM-dd |
| viewerId | false | String | Viewer ID |
| channelId | false | String | Channel ID |
| currentPage | false | Integer | Page number, defaults to 1 [Corresponds to the page field in the API documentation] |
| pageSize | false | Integer | Number of data items displayed per page, defaults to 20 items per page |
| appId | false | String | POLYV user APP_ID. Required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account calls). Obtained by registering on the Polyv official website. Path: Official website -> Login -> Live Streaming (Development Settings) |
| appSecret | false | String | POLYV user APP_SECRET. Required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account calls). Obtained by registering on the Polyv official website. Path: Official website -> Login -> Live Streaming (Development Settings) |
Return Object Description
| Parameter | Type | Description |
|---|---|---|
| contents | Array | Query result list [see ViewlogDetail parameter description] |
| pageSize | Integer | Number of data items displayed per page, default is 20 |
| 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] |
ViewlogDetail Parameter Description
| Parameter Name | Type | Description |
|---|---|---|
| avgDuration | String | Average watch duration |
| nick | String | Nickname |
| totalDuration | String | Total watch duration |
| viewCount | Integer | Number of views |
| viewerId | String | User ID |
| param4 | String | Custom parameter param4 |
| param5 | String | Custom parameter param5 |
