Query Background Channel Statistics
Updated: 2025-08-29 14:14:25
API Description
1、查询后台频道统计信息
2、接口支持https协议
API URL
http://api.polyv.net/live/v4/channel/statistics/channel-statistic
Request Method
GET
API Constraints
- The API supports both HTTP and HTTPS. HTTPS is recommended for security. API calls have frequency limits. See details
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| appId | true | String | Account appId See Get Secret Key |
| timestamp | true | String | Current 13-digit millisecond timestamp, valid for 3 minutes |
| sign | true | String | Signature, a 32-character uppercase MD5 value. The appSecret key used to generate the signature is critical for communication data security. It must not be stored or used directly on the client. All APIs must be called through the customer's own server to relay requests to the POLYV server for response data. See Signature Generation Rules |
| channelId | true | String | Channel ID |
| endDate | true | String | End date, format: yyyy-MM-dd |
| startDate | true | String | Start date, format: yyyy-MM-dd |
Example
https://api.polyv.net/live/v4/channel/statistics/channel-statistic?appId=frlr1zazn3&sign=739AE57DEEFD537131C7F30E85A35480&channelId=3346714&startDate=2023-07-01&endDate=2023-07-10×tamp=1689046365000
Response Parameter Description
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Status code, same as HTTP status code, used to determine basic response status |
| data | Object | Channel statistics view object See Data Parameter Description |
| error | Object | Error information when status code is not 200 See Error Parameter Description |
| requestId | String | Request ID, a unique UUID generated for each request, only for troubleshooting and debugging, should not be tied to business logic |
| status | String | Response result, determined by business logic. Returns success on success, error on failure |
| success | Boolean | Whether the response was successful |
Data Parameter Description
| Parameter | Type | Description |
|---|---|---|
| averagePlayDuration | Integer | Average watch time per person, calculated as (watch duration / number of viewers by IP) rounded down, unit: minutes |
| averageTime | Float | Average watch count per person, calculated as (watch count / number of viewers by IP) * 10, rounded down, then 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 by viewerId) |
| playDuration | Integer | Watch duration, unit: minutes |
| plays | Integer | Number of views |
| uniqueVisitor | Integer | Number of unique visitors |
| statisticsByViewer | String | Whether to calculate average watch time and count by viewerId. Y for yes, N for no |
| averagePlayDurationByViewer | Integer | Average watch time per person, calculated as (watch duration / number of viewers by viewers) rounded down, unit: minutes |
| averageTimeByViewer | Float | Average watch count per person, calculated as (watch count / number of viewers by viewers) * 10, rounded down, then divided by 10, resulting in one decimal place, unit: times |
Error Parameter Description
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Error code, used to determine the specific error reason |
| desc | String | Error description, corresponding to error.code |
Java Request Example
For quick integration of basic code, please download the relevant dependency source code. Click here to download the source code. After downloading, add it to your own source code project. The test cases include HttpUtil.java and LiveSignUtil.java in the downloaded file.
It is strongly recommended to use the Live Java SDK for API integration. The Live Java SDK provides unified encapsulation and optimization for API call logic, exception handling, data signing, and HTTP request thread pools.
private static final Logger log = LoggerFactory.getLogger(getClass());
/**
* 查询后台频道统计信息
* @throws IOException
* @throws NoSuchAlgorithmException
*/
@Test
public void statisticsChannelStatisticTest() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId = super.appId;
String appSecret = super.appSecret;
String timestamp = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/live/v4/channel/statistics/channel-statistic";
String channelId = "";
String endDate = "";
String startDate = "";
//http 调用逻辑
Map<String, String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("channelId", channelId);
requestMap.put("endDate", endDate);
requestMap.put("startDate", startDate);
requestMap.put("timestamp", timestamp);
requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
String response = HttpUtil.get(url, requestMap);
log.info("测试查询后台频道统计信息成功:{}", response);
//do somethings
}
Response Example
For global system error descriptions, see Global Error Description
Success Example
{
"code": 200,
"status": "success",
"requestId": "a5f8e520709b454f9741570aee9625c1.74.16890463649665219",
"data": {
"uniqueVisitor": 23,
"plays": 71,
"playDuration": 928,
"ips": 24,
"averagePlayDuration": 38,
"averageTime": 2.9
},
"success": true
}
Error Example
{
"code": 400,
"status": "error",
"requestId": "d310b70bc329403f87f77f9203d50f89.128.16360831552223589",
"error": {
"code": 20001,
"desc": "application not found."
},
"success": false
}
