Polyv Help Center

Help Center

Paginated Query of Account Live Streaming Viewing Details

Updated: 2025-08-29 14:14:25

API Description

1、分页获取账号下所有频道观看详情数据
2、接口支持https协议
3、直播观看详情数据支持查询最近3年内的历史数据,建议将历史数据导出到本地储存,以便后续查询。

API URL

http://api.polyv.net/live/v3/user/statistics/viewlog

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

  2. To query records for a time period, pass: startDate, endDate (startDate and endDate must be within the same month).

  3. Viewing duration data has a 3-5 minute delay.

Request Parameter Description

Parameter Required Type Description
appId true String Account appId See details on obtaining keys
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 never 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
startDate true String Query start time, format: yyyy-MM-dd HH:mm:ss
endDate true String Query end time, format: yyyy-MM-dd HH:mm:ss
channelId false String Channel ID. Leave empty to query all channels.
watchType false String Viewing type,
live: live stream,
vod: replay
page false String Current page number, defaults to 1
pageSize false String Number of records per page, defaults to 1000

Example

http://api.polyv.net/live/v3/user/statistics/viewlog?endDate=2022-03-28+09%3A55%3A56&appId=frlr1zazn3&sign=B808C92E6EC692D0210704C5AF93063D&watchType=live&startDate=2022-03-25+16%3A29%3A55&channelId=2909053&timestamp=1649210306097

Response Parameter Description

Parameter Type Description
code Integer Response status code. 200 indicates success, non-200 indicates failure. See global error description
status String Response status text
message String Response description. When code is 400 or 500, provides auxiliary error reason.
data Object Contains live viewing log information on success [See Data parameter description](#Data参数描述], empty on failure.

Data Parameter Description

Parameter Type Description
pageSize Integer Number of records per page, defaults to 1000
pageNumber Integer Current page number
totalItems Integer Total number of records
contents Array Query result list See Contents parameter description
startRow Integer Position of the first record on the current page in the total result set
firstPage Boolean Whether it is the first page, values: true/false
lastPage Boolean Whether it is the last page, values: true/false
prePageNumber Integer Previous page number
nextPageNumber Integer Next page number
limit Integer Number of items per page
totalPages Integer Total number of pages
endRow Integer Position of the last record on the current page in the total result set
offset Integer Pagination starting record

Contents Parameter Description

Parameter Type Description
playId String ID representing this playback action
userId String Live streaming account ID
channelId String Channel number
playDuration Integer Playback duration, unit: seconds
stayDuration Integer Stay duration, unit: seconds
sessionId String Live session ID
param1 String Viewer ID when using POLYV viewing page
param2 String Viewer nickname when using POLYV viewing page
param3 String Viewing log type, defaults to live
vod: watching replay
live: live stream
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 Video page URL
userAgent String User device
operatingSystem String Operating system
browser String Browser
isMobile String Whether it is a mobile device
currentDay String Query date, format: yyyy-MM-dd
createdTime Long Log creation date, 13-digit millisecond timestamp
lastModified Long Log update date, 13-digit millisecond timestamp
ptype Integer 0 or not passed: normal live stream
1: Ultra-low latency live stream rts (no longer in use)
2: PRTC live stream (no latency)
firstActiveTime Long Page entry time, 13-digit millisecond timestamp. May return null in some cases. Unless specified otherwise, use createdTime instead.
lastActiveTime Long Page exit time, 13-digit millisecond timestamp. May return null in some cases. Unless specified otherwise, use createdTime + stayDuration instead.

Java Request Example

@Test
public void getChannelCardPush2() throws IOException, NoSuchAlgorithmException {
    String appId = super.appId;
    String appSecret = super.appSecret;
    String timestamp = String.valueOf(System.currentTimeMillis());
    //业务参数
    String url = "http://api.polyv.net/live/v3/user/statistics/viewlog";
    
    //http 调用逻辑
    Map<String, String> requestMap = new HashMap<>();
    requestMap.put("appId", appId);
    requestMap.put("timestamp", timestamp);
    requestMap.put("startDate", "2022-03-25 16:29:55");
    requestMap.put("endDate", "2022-03-28 09:55:56");
    requestMap.put("channelId", "2909053");
    requestMap.put("watchType", "live");
    
    requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
    
    String response = HttpUtil.get(url, requestMap);
    
    log.info("测试查询频道卡片推送列表,返回值:{}", response);
}

Response Example

For global system error descriptions, see Global Error Description

Success Example

{
    "code": 200,
    "status": "success",
    "message": "",
    "data":
    {
        "pageSize": 1000,
        "pageNumber": 1,
        "totalItems": 1,
        "contents": [
            {
                "playId": "1648432513206X1501461",
                "userId": "1b448be323",
                "channelId": 2909053,
                "playDuration": 87,
                "stayDuration": 90,
                "sessionId": "g83wdgxfh6",
                "param1": "1648432461504",
                "param2": "回放列表观看",
                "param3": "vod",
                "param4": "",
                "param5": "",
                "ipAddress": "120.228.5.164",
                "country": "中国",
                "province": "湖南",
                "city": "长沙",
                "isp": "移动",
                "referer": "https://live.polyv.cn/watch/2909053",
                "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36",
                "operatingSystem": "Windows",
                "browser": "Chrome 9",
                "isMobile": "N",
                "currentDay": "2022-03-28",
                "createdTime": 1648432556000,
                "lastModified": 1648443664000,
                "ptype": 0,
                "firstActiveTime": 1648432516000,
                "lastActiveTime": 1648432606000
            }],
        "limit": 1,
        "offset": 0,
        "totalPages": 1,
        "endRow": 1,
        "firstPage": true,
        "lastPage": true,
        "prePageNumber": 1,
        "nextPageNumber": 1,
        "startRow": 1
    }
}

Error Example

{
    "code": 400,
    "status": "error",
    "message": "invalid signature.",
    "data": ""
}
联系客服,在线咨询