Polyv Help Center

Help Center

Paginated Query of Viewing Logs for Accounts (Including Check-in Info) – For Fixed Customers

Updated: 2023-04-14 14:20:03

Interface URL

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

Interface Description

1. Purpose: Paginated retrieval of viewing logs with student check-in information for a channel.
2. The interface supports the HTTPS protocol.
3. The {channelId} in the interface URL is the Channel ID.

Supported Format

JSON

Request Method

GET

Request Parameters

Parameter Required Type Description
appId Yes string Obtained from API settings, the appId registered in the live streaming system.
channelId No int Channel ID
timestamp Yes string Current 13-digit millisecond timestamp, valid for 3 minutes.
page Yes string Page number
pageSize No string Number of data items per page, default is 1000.
currentDay See note below string Query date, format: yyyy-MM-dd
startTime See note below string Query start time, 13-digit millisecond timestamp.
endTime See note below string Query end time, 13-digit millisecond timestamp.
param1 No string Viewer user ID
param2 No string Viewer nickname
param3 No string Viewing log type
sign Yes 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

Note:

  1. To query records over a period, pass: startTime, endTime (startTime and endTime must be in the same month). To query records for a specific day, pass currentDay.
  2. At least one of startTime/endTime or currentDay must be provided.
  3. If both currentDay and startTime/endTime are provided, currentDay will be used.

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,
            "leftTime":1520507705000,
            "firstTime": null,
            "lastTime": null,
            "num": 0
            }, 
            {
            "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,
            "leftTime":1520507705000,
            "firstTime": null,
            "lastTime": null,
            "num": 0
            }, 
                        {
            "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,
            "firstTime": 1520501234000,
            "lastTime": 1520505678000,
            "num": 3
            }
        ], 
        "endRow": 3, 
        "startRow": 1, 
        "firstPage": true, 
        "lastPage": true, 
        "nextPageNumber": 1, 
        "prePageNumber": 1, 
        "totalPages": 1, 
        "limit": 3, 
        "offset": 0
    }
}

Failed Response JSON Example:

appId not 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": ""
}

currentDay not provided

{
    "code": 400,
    "status": "error",
    "message": "currentDay is empty.",
    "data": ""
}

Channel does not exist

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

Invalid channel ID

{
    "code": 403,
    "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 Cache duration
flowSize Traffic size
sessionId Live session ID
param1 Viewer ID from the POLYV viewing page
param2 Viewer nickname from the POLYV viewing page
param3 Viewing type: live or vod
param4/5 POLYV system parameters
ipAddress IP address
country Country
province Province
city City
isp ISP operator
referer Video page URL
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)
leftTime Time of leaving the live stream (13-digit timestamp)
firsTime First check-in time in this live session (13-digit timestamp), returns null if no check-in data
lastTime Last check-in time in this live session (13-digit timestamp), returns null if no check-in data
num Number of check-ins in this live session, returns 0 if no check-in data
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 record on the current page in the list
endRow Position of the last record on the current page in the list
limit Number of records on the current page

PHP Request Example

<?php

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

//接口需要的参数(非sign)赋值
$channelId = "124545";
$currentDay = "2018-03-12";  
$page = "1"; //页数
$pageSize="10";//每页显示的数据

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

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

//接口请求url
$url = "http://api.polyv.net/live/v3/channel/statistics/viewlog-with-checkin?appId=$appId&channelId=$channelId&currentDay=$currentDay&page=$page&pageSize=$pageSize&timestamp=$timestamp&sign=$sign";

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