Polyv Help Center

Help Center

Paginated Query for User Watch Logs

Updated: 2022-09-02 18:08:07

Interface URL

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

Interface Description

1. Purpose: Retrieve user watch logs in a paginated manner.
2. The interface supports the HTTPS protocol.

Supported Response Format

JSON

Request Method

GET

Request Rate Limit

TRUE

Request Parameters

Parameter Required Type Description
appId true string Obtained from API settings, the appId registered in the live streaming system.
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 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
page true string Page number.
pageSize false string Number of data items per page. Default is 1000 items per page.
startDate true (see note below) string Query start time, format: yyyy-MM-dd.
endDate true (see note below) string Query end time, format: yyyy-MM-dd.
channelId false int Channel ID.

Note:

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

Successful Response JSON Example:

{
    "code": 200, 
    "status": "success", 
    "message": "", 
    "data": {
        "pageNumber": 1, 
        "totalItems": 3, 
        "contents": [
{
"playId": "1520501687122X1438160",
"userId": "1c6dc3c666",
"channelId": 151462,
"playDuration": 341,
"stayDuration": 361,
"flowSize": 10028116,
"sessionId": "eyz0awxrlh",
"param1": "1520499775580",
"param2": "广州观众/78614",
"param3": "live",
"param4": "",
"param5": "",
"ipAddress": "59.42.41.1",
"country": "中国",
"province": "广东",
"city": "广州",
"isp": "/南沙区电信",
"referer": "https://live.polyv.cn/watch/151462",
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36",
"operatingSystem": "Mac OS X",
"browser": "Chrome",
"isMobile": "N",
"currentDay": "2018-03-08",
"createdTime": 1520501705000,
"lastModified": 1520504494000
}, 
{
"playId": "1520501157256X1429802",
"userId": "1c6dc3c666",
"channelId": 151462,
"playDuration": 29,
"stayDuration": 528,
"flowSize": 1068201,
"sessionId": "eyz0awxrlh",
"param1": "1520499775580",
"param2": "广州观众/78614",
"param3": "live",
"param4": "",
"param5": "",
"ipAddress": "59.42.41.1",
"country": "中国",
"province": "广东",
"city": "广州",
"isp": "/南沙区电信",
"referer": "https://live.polyv.cn/watch/151462",
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36",
"operatingSystem": "Mac OS X",
"browser": "Chrome",
"isMobile": "N",
"currentDay": "2018-03-08",
"createdTime": 1520501664000,
"lastModified": 1520504494000
}, 
            {
"playId": "1520500551108X1714565",
"userId": "1c6dc3c666",
"channelId": 151462,
"playDuration": 18,
"stayDuration": 20,
"flowSize": 3048444,
"sessionId": "eyz0awxrlh",
"param1": "1520499775580",
"param2": "广州观众/78614",
"param3": "live",
"param4": "",
"param5": "",
"ipAddress": "59.42.40.205",
"country": "中国",
"province": "广东",
"city": "广州",
"isp": "/南沙区电信",
"referer": "https://live.polyv.cn/watch/151462",
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36",
"operatingSystem": "Mac OS X",
"browser": "Chrome",
"isMobile": "N",
"currentDay": "2018-03-08",
"createdTime": 1520500572000,
"lastModified": 1520503294000
}
        ], 
        "endRow": 3, 
        "startRow": 1, 
        "firstPage": true, 
        "lastPage": true, 
        "nextPageNumber": 1, 
        "prePageNumber": 1, 
        "totalPages": 1, 
        "limit": 3, 
        "offset": 0
    }
}

Failed Response JSON Examples:

No appId provided:

{
    "code": 400,
    "status": "error",
    "message": "appId is required.",
    "data": ""
}

Incorrect appId:

{
    "code": 400,
    "status": "error",
    "message": "application not found.",
    "data": ""
}

Timestamp error:

{
    "code": 400,
    "status": "error",
    "message": "invalid timestamp.",
    "data": ""
}

Signature error:

{
    "code": 403,
    "status": "error",
    "message": "invalid signature.",
    "data": ""
}

Query start or end time is empty:

{
    "code": 400,
    "status": "error",
    "message": "startDate and endDate can not be empty.",
    "data": ""
}

Query start time is greater than end time:

{
    "code": 400,
    "status": "error",
    "message": "startDate can not great endDate.",
    "data": ""
}

Query spans across months:

{
    "code": 400,
    "status": "error",
    "message": "unable cross month query",
    "data": ""
}

Invalid channel ID:

{
    "code": 400,
    "status": "error",
    "message": "invalid channelId.",
    "data": ""
}

Field Description

Parameter Description
code Response status code, e.g., 200.
status Response status.
message Error message.
data Response result set.
pageNumber Current page number.
totalItems Total number of items.
contents Query result list.
playId ID representing this playback action.
userId User ID.
channelId Channel number.
playDuration Playback duration.
stayDuration Stay duration.
flowSize Traffic size.
sessionId Live session ID.
param1 Viewer ID from the POLYV watch page.
param2 Viewer nickname from the POLYV watch page.
param3 Watch type: values are live (live stream) or vod (playback).
param4/5 POLYV system parameters.
ipAddress IP address.
country Country.
province Province.
city City.
isp ISP operator.
referer URL of the page playing the video.
userAgent User device.
operatingSystem Operating system.
browser Browser.
isMobile Whether it is a mobile device.
currentDay Log query date (format: yyyy-MM-dd).
createdTime Log creation date (13-digit timestamp).
lastModified Log update date (13-digit timestamp).
firstPage Whether it is the first page, value: true/false.
lastPage Whether it is the last page, value: true/false.
nextPageNumber Next page number.
prePageNumber Previous page number.
totalPages Total number of pages.
startRow Position of the first video on the current page within the playback video list.
endRow Position of the last video on the current page within the playback video list.
limit Number of videos on the current page.

PHP Request Example

<?php

//引用config.php
include 'config.php';

//接口需要的参数(非sign)赋值
$startDate = "2020-03-12";  
$endDate = "2020-03-30";  
$page = "1"; //页数
$pageSize="10";//每页显示的数据

$params = array(
    'appId'=>$appId,
    'startDate'=>$startDate,
    'endDate'=>$endDate,
    'page'=>$page,
    'pageSize'=>$pageSize,
    'timestamp'=>$timestamp
  );

//生成sign
$sign = getSign($params); //详细查看config.php文件的getSign方法

//接口请求url
$url = "http://api.polyv.net/live/v3/user/statistics/viewlog?appId=$appId&startDate=startDate&endDate=endDate&page=$page&pageSize=$pageSize&timestamp=$timestamp&sign=$sign";

//输出接口请求结果
echo file_get_contents($url);
  
?>
联系客服,在线咨询