Polyv Help Center

Help Center

Query Live Viewing Details for a Channel Over a Period

Updated: 2025-07-30 10:13:32

API Description

1、通过频道号获取该频道某段时间的直播观看的统计数据
2、接口URL中的{channelId}为频道号
3、接口支持https协议

API URL

http://api.polyv.net/live/v2/statistics/{channelId}/summary

Online API Call

Request Method

GET

API Constraints

  1. 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 Long 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 side. 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
startDay true String Start date, format: yyyy-MM-dd
endDay true String End date, format: yyyy-MM-dd

Example

http://api.polyv.net/live/v2/statistics/1965681/summary?startDay=2020-1-1&appId=frlr1zazn3&endDay=2020-5-11&sign=311D8B0532DC5BC3F75CE25F4A9EF36A&timestamp=1621842602591

Response Parameter Description

Field Type Description
status String Status value
result Array Corresponding result See Result Parameter Description
Result Parameter Description
Parameter Type Description
currentDay String Query date, format: yyyy-MM-dd
channelId String Channel ID
userId String Live account ID
pcPlayDuration Integer PC playback duration, unit: minutes
pcVideoView Integer Total PC views, similar to PV
mobilePlayDuration Integer Mobile playback duration, unit: minutes
mobileVideoView Integer Total mobile views, similar to PV
mobileUniqueViewer Integer Unique mobile viewers, similar to UV
createdTime Long Record creation time, 13-digit millisecond timestamp
lastModified Long Record modification time, 13-digit millisecond timestamp
creatorId String Sub-account user ID that created the account (empty if created by the main account)
creatorName String Sub-account name that created the channel (displays "Main Account" if created by the main account)

Java Request Example

For quick integration of basic code, please download the relevant dependency source code. Click to download source code. After downloading, add it to your own source 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(ChannelViewDataTest.class);
/**
 * 查询频道某段时间的直播观看详情数据
 * @throws IOException
 */
@Test
public void testSummary() throws IOException, NoSuchAlgorithmException {
    //公共参数,填写自己的实际参数
    String appId = super.appId;
    String appSecret = super.appSecret;
    String userId = super.userId;
    String timestamp = String.valueOf(System.currentTimeMillis());
    //业务参数
    String url = String.format("http://api.polyv.net/live/v2/statistics/%s/summary","1965681");
    String startDay = "2020-1-1";
    String endDay = "2020-5-11";

    //http 调用逻辑
    Map<String,String> requestMap = new HashMap<>();
    requestMap.put("appId", appId);
    requestMap.put("timestamp",timestamp);
    requestMap.put("startDay",startDay);
    requestMap.put("endDay",endDay);
    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

{
    "status":"success",
    "result":[
        {
            "currentDay":"2020-10-20",
            "channelId":1965681,
            "userId":"1b448be323",
            "pcPlayDuration":7,
            "pcVideoView":7,
            "pcUniqueViewer":1,
            "mobilePlayDuration":0,
            "mobileVideoView":0,
            "mobileUniqueViewer":0,
            "createdTime":1603218100000,
            "lastModified":1603218100000,
            "creatorId":"1b448be323",
            "creatorName":"主账号"
        },
        {
            "currentDay":"2020-10-26",
            "channelId":1965681,
            "userId":"1b448be323",
            "pcPlayDuration":17,
            "pcVideoView":12,
            "pcUniqueViewer":1,
            "mobilePlayDuration":2,
            "mobileVideoView":1,
            "mobileUniqueViewer":1,
            "createdTime":1603736505000,
            "lastModified":1603736505000,
            "creatorId":"1b448be323",
            "creatorName":"主账号"
        },
        {
            "currentDay":"2020-11-12",
            "channelId":1965681,
            "userId":"1b448be323",
            "pcPlayDuration":1,
            "pcVideoView":1,
            "pcUniqueViewer":1,
            "mobilePlayDuration":0,
            "mobileVideoView":0,
            "mobileUniqueViewer":0,
            "createdTime":1605205271000,
            "lastModified":1605205271000,
            "creatorId":"1b448be323",
            "creatorName":"主账号"
        },
        {
            "currentDay":"2020-12-03",
            "channelId":1965681,
            "userId":"1b448be323",
            "pcPlayDuration":1,
            "pcVideoView":1,
            "pcUniqueViewer":1,
            "mobilePlayDuration":0,
            "mobileVideoView":0,
            "mobileUniqueViewer":0,
            "createdTime":1607019680000,
            "lastModified":1607019680000,
            "creatorId":"1b448be323",
            "creatorName":"主账号"
        }
    ]
}

Error Example

{
    "code":"invalid.request",
    "msg":"signature error."
}
联系客服,在线咨询